[MacPorts] #72494: R ports on libstdc++-based systems: 4.5.0 update has an effect of reverting from new to old C++ ABI
MacPorts
noreply at macports.org
Fri May 16 08:16:03 UTC 2025
#72494: R ports on libstdc++-based systems: 4.5.0 update has an effect of reverting
from new to old C++ ABI
--------------------------+--------------------
Reporter: barracuda156 | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.10.7
Keywords: | Port: R
--------------------------+--------------------
I will just leave this here for the reference, nothing needed to do about
it now.
Until 4.5.0 `R` port did not set C++ standard in the port itself. It was
using modern gcc anyway, however C++ ABI was not set explicitly, and by
default gcc uses the new one. While MacPorts everywhere uses old C++ ABI
with libstdc++ (for compat reasons), R ecosystem is mostly isolated, very
few ports link to something external using C++, so this mismatch was never
a major issue. In a few instances where it caused linking failures,
`-D_GLIBCXX_USE_CXX11_ABI=0` was manually patched in.
4.5.0 update added `compiler.cxx_standard` into the portfile. This
requires to rebuild all C++ R ports, but since R was updated at the same
time, ports are anyway broken until revbumping is done. So this is not an
issue.
In principle, setting C++ standard is correct, at least from a point of
view of consistency. If everything goes smoothly and revbumping R ports is
done, it probably will "just work": newly-built `R` 4.5.0 gonna have
`-D_GLIBCXX_USE_CXX11_ABI=0` baked in cxxflags and used for all packages,
which must be rebuilt anyway, and then they pick the same ABI.
There are two caveats. Firstly, if someone has updated `R` to 4.5.0
earlier and built some ports with it, but then rebuilds R from the current
MacPorts port, this will eventually happen with some port down the road:
{{{
/opt/local/bin/g++-mp-14 -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 rmsb.so RcppExports.o
stanExports_lrmconppo.o stanExports_lrmconppot.o stanExports_lrmcppo.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.5/Resources/library/RcppParallel/lib/
-Wl,-rpath,/opt/local/Library/Frameworks/R.framework/Versions/4.5/Resources/library/RcppParallel/lib/
-ltbb -ltbbmalloc -F/opt/local/Library/Frameworks/R.framework/..
-framework R
installing to /opt/local/var/macports/build/_opt_local_ppcports_R_R-
rmsb/R-rmsb/work/build/00LOCK-rmsb/00new/rmsb/libs
** R
** inst
** 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
sh: line 1: 96296 Bus error R_TESTS=
'/opt/local/Library/Frameworks/R.framework/Resources/bin/R' --no-save
--no-restore --no-echo 2>&1 < '/opt/local/var/macports/build
/_opt_local_ppcports_R_R-
rmsb/R-rmsb/work/.tmp/RtmpzgQkGD/file1738545167cb9'
*** caught bus error ***
address 0x0, cause 'invalid alignment'
Traceback:
1: Module(module, mustStart = TRUE, where = env)
2: doTryCatch(return(expr), name, parentenv, handler)
3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
4: tryCatchList(expr, classes, parentenv, handlers)
5: tryCatch(Module(module, mustStart = TRUE, where = env), error =
function(e) e)
6: Rcpp::loadModule(module = "stan_fit4lrmconppo_mod", what = TRUE,
env = ns, loadNow = TRUE)
7: (function (ns) Rcpp::loadModule(module = "stan_fit4lrmconppo_mod",
what = TRUE, env = ns, loadNow = TRUE))(<environment>)
8: doTryCatch(return(expr), name, parentenv, handler)
9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
11: tryCatch((function (ns) Rcpp::loadModule(module =
"stan_fit4lrmconppo_mod", what = TRUE, env = ns, loadNow =
TRUE))(<environment>), error = function(e) e)
12: eval(substitute(tryCatch(FUN(WHERE), error = function(e) e),
list(FUN = f, WHERE = where)), where)
13: eval(substitute(tryCatch(FUN(WHERE), error = function(e) e),
list(FUN = f, WHERE = where)), where)
14: .doLoadActions(where, attach)
15: methods::cacheMetaData(ns, TRUE, ns)
16: loadNamespace(package, lib.loc)
17: doTryCatch(return(expr), name, parentenv, handler)
18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
19: tryCatchList(expr, classes, parentenv, handlers)
20: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <-
loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos,
deps, exclude, include.only)}, error = function(e) { P <- if
(!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L])
else "" msg <- gettextf("package or namespace load failed for %s%s:\n
%s", sQuote(package), P, conditionMessage(e)) if
(logical.return && !quietly) message(paste("Error:", msg), domain
= NA) else stop(msg, call. = FALSE, domain = NA)})
21: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return
= TRUE)
22: withCallingHandlers(expr, packageStartupMessage = function(c)
tryInvokeRestart("muffleMessage"))
23: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,
character.only = TRUE, logical.return = TRUE))
24: doTryCatch(return(expr), name, parentenv, handler)
25: tryCatchOne(expr, names, parentenv, handlers[[1L]])
26: tryCatchList(expr, classes, parentenv, handlers)
27: tryCatch(expr, error = function(e) { call <- conditionCall(e) if
(!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch)))
call <- sys.call(-4L) dcall <- deparse(call, nlines = 1L)
prefix <- paste("Error in", dcall, ": ") LONG <- 75L sm <-
strsplit(conditionMessage(e), "\n")[[1L]] w <- 14L + nchar(dcall,
type = "w") + nchar(sm[1L], type = "w") if (is.na(w)) w
<- 14L + nchar(dcall, type = "b") + nchar(sm[1L], type =
"b") if (w > LONG) prefix <- paste0(prefix, "\n ")
} else prefix <- "Error : " msg <- paste0(prefix,
conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if
(!silent && isTRUE(getOption("show.error.messages"))) { cat(msg,
file = outFile) .Internal(printDeferredWarnings()) }
invisible(structure(msg, class = "try-error", condition = e))})
28: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,
character.only = TRUE, logical.return = TRUE)))
29: tools:::.test_load_package("rmsb", "/opt/local/var/macports/build
/_opt_local_ppcports_R_R-rmsb/R-rmsb/work/build/00LOCK-rmsb/00new")
An irrecoverable exception occurred. R is aborting now ...
ERROR: loading failed
}}}
Oddly, the error is not suggestive of its cause, unlike in a case when
something is built with new ABI and linked against the old (here it is the
reverse). If you encounter something like that – probably the problem is
that you had a port built without `-D_GLIBCXX_USE_CXX11_ABI=0`, and then a
failing one tries to link with it, but uses `-D_GLIBCXX_USE_CXX11_ABI=0`.
(This situation should not happen, if you just go together with MacPorts
updates. Though there is another breakage now caused by R update.)
Another concern is that up to present moment pretty much nothing R-related
was tested with old C++ ABI (with a very few exceptions, where the flag
had to be patched in manually). So I have no idea how it gonna work. It
probably will, maybe even better, but it is unknown. Most of ports which
had test suites were tested with gcc when added, but they used new ABI.
For myself I decided to drop C++ standard enforcement (compiler choice is
correct regardless), since a) I rather use a set-up which I have tested,
and it is known to work pretty well, and b) I do not want to spend a few
days rebuilding all C++ ports.
P. S. If MacPorts uses the old ABI with libstdc++ (that is triggered by
setting C++ standard in `R` portfile), then existing patches that add
`-D_GLIBCXX_USE_CXX11_ABI=0` can be dropped. No point to hunt them down
specifically, just delete whenever/if a port is updated.
--
Ticket URL: <https://trac.macports.org/ticket/72494>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list