On Wed, Mar 04, 2026 at 11:45:45AM +0100, Bruno Haible wrote:
> Dima Pasechnik wrote:
> > Apple lies to us here!
> > I have "Apple clang version 17.0.0 (clang-1700.6.3.2)" on the latest 
> > version of Intel macOS 
> > 
> >   % uname -a
> >   Darwin OUCL13243.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jan 19 
> > 22:00:10 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_X86_64 x86_64
> > 
> >   % cc -v
> >   Apple clang version 17.0.0 (clang-1700.6.3.2)
> >   Target: x86_64-apple-darwin24.6.0
> >   Thread model: posix
> >   InstalledDir: 
> > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
> > 
> > and "cc -help" reports that "-fopenmp" is an option,
> > 
> >    % cc --help | grep "fopenmp "
> >   -fopenmp                Parse OpenMP pragmas and generate parallel code.
> > 
> > 
> > yet it does not work:
> > 
> > % cat foo.c
> > #include <stdio.h>
> > 
> > % cc -c foo.c -fopenmp
> > clang: error: unsupported option '-fopenmp'
> 
> Similarly for me. My test program actually exercises OpenMP functionality:
> 
>   $ cat foo.c
>   #include <omp.h>
>   int main (void) { return omp_get_num_threads (); }
> 
> and I see that the option, while accepted, has no effect:
> 
>   $ cc -v
>   Apple clang version 17.0.0 (clang-1700.6.3.2)
>   Target: arm64-apple-darwin25.2.0
>   Thread model: posix
>   InstalledDir: /Library/Developer/CommandLineTools/usr/bin
> 
>   $ cc --help | grep "fopenmp "
>     -fopenmp                Parse OpenMP pragmas and generate parallel code.
> 
>   $ cc -fopenmp foo.c
>   clang: error: unsupported option '-fopenmp'
>   clang: error: unsupported option '-fopenmp'
> 
>   $ cc -Xpreprocessor -fopenmp foo.c
>   foo.c:1:10: fatal error: 'omp.h' file not found
>       1 | #include <omp.h>
>         |          ^~~~~~~
>   1 error generated.
> 
>   $ cc -Xclang -fopenmp foo.c
>   foo.c:1:10: fatal error: 'omp.h' file not found
>       1 | #include <omp.h>
>         |          ^~~~~~~
>   1 error generated.
> 
> > % cc -c foo.c -Xclang -fopenmp # this is OK
> > % cc -c foo.c -Xpreprocessor -fopenmp # OK too
> 
> And what if you take my foo.c? Do you get a link error? Do you have to add
> "-lomp" by hand?

I do have to add -I by hand, to begin with (this is with
Homebrew-installed libomp package, "brew install libomp" will give you
it), and it fails at the linking:

% cc foo.c -Xpreprocessor -fopenmp -I $(brew --prefix)/opt/libomp/include
Undefined symbols for architecture x86_64:
  "_omp_get_num_threads", referenced from:
      _main in foo-9fd8a2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So one needs -lomp with -L added, then it works.
% cc foo.c -Xpreprocessor -fopenmp -I$(brew --prefix)/opt/libomp/include 
-L$(brew --prefix)/opt/libomp/lib -lomp
% ./a.out
%

--------

I am working with codebase that instead of AC_OPENMP uses AX_OPENMP from
Autoconf archives (not sure why), and I patched it so that it works.
(with patched libtool).
https://github.com/sagemath/sage/pull/41626/changes#diff-7b626e958ad6b4d0ddf0c437c7736df4625749df80bd66b4591dfe501d936223
Then I understood that certainly AX_OPENMP isn't good enough, as it, after the 
patch,
started to leave various penmp/ litter after itself, whereas AC_OPENMP takes 
care or it.

Dima

> 
> Bruno
> 
> 
> 

Attachment: signature.asc
Description: PGP signature

              • ... Andrew W. Nosenko
              • ... Dima Pasechnik
      • Re... Andrew W. Nosenko
        • ... Ben Boeckel
          • ... Dima Pasechnik
  • Re: fixing ... Bruno Haible via Discussion list for the autoconf build system
    • Re: fi... Dima Pasechnik
      • Re... Bruno Haible via Discussion list for the autoconf build system
    • Re: fi... Dima Pasechnik
      • Re... Bruno Haible via Discussion list for the autoconf build system
        • ... Dima Pasechnik

Reply via email to