From 044d1b12bb0e3b33d873a972f7c461cb393f1498 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 22 Jan 2025 11:29:50 +0100 Subject: [PATCH] autotools.py: set lt_cv_apple_cc_single_mod=yes (#48671) Since macOS 15 `ld -single_module` warns with a deprecation message, which makes configure scripts believe the flag is unsupported. That in turn triggers a code path where `archive_cmds` is set to ``` $CC -r -keep_private_externs -nostdlib ... -dynamiclib ``` instead of just ``` $CC -dynamiclib ... ``` This code path was meant to trigger only on ancient macOS <= 14.4 where libtool had to add `-single_module`, which is the default since macos 14.4, and is now apparently deprecated because the flag is a no-op for more than 15 years. The wrong `archive_cmds` causes actual problems combined with a bug in OpenMPI's compiler wrapper (`CC=mpicc`), which appends `-rpath` flags, which cause an error when combined with the `-r` flag added by the autotools. Spack's compiler wrapper doesn't do this, but it's likely there are other compiler wrappers out there that are not aware that `-r` and `-rpath` cannot be combined. The fix is to change defaults: `lt_cv_apple_cc_single_mod=yes`. --- lib/spack/spack/build_systems/autotools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index 47911271fef..2acd52b7404 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -357,6 +357,13 @@ def _do_patch_libtool_configure(self): ) # Support Libtool 2.4.2 and older: x.filter(regex=r'^(\s*test \$p = "-R")(; then\s*)$', repl=r'\1 || test x-l = x"$p"\2') + # Configure scripts generated with libtool < 2.5.4 have a faulty test for the + # -single_module linker flag. A deprecation warning makes it think the default is + # -multi_module, triggering it to use problematic linker flags (such as ld -r). The + # linker default is `-single_module` from (ancient) macOS 10.4, so override by setting + # `lt_cv_apple_cc_single_mod=yes`. See the fix in libtool commit + # 82f7f52123e4e7e50721049f7fa6f9b870e09c9d. + x.filter("lt_cv_apple_cc_single_mod=no", "lt_cv_apple_cc_single_mod=yes", string=True) @spack.builder.run_after("configure") def _do_patch_libtool(self):