During an exp-run for llvm 13 (see bug 258209), it turned out that math/R fails to build with clang 13 (http://gohan04.nyi.freebsd.org/data/mainamd64PR258209-default/2021-09-30_06h20m28s/logs/errors/R-4.1.1_1.log): begin installing recommended package mgcv * installing *source* package ‘mgcv’ ... ** package ‘mgcv’ successfully unpacked and MD5 sums checked ** using non-staged installation ** libs gmake[4]: Entering directory '/tmp/RtmpJN7T4d/R.INSTALLb1494371d851/mgcv/src' cc -I"/wrkdirs/usr/ports/math/R/work/R-4.1.1/include" -DNDEBUG -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -fopenmp -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -c coxph.c -o coxph.o cc -I"/wrkdirs/usr/ports/math/R/work/R-4.1.1/include" -DNDEBUG -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -fopenmp -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -c davies.c -o davies.o cc -I"/wrkdirs/usr/ports/math/R/work/R-4.1.1/include" -DNDEBUG -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -fopenmp -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -c discrete.c -o discrete.o In file included from discrete.c:28: /usr/include/omp.h:484:39: error: expected 'match' clause on 'omp declare variant' directive #pragma omp begin declare variant match(device={kind(host)}) ^ /wrkdirs/usr/ports/math/R/work/R-4.1.1/include/Rinternals.h:1640:17: note: expanded from macro 'match' #define match Rf_match ^ In file included from discrete.c:28: /usr/include/omp.h:487:39: error: expected 'match' clause on 'omp declare variant' directive #pragma omp begin declare variant match(device={kind(nohost)}) ^ /wrkdirs/usr/ports/math/R/work/R-4.1.1/include/Rinternals.h:1640:17: note: expanded from macro 'match' #define match Rf_match ^ 2 errors generated. What happens here is that the mgcv package includes <omp.h> *after* including <R.h>, which causes the conflict between the "#define match" and the openm pragma line which uses match(). This problem was fixed in mgcv 1.8-37 (https://cran.r-project.org/web/packages/mgcv/ChangeLog) with the small mention: > 1.8-37 > > * minor update for clang compatibility. basically, in most of the .c files, "#include <omp.h>" was moved before "#include <R.h>". Locally, I was able to 'fix' it by replacing /wrkdirs/usr/ports/math/R/work/R-4.1.1/src/library/Recommended/mgcv.tgz with a copy of https://cran.r-project.org/src/contrib/mgcv_1.8-37.tar.gz, but I am unsure how this can be done more correctly for the math/R port. Maybe the mgcv_1.8-37.tar.gz file can be added as an additional distfile, and added to the port Makefile, somehow? Any ideas are welcome.
Could you test https://reviews.freebsd.org/D32280 ?
(In reply to Joseph Mingrone from comment #1) As noted in the review, it builds with clang 13, installs, and seems to run fine for me. Thanks for the quick fix!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=16c89d12ec5c03f824e4925d18b8849c4ab1e86b commit 16c89d12ec5c03f824e4925d18b8849c4ab1e86b Author: Joseph Mingrone <jrm@FreeBSD.org> AuthorDate: 2021-10-03 14:20:38 +0000 Commit: Joseph Mingrone <jrm@FreeBSD.org> CommitDate: 2021-10-03 20:28:52 +0000 math/R: Fix build with clang/openmp 13 The mgcv package is one of the recommended packages to be installed with R. A problem with mgcv and clang/openmp 13 is that mgcv versions prior to 1.8-37 place 'include <omp.h>' after 'include <R.h>'. This causes a conflict between '#define match' and an openmp pragma line, which uses match(). This problem was fixed in mgcv 1.8-37, so replace mgcv 1.8-36 with this newer version. While here, incorporate formatting changes suggested by portclippy and portfmt. PR: 258887 Approved by: dim Differential Revision: https://reviews.freebsd.org/D32280 math/R/Makefile | 18 ++++++++++++------ math/R/distinfo | 4 +++- math/R/pkg-plist | 2 -- 3 files changed, 15 insertions(+), 9 deletions(-)
Thanks for confirming.