Given some of the misinformation in this thread I have to clarify a few things for posterity.
Firstly, the issue was very simple one - the package failed to link the omp library which is required and documented at https://mac.r-project.org/openmp/ -- the required flags are: PKG_CPPFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp and the latter was missing in the package. Any code using OpenMP must link to the OpenMP run-time library which provides the actual implementation, otherwise it doesn't work. Second, there are no special compilers required, but the Apple driver don't accept the -fopenmp flag so it has to be specified as above, essentially working around the driver removing it - which is why this is considered experimental. Finally, the only officially supported way is to use OpenMP flags provided by R. However, the macOS R releases are not built with OpenMP support, because the run-time is not part of macOS and current R doesn't know about the work-arounds. That said, in order to prepare for a possible OpenMP support on macOS, the R 4.3.0 release includes the LLVM OpenMP run-time compatible with Xcode 14.2. This is intended as a stepping stone where the possibly of OpenMP support using Apple compilers is can be tested. R itself currently does not have a provision to leverage this "non-standard" support, but it could be added in the future. Cheers, Simon > On 1/05/2023, at 1:34 PM, Kasper Daniel Hansen <kasperdanielhan...@gmail.com> > wrote: > > Rodney, > > I don't know much about OpenMP and macOS, but note that these days > https://mac.r-project.org/tools/ > says > "Additional information on the OpenMP page is available for those > interested in OpenMP support which is not supported by Apple, but still > possible with additional libraries." > and links to > https://mac.r-project.org/openmp/ > > I _believe_ that this requires the _user_ (or the check/build system) of > the package on macOS to install one of the custom clang compilers listed on > the page. For this reason, I don't think it is trivial to get the > package through CRAN or distribute the package if it links / uses OpenMP. I > could be wrong of course, since it is not something I follow. I am guessing > the best solution (which could be complicated) is to have a configure > script which checks at build time whether the system supports OpenMP. This > feels like something someone has thought about. > > Best, > Kasper > > > > > On Sat, Apr 29, 2023 at 6:32 PM Sparapani, Rodney via R-SIG-Mac < > r-sig-mac@r-project.org> wrote: > >> Oh, that was totally self-inflicted. >> I had commented out PKG_LIBS in Makevars.in >> That does work on Linux with OpenMP somehow. >> However, it does NOT with macOS. Thanks >> >> -- >> Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His >> Director, Wisconsin Chapter of the American Statistical Association >> Institute for Health and Equity, Division of Biostatistics >> Medical College of Wisconsin, Milwaukee Campus >> >> >> From: R-SIG-Mac <r-sig-mac-boun...@r-project.org> on behalf of Sparapani, >> Rodney via R-SIG-Mac <r-sig-mac@r-project.org> >> Date: Saturday, April 29, 2023 at 4:18 PM >> To: r-sig-mac@r-project.org <r-sig-mac@r-project.org> >> Subject: [R-SIG-Mac] symbol not found in flat namespace '___kmpc_critical' >> ATTENTION: This email originated from a sender outside of MCW. Use caution >> when clicking on links or opening attachments. >> ________________________________ >> >> Hi Gang: >> >> After hours of debugging, I�m stuck and hoping that someone has an >> idea of what the issue is here. Any hints/tips/etc. are greatly >> appreciated! >> >> I�m getting this error from my CRAN package, nftbart. Right now, I�m >> preparing for a new release: v1.6. However, I�m stumped by this error >> message that I get when installing with OpenMP. Without OpenMP, >> everything is fine; however, the package benefits greatly from OpenMP. >> >> I am getting the same results for R 4.2.3 and 4.3.0 RC. The source code is >> on github at >> https://urldefense.com/v3/__https://github.com/rsparapa/bnptools.git__;!!H8mHWRdzp34!4rScCMt0gCJ2ZzuZjzo9CEWXYOBECh814z0fzF0OiVjfFcc609ThiLvNcCYt4sIk7wrZhld1ErXx7PLOgKyTDw$ >> < >> https://urldefense.com/v3/__https:/github.com/rsparapa/bnptools.git__;!!H8mHWRdzp34!4rScCMt0gCJ2ZzuZjzo9CEWXYOBECh814z0fzF0OiVjfFcc609ThiLvNcCYt4sIk7wrZhld1ErXx7PLOgKyTDw$ >>> >> >> So, to demonstrate, you just need to do something like this� >> >> >> $ git clone >> https://urldefense.com/v3/__https://github.com/rsparapa/bnptools.git__;!!H8mHWRdzp34!4rScCMt0gCJ2ZzuZjzo9CEWXYOBECh814z0fzF0OiVjfFcc609ThiLvNcCYt4sIk7wrZhld1ErXx7PLOgKyTDw$ >> < >> https://urldefense.com/v3/__https:/github.com/rsparapa/bnptools.git__;!!H8mHWRdzp34!4rScCMt0gCJ2ZzuZjzo9CEWXYOBECh814z0fzF0OiVjfFcc609ThiLvNcCYt4sIk7wrZhld1ErXx7PLOgKyTDw$> >> DIR >> >> $ cd DIR >> >> $ R CMD build nftbart >> >> $ R CMD INSTALL nftbart_1.6.tar.gz >> >> * installing to library >> �/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library� >> >> * installing *source* package �nftbart� ... >> >> ** 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 we are using the GNU C++ compiler... yes >> >> checking whether clang++ -arch x86_64 -std=gnu++17 accepts -g... yes >> >> checking for clang++ -arch x86_64 -std=gnu++17 option to support OpenMP... >> -lomp -Xclang -fopenmp >> >> configure: creating ./config.status >> >> config.status: creating src/Makevars >> >> ** libs >> >> using C compiler: �Apple clang version 14.0.3 (clang-1403.0.22.14.1)� >> >> using C++ compiler: �Apple clang version 14.0.3 (clang-1403.0.22.14.1)� >> >> using SDK: �� >> >> clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" >> -DNDEBUG -lomp -Xclang -fopenmp >> -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' >> -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -c >> init.c -o init.o >> >> clang++ -arch x86_64 -std=gnu++17 >> -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -lomp >> -Xclang -fopenmp >> -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' >> -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -c >> nftbart.cpp -o nftbart.o >> >> clang++ -arch x86_64 -std=gnu++17 -dynamiclib >> -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module >> -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib >> -L/opt/R/x86_64/lib -o nftbart.so init.o nftbart.o >> -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework >> -Wl,CoreFoundation >> >> installing to >> /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/00LOCK-nftbart/00new/nftbart/libs >> >> ** R >> >> ** data >> >> ** demo >> >> ** 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 >> >> Error: package or namespace load failed for �nftbart� in dyn.load(file, >> DLLpath = DLLpath, ...): >> >> unable to load shared object >> '/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/00LOCK-nftbart/00new/nftbart/libs/nftbart.so': >> >> >> dlopen(/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/00LOCK-nftbart/00new/nftbart/libs/nftbart.so, >> 0x0006): symbol not found in flat namespace '___kmpc_critical' >> >> Error: loading failed >> >> Execution halted >> >> ERROR: loading failed >> >> * removing >> �/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/nftbart� >> >> * restoring previous >> �/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/nftbart� >> >>> sessionInfo() >> R version 4.3.0 Patched (2023-04-27 r84338) >> Platform: x86_64-apple-darwin20 (64-bit) >> Running under: macOS Ventura 13.2.1 >> >> Matrix products: default >> BLAS: >> /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib >> LAPACK: >> /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; >> LAPACK version 3.11.0 >> >> locale: >> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 >> >> time zone: America/Chicago >> tzcode source: internal >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> loaded via a namespace (and not attached): >> [1] compiler_4.3.0 >>> >> >> OpenMP Build: LLVM 14.0.6 >> >> $ codesign -d -vv /usr/local/lib/libomp.dylib >> >> Executable=/usr/local/lib/libomp.dylib >> >> Identifier=libomp >> >> Format=Mach-O universal (x86_64 arm64) >> >> CodeDirectory v=20400 size=6506 flags=0x0(none) hashes=198+2 >> location=embedded >> >> Signature size=8977 >> >> Authority=Developer ID Application: Simon Urbanek (VZLD955F6P) >> >> Authority=Developer ID Certification Authority >> >> Authority=Apple Root CA >> >> Timestamp=Feb 5, 2023 at 4:26:54 PM >> >> Info.plist=not bound >> >> TeamIdentifier=VZLD955F6P >> >> Sealed Resources=none >> >> Internal requirements count=1 size=168 >> >> -- >> Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His >> Director, Wisconsin Chapter of the American Statistical Association >> Institute for Health and Equity, Division of Biostatistics >> Medical College of Wisconsin, Milwaukee Campus >> >> [[alternative HTML version deleted]] >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> R-SIG-Mac mailing list >> R-SIG-Mac@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-mac >> > > > -- > Best, > Kasper > > [[alternative HTML version deleted]] > > _______________________________________________ > R-SIG-Mac mailing list > R-SIG-Mac@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-mac > _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac