Dear developers and CRAN people, I get some linker warnings on the macOS build server, ld: warning: direct access in function '?' from file '?' to global weak symbol '?' from file '?' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. Writing R Extensions (Section 6.16) says that visibility attributes are not supported on macOS nor Windows. If I add $(CXX_VISIBILITY) to PKG_CXXFLAGS, the warnings are still there, and I can see from the compiler log that the flags do not have any effect on macOS. However, if I add -fvisibility=hidden to PKG_CXXFLAGS, the warnings disappear (but I get a reminder from R CMD check that -fvisibility=hidden is not portable). I am wondering if $(CXX_VISIBILITY) could be supported on macOS. Best wishes, Matthias This is the build log of the package: https://www.r-project.org/nosvn/R.check/r-release-macos-arm64/rswipl-00install.html
[R-pkg-devel] CXX_VISIBILITY on macOS
3 messages · Matthias Gondan, Simon Urbanek
Matthias, this has nothing to do with R, but rather your code. You have the wrong order of headers: the SWI headers mess up visibility macros, so you have to include them *after* Rcpp.h. Cheers, Simon
On 9/10/2023, at 8:41 AM, Matthias Gondan <matthias-gondan at gmx.de> wrote: Dear developers and CRAN people, I get some linker warnings on the macOS build server, ld: warning: direct access in function '?' from file '?' to global weak symbol '?' from file '?' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. Writing R Extensions (Section 6.16) says that visibility attributes are not supported on macOS nor Windows. If I add $(CXX_VISIBILITY) to PKG_CXXFLAGS, the warnings are still there, and I can see from the compiler log that the flags do not have any effect on macOS. However, if I add -fvisibility=hidden to PKG_CXXFLAGS, the warnings disappear (but I get a reminder from R CMD check that -fvisibility=hidden is not portable). I am wondering if $(CXX_VISIBILITY) could be supported on macOS. Best wishes, Matthias This is the build log of the package: https://www.r-project.org/nosvn/R.check/r-release-macos-arm64/rswipl-00install.html [[alternative HTML version deleted]]
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
You found the problem, thanks! Matthias, this has nothing to do with R, but rather your code. You have the wrong order of headers: the SWI headers mess up visibility macros, so you have to include them *after* Rcpp.h. Cheers, Simon