Martin Morgan
2013-Mar-16 22:29 UTC
[Rd] configure.ac clock_gettime (and R_CHECK_FUNCS) incorrect?
When R is configured with CFLAGS=-O2, clock_gettime is included $ nm src/main/libR.a | grep clock_gettime U clock_gettime whereas when configured with -O0 it is not $ nm src/main/libR.a | grep clock_gettime $ Similarly when built as a shared library the linker flags include or not -lrt, and ldd indicates dependency on librt or not. This thread http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-December/005022.html lead to the conclusion that the test for clock_gettime from configure.ac:1838 is flawed, because R_CHECK_FUNCS([clock_gettime timespec_get], [#include <time.h>]) if test "${ac_cv_have_decl_clock_gettime}" = "yes"; then AC_CHECK_LIB(rt, clock_gettime) fi generates test code, from config.log, which looks like | int | main () | { | #ifndef clock_gettime | char *p = (char *) clock_gettime; | #endif | | ; | return 0; | } when compiled with CFLAGS=-O2, the assignment to p is optimized out and the test succeeds whether clock_gettime is present or not; the autoconf macro may add -lrt to the compile flags. When compiled with CFLAGS=-O0, the test fails and autoconf does not try to add -lrt, even though that might be (is) necessary. It seems that R_CHECK_FUNCS (R_CHECK_DECLS) in general and the logic of this specific test need revisiting? $ bin/R --version R Under development (unstable) (2013-03-16 r62282) -- "Unsuffered Consequences" ... on $ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. or $ clang --version Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0) Target: x86_64-pc-linux-gnu Thread model: posix Martin -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793