Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson fails to configure OpenMP when using Clang from MacPorts #13145

Open
lpsinger opened this issue Apr 25, 2024 · 3 comments
Open

Meson fails to configure OpenMP when using Clang from MacPorts #13145

lpsinger opened this issue Apr 25, 2024 · 3 comments

Comments

@lpsinger
Copy link

Describe the bug
Meson fails to detect OpenMP with Clang from MacPorts.

To Reproduce

  1. Install MacPorts.

  2. Install the MacPorts version of Clang by running sudo port install clang-18.

  3. Place the following in the file meson.build:

    project('example', 'c')
    dependency('openmp')
  4. Configure the project, and observe the failure:

    $ CC=clang-mp-18 meson setup build
    The Meson build system
    Version: 1.4.0
    Source dir: /private/tmp
    Build dir: /private/tmp/build
    Build type: native build
    Project name: example
    Project version: undefined
    C compiler for the host machine: clang-mp-18 (clang 18.1.4 "clang version 18.1.4")
    C linker for the host machine: clang-mp-18 ld64 1053.12
    Host machine cpu family: x86_64
    Host machine cpu: x86_64
    WARNING: OpenMP found but omp.h missing.
    Run-time dependency OpenMP found: NO (tried system)
    
    meson.build:2:0: ERROR: Dependency "openmp" not found, tried system
    
    A full log can be found at /private/tmp/build/meson-logs/meson-log.txt
    

Here is the log file: meson-log.txt

The check that is failing is a test compilation of the following testfile.c, compiled with the command clang-mp-18 testfile.c -E -P -P -O0 -Werror=implicit-function-declaration, i.e., without the command line option -fopenmp:

#ifdef __has_include
  #if !__has_include("omp.h")
    #error "Header 'omp.h' could not be found"
  #endif
#else
  #include <omp.h>
#endif

This test would have succeeded if Meson had added the flag -fopenmp; in some compilers such as this one, omp.h is not findable unless the command-line flag -fopenmp is present.

Expected behavior
Meson should add the -fopenmp flag when doing this test, and the test should succeed.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native build
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) macOS Sonoma
  • what Python version are you using 3.11.9
  • what meson --version 1.4.0
  • what ninja --version if it's a Ninja build 1.11.1.git.kitware.jobserver-1
@dcbaker
Copy link
Member

dcbaker commented Apr 25, 2024

If the compiler is identifying itself as an Apple compiler (ie, if Apple is in the output of clang --version), then Meson considers OpenMP unsupported. See: #7435 for more information.

@lpsinger
Copy link
Author

Indeed, it does:

$ clang-mp-18 --version
clang version 18.1.4
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-18/bin

@dcbaker
Copy link
Member

dcbaker commented Apr 26, 2024

That looks like we're incorrectly identifying a "vanilla" clang as an "apple" clang. The latter of which really means "the Clang Apple ships with XCode", so we should fix our detection code to detect that as a vanilla clang and then OpenMP should just work.

edit: Strangly though we look for "Apple" (Case sensitive) in the output, and the output you have is reporting "apple", so OpenMP should just work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants