microbenchmark icon indicating copy to clipboard operation
microbenchmark copied to clipboard

Build fails on FreeBSD-13

Open wesnm opened this issue 3 years ago • 1 comments
trafficstars

Description

Build fails on FreeBSD. This is due to supplying "-D_POSIX_C_SOURCE=200112L" to the compiler. The end result is that __BSD_VISIBLE isn't defined, and then CLOCK_MONOTONIC_PRECISE is not defined in <sys/_clock_id.h>, which is included from <time.h>. Ironically it's the literal opposite of the comment in src/Makevars.in.

Since configure doesn't define this when checking for CLOCK_MONOTONIC_PRECISE, it successfully finds it available, but during compilation it is actually not defined.

cc -I"/usr/local/lib/R/include" -DNDEBUG -D_POSIX_C_SOURCE=200112L -DHAVE_CONFIG_H  -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include   -fpic  -O2 -pipe -pipe -msse4.2 -O2 -fno-strict-aliasing -march=haswell  -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include   -c nanotimer.c -o nanotimer.o
In file included from nanotimer.c:22:
./nanotimer_clock_gettime.h:13:19: error: use of undeclared identifier 'CLOCK_MONOTONIC_PRECISE'
    clock_gettime(MB_CLOCKID_T, &time_var);
                  ^
./config.h:35:22: note: expanded from macro 'MB_CLOCKID_T'
#define MB_CLOCKID_T CLOCK_MONOTONIC_PRECISE
                     ^
1 error generated.
gmake: *** [/usr/local/lib/R/etc/Makeconf:168: nanotimer.o] Error 1
ERROR: compilation failed for package ‘microbenchmark’

Session Info

R version 4.1.2 (2021-11-01)
Platform: amd64-portbld-freebsd13.0 (64-bit)
Running under: FreeBSD mercury.chemikals.org 13.0-STABLE FreeBSD 13.0-STABLE #2 stable/13-9a00da73a: Sat Oct 23 18:21:20 CDT 2021     [email protected]:/usr/obj/usr/src/amd64.amd64/sys/MERCURY  amd64

Matrix products: default
LAPACK: /usr/local/lib/R/lib/libRlapack.so.4.1.2

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2   

wesnm avatar Dec 04 '21 01:12 wesnm

Thanks for the report! Would you be willing to attempt a patch? I'd really appreciate it!

joshuaulrich avatar Dec 06 '21 16:12 joshuaulrich

@wesnm This fix is on CRAN now.

joshuaulrich avatar Sep 04 '24 19:09 joshuaulrich

I just tried 1.5.0. It builds, installs and runs fine on FreeBSD! Many thanks :D

rhurlin avatar Sep 04 '24 19:09 rhurlin