vdorie / stan4bart

Uses Stan sampler and math library to semiparametrically fit linear and multilevel models with additive Bayesian Additive Regression Tree (BART) components.
40 stars 4 forks source link

cppflags are not processed correctly: no space after `-DTBB_INTERFACE_NEW`: `warning: ISO C++11 requires whitespace after the macro name` #15

Open barracuda156 opened 1 month ago

barracuda156 commented 1 month ago

@vdorie For some reason, flags get glued together, i.e. there is no space between these: -DTBB_INTERFACE_NEW-I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include'.

--->  Configuring R-stan4bart
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stan4bart/R-stan4bart/work/stan4bart" && /opt/local/bin/R CMD build . --no-manual --no-build-vignettes --keep-empty-dirs 
* checking for file ‘./DESCRIPTION’ ... OK
* preparing ‘stan4bart’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘stan4bart_0.0-10.tar.gz’

--->  Building R-stan4bart
xinstall: mkdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stan4bart/R-stan4bart/work/build
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stan4bart/R-stan4bart/work/stan4bart" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stan4bart/R-stan4bart/work/build --install-tests 
* installing *source* package ‘stan4bart’ ...
file ‘configure’ has the wrong MD5 checksum
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether /opt/local/bin/g++-mp-13 accepts -g... yes
checking for /opt/local/bin/g++-mp-13 option to enable C++11 features... none needed
checking how to run the C++ preprocessor... /opt/local/bin/g++-mp-13 -E
checking whether the compiler supports GNU C++... (cached) yes
checking whether /opt/local/bin/g++-mp-13 accepts -g... (cached) yes
checking for /opt/local/bin/g++-mp-13 option to enable C++11 features... (cached) none needed
checking build system type... powerpc-apple-darwin10.0.0d2
checking host system type... powerpc-apple-darwin10.0.0d2
checking for gcc... /opt/local/bin/gcc-mp-13
checking whether the compiler supports GNU C... yes
checking whether /opt/local/bin/gcc-mp-13 accepts -g... yes
checking for /opt/local/bin/gcc-mp-13 option to enable C11 features... none needed
checking for x86 cpuid  output... unknown
checking for x86-AVX xgetbv  output... unknown
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for malloc.h... no
checking size of size_t... 4
checking alignment of void*... 4
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for working posix_memalign... yes
checking for ffs... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/config.h
** libs
using C compiler: ‘gcc-mp-13 (MacPorts gcc13 13.3.0_0+stdlib_flag) 13.3.0’
using C++ compiler: ‘g++-mp-13 (MacPorts gcc13 13.3.0_0+stdlib_flag) 13.3.0’
using C++17
Warning in system2("xcrun", "--show-sdk-path", TRUE, TRUE) :
  running command ''xcrun' --show-sdk-path 2>&1' had status 64
using SDK: ‘NA’‘NA’‘NA’‘NA’‘NA’‘NA’
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include   -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW-I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS   -fPIC  -pipe -Os -arch ppc   -c bart_util.cpp -o bart_util.o
<command-line>: warning: ISO C++11 requires whitespace after the macro name
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include   -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW-I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS   -fPIC  -pipe -Os -arch ppc   -c init.cpp -o init.o
<command-line>: warning: ISO C++11 requires whitespace after the macro name
/opt/local/bin/gcc-mp-13 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c misc_adaptiveRadixTree.c -o misc_adaptiveRadixTree.o
/opt/local/bin/gcc-mp-13 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c misc_string.c -o misc_string.o
/opt/local/bin/gcc-mp-13 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c rc_bounds.c -o rc_bounds.o
/opt/local/bin/gcc-mp-13 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc  -c rc_util.c -o rc_util.o
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/dbarts/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include   -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW-I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS   -fPIC  -pipe -Os -arch ppc   -c stan_sampler.cpp -o stan_sampler.o
<command-line>: warning: ISO C++11 requires whitespace after the macro name
/opt/local/bin/g++-mp-13 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -Wl,-headerpad_max_install_names -L/opt/local/lib -lMacportsLegacySupport -Wl,-rpath,/opt/local/lib/libgcc -arch ppc -o stan4bart.so bart_util.o init.o misc_adaptiveRadixTree.o misc_string.o rc_bounds.o rc_util.o stan_sampler.o -L/opt/local/libexec/onetbb/lib -Wl,-rpath,/opt/local/libexec/onetbb/lib -ltbb -ltbbmalloc -L/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/lib/ -Wl,-rpath,/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/lib/ -ltbb -ltbbmalloc -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stan4bart/R-stan4bart/work/build/00LOCK-stan4bart/00new/stan4bart/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (stan4bart)

Compiler gets rightfully upset about that, though the build succeeds.

For comparison, there is no issue with cppflags on the same system when I build blavaan (which also used RcppParallel and oneTBB):

--->  Building R-blavaan
xinstall: mkdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-blavaan/R-blavaan/work/build
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-blavaan/R-blavaan/work/blavaan" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-blavaan/R-blavaan/work/build --install-tests 
* installing *source* package ‘blavaan’ ...
file ‘configure’ has the wrong MD5 checksum
** using staged installation
** libs
using C++ compiler: ‘g++-mp-13 (MacPorts gcc13 13.3.0_0+stdlib_flag) 13.3.0’
using C++17
Warning in system2("xcrun", "--show-sdk-path", TRUE, TRUE) :
  running command ''xcrun' --show-sdk-path 2>&1' had status 64
using SDK: ‘NA’‘NA’‘NA’‘NA’‘NA’‘NA’

/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"../inst/include" -I"/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/StanHeaders/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/rstan/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include   -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -DTBB_INTERFACE_NEW   --param ggc-min-expand=10 -fPIC  -pipe -Os -arch ppc   -c RcppExports.cpp -o RcppExports.o

/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"../inst/include" -I"/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error -DUSE_STANC3 -D_HAS_AUTO_PTR_ETC=0 -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/StanHeaders/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/rstan/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppEigen/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include   -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS -DTBB_INTERFACE_NEW   --param ggc-min-expand=10 -fPIC  -pipe -Os -arch ppc   -c stanExports_stanmarg.cc -o stanExports_stanmarg.o
barracuda156 commented 1 month ago

The problem is reflected in generated Makevars:

TBB_LIB = /opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/lib/
PKG_CPPFLAGS = -I"include" -I"include/sundials" -I"../inst/include" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG
PKG_CXXFLAGS = -I/opt/local/libexec/onetbb/include -DTBB_INTERFACE_NEW-I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/include' -D_REENTRANT -DSTAN_THREADS  
SHLIB_LDFLAGS = $(SHLIB_CXXLDFLAGS)
SHLIB_LD = $(SHLIB_CXXLD)
PKG_LIBS = -L/opt/local/libexec/onetbb/lib -Wl,-rpath,/opt/local/libexec/onetbb/lib -ltbb -ltbbmalloc -L/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/lib/ -Wl,-rpath,'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc

CXX_STD = CXX17
SOURCES = bart_util.cpp init.cpp misc_adaptiveRadixTree.c misc_string.c rc_bounds.c rc_util.c stan_sampler.cpp
OBJECTS = bart_util.o init.o misc_adaptiveRadixTree.o misc_string.o rc_bounds.o rc_util.o stan_sampler.o

all: $(SHLIB)

clean:
        rm -rf *.so *.o
        rm -rf config.h

.phony: all clean
vdorie commented 1 month ago

I just pushed a change to the configure script in 42f9c58. Since I can't replicate the problem locally, please let me know if it addresses the issue.