Skip to content

tests: let CMake pick the OpenMP flag and runtime - #177

Merged
georgmartius merged 1 commit into
masterfrom
fix/tests-openmp-toolchain
Aug 7, 2026
Merged

tests: let CMake pick the OpenMP flag and runtime#177
georgmartius merged 1 commit into
masterfrom
fix/tests-openmp-toolchain

Conversation

@georgmartius

Copy link
Copy Markdown
Owner

The test project still hardcoded -fopenmp on the compile line and linked gomp explicitly — the arrangement the library moved away from when #65 was fixed, but which was never applied to tests/.

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 fails to link:

undefined reference to `__kmpc_fork_call'
undefined reference to `__kmpc_for_static_fini'

gcc happened to agree with itself, which is why this went unnoticed.

Now uses find_package(OpenMP) and links OpenMP::OpenMP_C for both tests and bench, so each toolchain gets its own flag and its own runtime.

Verified:

build OpenMP found runtime linked suite
gcc -fopenmp (4.5) libgomp.so.1 36/36
clang -fopenmp=libomp (5.1) libomp.so.5 36/36
clang, USE_OMP=OFF n/a none builds

The clang 36/36 includes --testOMP, which previously could not be built at all.

🤖 Generated with Claude Code

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.
@georgmartius
georgmartius merged commit c4298ef into master Aug 7, 2026
4 checks passed
@georgmartius
georgmartius deleted the fix/tests-openmp-toolchain branch August 7, 2026 05:50
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

Successfully merging this pull request may close these issues.

1 participant