Closed nunotexbsd closed 10 months ago
No clue as to what could be failing, because we are OK on CRAN.
Hashicorp/Atlas® Vagrant™:
Instances can be deployed using the vagrant utility:
% vagrant init freebsd/FreeBSD-13.2-RELEASE
% vagrant up
From testthat.Rout.fail:
== Failed tests ================================================================
-- Failure ('test_math.R:60:3'): we can take logarithms units ------------------
units(log1p(ux)) (`actual`) not equal to units(as_units("ln(re 1 m)", force_single_symbol = TRUE)) (`expected`).
`actual$numerator`: "1 ln(re 1 m)"
`expected$numerator`: "ln(re 1 m)"
-- Failure ('test_math.R:63:3'): we can take logarithms units ------------------
units(log(ux)) (`actual`) not equal to units(as_units("ln(re 1 m)", force_single_symbol = TRUE)) (`expected`).
`actual$numerator`: "1 ln(re 1 m)"
`expected$numerator`: "ln(re 1 m)"
[ FAIL 2 | WARN 0 | SKIP 11 | PASS 439 ]
Could you please run the following and report the output?
#include <stdio.h>
#include <math.h>
#include <udunits2/udunits2.h>
int main() {
ut_set_error_message_handler((ut_error_message_handler) ut_ignore);
ut_system *sys = ut_read_xml(NULL);
ut_encoding enc = UT_UTF8;
ut_set_error_message_handler((ut_error_message_handler) vprintf);
ut_unit *meter = ut_parse(sys, "1 m", enc);
ut_unit *logmeter = ut_log(exp(1), meter);
char out[128];
ut_format(logmeter, out, sizeof(out), enc);
printf("%s\n", out);
ut_free(meter);
ut_free(logmeter);
ut_free_system(sys);
return 0;
}
Save this as test.c
and then
$ gcc test.c -l udunits2 && ./a.out
ln(re 1 m)
(...)
Forgot to add -l udunits2
@Enchufa2
Changed #include <udunits2/udunits2.h>
to #include <udunits2.h>
It compiles without any warning and ./a.out
gives result: ln(re 1 m)
@Enchufa2
It fails with clang with a core dump:
clang test.c -shared -L/usr/local/lib/R/lib -Wl,-rpath=/usr/local/lib/gcc12 -L/usr/local/lib/gcc12 -B/usr/local/bin -L/usr/local/lib -I/usr/local/include -ludunits2
./a.out: Segmentation fault (core dumped)
Maybe the problem is from clang?
I'm a little bit confused but it seems that FreeBSD ports framework uses clang + gcc fortran for compiling for what I see in package build log:
using C++ compiler: 'FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)'
gmake[1]: Entering directory '/wrkdirs/usr/ports/math/R-cran-units/work/units/src'
c++ -std=gnu++17 -I"/usr/local/lib/R/include" -DNDEBUG -DUDUNITS2_DIR=0 -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -I'/usr/local/lib/R/library/Rcpp/include' -DLIBICONV_PLUG -I/usr/local/in
clude -isystem /usr/local/include -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -c RcppExports.cpp -o
RcppExports.o
c++ -std=gnu++17 -I"/usr/local/lib/R/include" -DNDEBUG -DUDUNITS2_DIR=0 -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -I'/usr/local/lib/R/library/Rcpp/include' -DLIBICONV_PLUG -I/usr/local/in
clude -isystem /usr/local/include -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -DLIBICONV_PLUG -isystem /usr/local/include -c udunits.cpp -o udu
nits.o
c++ -std=gnu++17 -shared -L/usr/local/lib/R/lib -Wl,-rpath=/usr/local/lib/gcc12 -L/usr/local/lib/gcc12 -B/usr/local/bin -L/usr/local/lib -fstack-protector-strong -o units.so RcppExports.o udunits.o -lexpat -lexpa
t -ludunits2 -L/usr/local/lib/R/lib -lR
gmake[1]: Leaving directory '/wrkdirs/usr/ports/math/R-cran-units/work/units/src'
installing to /wrkdirs/usr/ports/math/R-cran-units/work/stage/usr/local/lib/R/library/00LOCK-units/00new/units/libs
We are compiling a program in my example above, not a shared library, so -shared
shouldn't be added. With clang, try
$ clang test.c -ludunits2 -lm && ./a.out
ln(re 1 m)
I spinned a FreeBSD 14 virtual machine using the official qcow2 image, and I see:
$ clang test.c -ludunits2 -lm -I/usr/local/include -L/usr/local/lib && ./a.out
1 ln(re 1 m)
So this may be an upstream bug in udunits2, because in all the other platforms (and other bases within the same platform) do not show that leading 1
. I suggest to submit this upstream, and we can close this.
units
works just fine, with or without that 1
. And as said, all checks are ok on CRAN. So meanwhile you can safely skip those two tests in FreeBSD.
In fact,
$ gcc12 test.c -ludunits2 -lm -I/usr/local/include -L/usr/local/lib && ./a.out
ln(re 1 m)
produces the correct output in FreeBSD, and clang-16 does too on Linux. So... it may be some issue with FreeBSD's clang... I don't know, but units
seems to be ok.
Tests failure on FreeBSD14/R4.3.1 Port: https://www.freshports.org/math/R-cran-units/
Any clues? Thanks