diff --git a/.Rbuildignore b/.Rbuildignore index a3193d4f25..2b3483fa0e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,6 +15,7 @@ ^NEWS\.0\.md$ ^README\.md$ ^_pkgdown\.yml$ +^src/Makevars$ ^\.RData$ ^\.Rhistory$ diff --git a/.gitignore b/.gitignore index ce159ee5f6..35a25bc087 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ Rplots.pdf *-Ex.R data.table_*.tar.gz data.table.Rcheck +src/Makevars # Emacs IDE files .emacs.desktop diff --git a/NEWS.md b/NEWS.md index 4a0033fcfa..1cfad0b453 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ 1. `DT[, {...; .(A,B)}]` (i.e. when `.()` is the final item of a multi-statement `{...}`) now auto-names the columns `A` and `B` (just like `DT[, .(A,B)]`) rather than `V1` and `V2`, [#2478](https://github.com/Rdatatable/data.table/issues/2478) [#609](https://github.com/Rdatatable/data.table/issues/609). Similarly, `DT[, if (.N>1) .(B), by=A]` now auto-names the column `B` rather than `V1`. Explicit names are unaffected; e.g. `DT[, {... y= ...; .(A=C+y)}, by=...]` named the column `A` before, and still does. Thanks also to @renkun-ken for his go-first strong testing which caught an issue not caught by the test suite or by revdep testing, related to NULL being the last item, [#4061](https://github.com/Rdatatable/data.table/issues/4061). +2. Compiler support for OpenMP is now detected during installation, which allows data.table to compile even if the users' toolchain differs from CRANs, as is common on macOS, [#2161](https://github.com/Rdatatable/data.table/issues/2161). Thanks @jimhester for the PR. + ## BUG FIXES ## NOTES diff --git a/cleanup b/cleanup new file mode 100755 index 0000000000..3c020d3881 --- /dev/null +++ b/cleanup @@ -0,0 +1,2 @@ +#!/bin/sh +rm -f src/Makevars diff --git a/configure b/configure index 96fc844a18..b20ba04b4b 100755 --- a/configure +++ b/configure @@ -50,5 +50,27 @@ fi version=`pkg-config --modversion zlib` echo "zlib ${version} is available ok" -exit 0 +# Find R compilers +CC=`${R_HOME}/bin/R CMD config CC` +CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` +CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS` + +# Test if we have a OPENMP compatible compiler +echo "#include \nint main () { return omp_get_num_threads (); }" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} ${SHLIB_OPENMP_CFLAGS} -E -xc - >/dev/null 2>&1 || R_NO_OPENMP=1; + +# Write to Makevars +if [ $R_NO_OPENMP ]; then + echo "*** OpenMP not supported! data.table uses OpenMP to automatically" + echo "*** parallelize operations like sorting, grouping, file reading, etc." + echo "*** For details on how to install the necessary toolchains on your OS see:" + echo "*** https://github.com/Rdatatable/data.table/wiki/Installation" + echo "*** Continuing installation without OpenMP support..." + sed -e "s|@openmp_cflags@||" src/Makevars.in > src/Makevars +else + echo "OpenMP supported" + sed -e "s|@openmp_cflags@|\$(SHLIB_OPENMP_CFLAGS)|" src/Makevars.in > src/Makevars +fi + + +exit 0 diff --git a/src/Makevars b/src/Makevars.in similarity index 70% rename from src/Makevars rename to src/Makevars.in index e8e586004c..8f20d70560 100644 --- a/src/Makevars +++ b/src/Makevars.in @@ -1,9 +1,6 @@ - -PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) -PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) -lz +PKG_CFLAGS = @openmp_cflags@ +PKG_LIBS = @openmp_cflags@ -lz all: $(SHLIB) mv $(SHLIB) datatable$(SHLIB_EXT) if [ "$(OS)" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id datatable$(SHLIB_EXT) datatable$(SHLIB_EXT); fi - - diff --git a/src/Makevars.win b/src/Makevars.win new file mode 100644 index 0000000000..3ea29da12d --- /dev/null +++ b/src/Makevars.win @@ -0,0 +1,5 @@ +PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) +PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) -lz + +all: $(SHLIB) + mv $(SHLIB) datatable$(SHLIB_EXT)