]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
ltmain.in: Support OpenMP with macOS clang
authorDima Pasechnik <dima@pasechnik.info>
Thu, 26 Feb 2026 20:19:52 +0000 (14:19 -0600)
committerIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Sat, 28 Feb 2026 18:13:22 +0000 (20:13 +0200)
llvm's OpenMP library using the macOS clang compiler requires prefixing the
'-fopenmp' option with '-Xpreprocessor' non-standard option.

Reported: https://lists.gnu.org/archive/html/libtool/2026-02/msg00002.html

* build-aux/ltmain.in: Process '-Xpreprocessor -fopenmp' as one token.

build-aux/ltmain.in

index df85f00b0fcc6f668c28ff43a33eccc8c9c7521c..67175443b5999cf9c44fbaf3a5d9dc50f752d2a6 100644 (file)
@@ -4944,6 +4944,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
@@ -5433,7 +5443,7 @@ func_mode_link ()
        continue
        ;;
       -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
-      |-threads|-fopenmp|-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"
@@ -6024,7 +6034,7 @@ func_mode_link ()
        continue
        ;;
        -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
-        |-threads|-fopenmp|-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"