Skip to content

Commit ba2d7bb

Browse files
authored
retain PKG_* user-supplied env values (#4735)
1 parent db5afd2 commit ba2d7bb

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

.dev/CRAN_Release.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ require(data.table)
240240
test.data.table()
241241
q("no")
242242

243+
# User supplied PKG_CFLAGS and PKG_LIBS passed through, #4664
244+
# Next line from https://mac.r-project.org/openmp/. Should see the arguments passed through and then fail with gcc on linux.
245+
PKG_CFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL data.table_1.13.1.tar.gz
246+
# Next line should work on Linux, just using superfluous and duplicate but valid parameters here to see them retained and work
247+
PKG_CFLAGS='-fopenmp' PKG_LIBS=-lz R CMD INSTALL data.table_1.13.1.tar.gz
248+
243249
R
244250
remove.packages("xml2") # we checked the URLs; don't need to do it again (many minutes)
245251
require(data.table)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
3. `test.data.table()` failed in non-English locales such as `LC_TIME=fr_FR.UTF-8` due to `Jan` vs `janv.` in tests 168 and 2042, [#3450](https://github.com/Rdatatable/data.table/issues/3450). Thanks to @shrektan for reporting, and @tdhock for making the tests locale-aware.
3030

31+
4. User-supplied `PKG_LIBS` and `PKG_CFLAGS` are now retained and the suggestion in https://mac.r-project.org/openmp/; i.e.,
32+
`PKG_CPPFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL data.table_<ver>.tar.gz`
33+
has a better chance of working on Mac.
34+
3135

3236
# data.table [v1.13.0](https://github.com/Rdatatable/data.table/milestone/17?closed=1) (24 Jul 2020)
3337

configure

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ EOF
8585

8686
if [ "$R_NO_OPENMP" = "1" ]; then
8787
# Compilation failed -- try forcing -fopenmp instead.
88-
"${CC}" "${CFLAGS}" -fopenmp test-omp.c || R_NO_OPENMP=1
88+
${CC} ${CFLAGS} -fopenmp test-omp.c || R_NO_OPENMP=1
8989
fi
9090

9191
# Clean up.
@@ -103,5 +103,8 @@ else
103103
echo "OpenMP supported"
104104
sed -e "s|@openmp_cflags@|\$(SHLIB_OPENMP_CFLAGS)|" src/Makevars.in > src/Makevars
105105
fi
106+
# retain user supplied PKG_ env variables, #4664. See comments in Makevars.in too.
107+
sed -i "s|@PKG_CFLAGS@|$PKG_CFLAGS|" src/Makevars
108+
sed -i "s|@PKG_LIBS@|$PKG_LIBS|" src/Makevars
106109

107110
exit 0

src/Makevars.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
PKG_CFLAGS = @openmp_cflags@
2-
PKG_LIBS = @openmp_cflags@ -lz
1+
PKG_CFLAGS = @PKG_CFLAGS@ @openmp_cflags@
2+
PKG_LIBS = @PKG_LIBS@ @openmp_cflags@ -lz
3+
# See WRE $1.2.1.1. But retain user supplied PKG_* too, #4664.
4+
# WRE states ($1.6) that += isn't portable and that we aren't allowed to use it.
5+
# Otherwise we could use the much simpler PKG_LIBS += @openmp_cflags@ -lz.
6+
# Can't do PKG_LIBS = $(PKG_LIBS)... either because that's a 'recursive variable reference' error in make
7+
# Hence the onerous @...@ substitution. Is it still appropriate in 2020 that we can't use +=?
38

49
all: $(SHLIB)
510
if [ "$(SHLIB)" != "datatable$(SHLIB_EXT)" ]; then mv $(SHLIB) datatable$(SHLIB_EXT); fi

0 commit comments

Comments
 (0)