tests: let CMake pick the OpenMP flag and runtime - #177
Merged
Conversation
The test project still hardcoded -fopenmp on the compile line and linked gomp explicitly, the arrangement the library moved away from. Under clang the two disagree: -fopenmp compiles against libomp and emits __kmpc_* calls, while the link line forces GCC's libgomp, so the test binary failed to link with undefined references to __kmpc_fork_call and __kmpc_for_static_fini. gcc happened to agree with itself, which is why this went unnoticed. Use find_package(OpenMP) and link OpenMP::OpenMP_C for both "tests" and "bench", so each toolchain gets its own flag and its own runtime. Verified: the suite builds and passes 36/36 with gcc and with clang, each linking its own runtime (libgomp.so.1 / libomp.so.5), and USE_OMP=OFF still 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.
The test project still hardcoded
-fopenmpon the compile line and linkedgompexplicitly — the arrangement the library moved away from when #65 was fixed, but which was never applied totests/.Under clang the two disagree:
-fopenmpcompiles against libomp and emits__kmpc_*calls, while the link line forces GCC's libgomp, so the test binary fails to link:gcc happened to agree with itself, which is why this went unnoticed.
Now uses
find_package(OpenMP)and linksOpenMP::OpenMP_Cfor bothtestsandbench, so each toolchain gets its own flag and its own runtime.Verified:
-fopenmp(4.5)libgomp.so.1-fopenmp=libomp(5.1)libomp.so.5USE_OMP=OFFThe clang 36/36 includes
--testOMP, which previously could not be built at all.🤖 Generated with Claude Code