branch: master
commit c9c59804175920990ae2dc9706fa23a2cd4717b0
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.
* NEWS: Update.
---
NEWS | 3 +++
build-aux/ltmain.in | 14 ++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index a3a2321c..091b99b6 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ NEWS - list of user-visible changes between releases of GNU
Libtool
- Recognise explicit shared library arguments when linking dependency
libraries to a shared library, like exists when linking a program.
+ - Support OpenMP with macOS clang by processing '-Xpreprocessor
+ -fopenmp' as one token.
+
** Bug fixes:
- Store cygpath file path conversions correctly for MSYS2 and MSVC.
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"