cmake: allow overriding hardcoded libomp path on macOS#65
Open
natsukium wants to merge 1 commit intoTimoLassmann:mainfrom
Open
cmake: allow overriding hardcoded libomp path on macOS#65natsukium wants to merge 1 commit intoTimoLassmann:mainfrom
natsukium wants to merge 1 commit intoTimoLassmann:mainfrom
Conversation
The OpenMP workaround hardcoded /opt/homebrew/opt/libomp, which locked out a custom build. Introduce LIBOMP_ROOT (defaulting to Homebrew) so the prefix can be overridden on the cmake command line. While here, restrict the block to AppleClang. The flags inside are AppleClang-specific (-Xpreprocessor -fopenmp, linking against the LLVM libomp runtime) and were previously forced on any compiler targeting Apple Silicon, silently breaking GCC and mis-configuring Homebrew LLVM Clang builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! I'm the maintainer of the kalign package in nixpkgs.
While updating the package to 3.5.1, I ran into a macOS build issue caused by a hardcoded libomp path in
CMakeLists.txt, and wanted to propose a fix upstream.Problem
On aarch64-darwin, the build fails outside of a Homebrew environment because the libomp path is hardcoded to
/opt/homebrew:In Nix (and other custom build setups),
libomplives outside/opt/homebrew, so the hardcoded path breaks the build on Apple Silicon. See NixOS/nixpkgs#492312 for the downstream report.Changes
LIBOMP_ROOTCMake cache variable that defaults to/opt/homebrew/opt/libomp, so Homebrew users keep the current behavior while other environments can override it (e.g.-DLIBOMP_ROOT=/nix/store/.../libomp).AppleClangonly. Other compilers (GCC, LLVM Clang) support OpenMP natively and should go through the normalfind_package(OpenMP)path instead of being forced through the Apple Clang workaround.