branch: development
commit fa18359d6011eb986951915ffcd37b4289281b53
Author: Dima Pasechnik <[email protected]>
AuthorDate: Thu Feb 26 14:19:52 2026 -0600
ltmain.in: Support OpenMP with macOS clang
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 | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index df85f00b..67175443 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -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"