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

BLD Avoid misleading OpenMP warning with Apple Clang #28839

Merged

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Apr 15, 2024

Close #28710.

For now Meson OpenMP detection can not be trusted on Apple Clang, so when compilers environment variables are set we assume everything is going to be fine and the warning can be less scary.

I tested it on a OSX VM, it seems to work fine. I will trigger a wheel build since the macOS wheels should show the milder warning.
Edit: it does build log

Run-time dependency OpenMP for c found: NO (tried system)
../sklearn/meson.build:107: WARNING: Looks like you set compiler environment variables to enable OpenMP support,
check the output of "import sklearn; sklearn.show_versions()" after the build
to make sure that scikit-learn was actually built with OpenMP support

Copy link

github-actions bot commented Apr 15, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 84f8cbd. Link to the linter CI: here

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to disable the misleading warning until it's fixed in meson.

sklearn/meson.build Show resolved Hide resolved
sklearn/meson.build Outdated Show resolved Hide resolved
sklearn/meson.build Outdated Show resolved Hide resolved
sklearn/meson.build Outdated Show resolved Hide resolved
Comment on lines 71 to 77
'''
import os

compiler_env_vars_to_check = ["CPPFLAGS", "CFLAGS", "CXXFLAGS"]

compiler_env_vars_with_openmp = [var for var in compiler_env_vars_to_check if "-fopenmp" in os.getenv(var, "")]
print(compiler_env_vars_with_openmp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put this in a variable to make the run_command invoke more readable ?

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

var for var in compiler_env_vars_to_check if "-fopenmp" in os.getenv(var, "")]
print(compiler_env_vars_with_openmp)
'''], check: true).stdout().strip()
warn_about_missing_openmp = compiler_env_vars_with_openmp == '[]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be more standard I guess if the process would return 1 on failure instead of checking program's output. But it doesn't really matter here I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not but at the same time, the process returning 1 could also be because there is a syntax error in the Python snippet, so you would need additional logic or a different exit code, which would complicate things a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although, you could return a non-1 value. But doesn't matter. Merged :)

@adrinjalali adrinjalali merged commit 55378cb into scikit-learn:main Apr 18, 2024
30 checks passed
@lesteve lesteve deleted the avoid-misleading-apple-clang-warning branch April 18, 2024 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading OpenMP warning on MacOS when building with Meson
3 participants