Skip to content

Commit

Permalink
retain PKG_* user-supplied env values (#4735)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle committed Oct 3, 2020
1 parent db5afd2 commit ba2d7bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .dev/CRAN_Release.cmd
Expand Up @@ -240,6 +240,12 @@ require(data.table)
test.data.table()
q("no")

# User supplied PKG_CFLAGS and PKG_LIBS passed through, #4664
# Next line from https://mac.r-project.org/openmp/. Should see the arguments passed through and then fail with gcc on linux.
PKG_CFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL data.table_1.13.1.tar.gz
# Next line should work on Linux, just using superfluous and duplicate but valid parameters here to see them retained and work
PKG_CFLAGS='-fopenmp' PKG_LIBS=-lz R CMD INSTALL data.table_1.13.1.tar.gz

R
remove.packages("xml2") # we checked the URLs; don't need to do it again (many minutes)
require(data.table)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Expand Up @@ -28,6 +28,10 @@

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.

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


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

Expand Down
5 changes: 4 additions & 1 deletion configure
Expand Up @@ -85,7 +85,7 @@ EOF

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

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

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

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

2 comments on commit ba2d7bb

@markkvdb
Copy link

@markkvdb markkvdb commented on ba2d7bb Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit results in an error in the compilation of data.table on macOS 10.15.6 for me. While data.table 1.13.0 installs as expected when I follow the instructions as provided in the Wiki, trying to install 1.13.1 results in the following error:

* installing *source* package ‘data.table’ ...
** using staged installation
zlib 1.2.11 is available ok
OpenMP supported
sed: 1: "src/Makevars": unterminated substitute in regular expression
sed: 1: "src/Makevars": unterminated substitute in regular expression
** libs
/usr/local/opt/llvm/bin/clang -fopenmp -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include  @PKG_CFLAGS@  -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assign.c -o assign.o
clang-10: error: no such file or directory: '@PKG_CFLAGS@'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/data.table’

The problem seems to be in the Makevars file with an unterminated substitute.

@jangorecki
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @markkvdb, you can track status of this issue in #4742. It will be fix soon.

Please sign in to comment.