Failure linking against OpenMP on macOS
jvkersch opened this issue · comments
Joris Vankerschaver commented
When using the CMake build scripts on macOS, FindOpenMP
detects and enables OpenMP via the -Xclang -fopenmp
flags, but this fails at linking time:
/opt/homebrew/Cellar/cmake/3.21.2/bin/cmake -E cmake_link_script CMakeFiles/test_verify_traces.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Xclang -fopenmp CMakeFiles/test_verify_traces.dir/tests/test_verify_traces.c.o -o test_verify_traces libparasail.a /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libz.tbd
Undefined symbols for architecture arm64:
"___kmpc_critical", referenced from:
_.omp_outlined. in test_verify_traces.c.o
"___kmpc_end_critical", referenced from:
_.omp_outlined. in test_verify_traces.c.o
"___kmpc_for_static_fini", referenced from:
_.omp_outlined. in test_verify_traces.c.o
"___kmpc_for_static_init_8", referenced from:
_.omp_outlined. in test_verify_traces.c.o
"___kmpc_fork_call", referenced from:
_check_functions in test_verify_traces.c.o
ld: symbol(s) not found for architecture arm64
Apparently, Apple's clang has compiler support for OpenMP, but does not ship with the required libraries to actually provide the functionality (that's at least what I got from https://mac.r-project.org/openmp/).
Given that OpenMP support isn't strictly necessary for Parasail as a library, would it be possible to provide a build time flag to explicitly turn off OpenMP support? Something along the lines of
OPTION( WITH_OPENMP "Enable OpenMP (if supported by the compiler)" ON )
IF(WITH_OPENMP)
INCLUDE( FindOpenMP )
ENDIF()
Compiler:
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
This is on an Apple M1, with macOS 11.5.2.