Hello,
GNU libtool does not support compiling for and linking with llvm's OpenMP 
library using Apple's
clang compiler, as it requires prefixing the -fopenmp option with
-Xpreprocessor non-standard option.

We have a simple fix for this - which requires patching ltmain.sh, as
shown below (this is against a bit dated libtool version, GNU libtool
2.4.7; for the current stable version, it would be basically the same).
(cf. https://github.com/sagemath/sage/pull/41626)

Would this be acceptable addition to libtool?
Best,
Dima

diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
index 2a50d7f..8c6a8d8 100644
--- a/build-aux/ltmain.sh
+++ b/build-aux/ltmain.sh
@@ -6864,6 +6864,16 @@ func_mode_link ()
     # See if our shared archives depend on static archives.
     test -n "$old_archive_from_new_cmds" && build_old_libs=yes

+    # make sure "-Xpreprocessor -fopenmp" is processed as one token
+    case "$@" in
+    *-Xpreprocessor\ -fopenmp*)
+      fopenmp_match="-Xpreprocessor -fopenmp"
+      ;;
+    *)
+      fopenmp_match="-fopenmp"
+      ;;
+    esac
+
     # Go through the arguments, transforming them on the way.
     while test "$#" -gt 0; do
       arg=$1
@@ -7347,7 +7357,7 @@ func_mode_link ()
        continue
        ;;
       -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
-      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+      |-threads|$fopenmp_match|fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
        func_append compiler_flags " $arg"
        func_append compile_command " $arg"
        func_append finalize_command " $arg"
@@ -7891,7 +7901,7 @@ func_mode_link ()
        found=false
        case $deplib in
        -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
-        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+        |-threads|$fopenmp_match|fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
          if test prog,link = "$linkmode,$pass"; then
            compile_deplibs="$deplib $compile_deplibs"
            finalize_deplibs="$deplib $finalize_deplibs"

Attachment: signature.asc
Description: PGP signature

Reply via email to