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

OpenMP linking errors on Windows using Ninja and clang #1129

Open
KrisThielemans opened this issue Jan 9, 2023 · 4 comments
Open

OpenMP linking errors on Windows using Ninja and clang #1129

KrisThielemans opened this issue Jan 9, 2023 · 4 comments

Comments

@KrisThielemans
Copy link
Collaborator

#1127 attempts to use Ninja on Appveyor (among trying to use sccache). It fails due to (unrelated) linking errors with OpenMP. Apparently the linker doesn't get passed the correct flag. This is likely caused by switching to Ninja, which I had to do as the VS Generator ignores the *COMPILER_LAUNCHER (I guess I could try nmake). But this is using the clang compiler as opposed to cl. so lots of things change.

errors like

lld-link: error: undefined symbol: __kmpc_dispatch_init_8
>>> referenced by iterative_KOSMAPOSL.lib(KOSMAPOSLReconstruction.cxx.obj):(.omp_outlined.)
>>> referenced by iterative_KOSMAPOSL.lib(KOSMAPOSLReconstruction.cxx.obj):(.omp_outlined..1)

and

lld-link: error: undefined symbol: omp_get_num_threads
>>> referenced by recon_buildblock.lib(PoissonLogLikelihoodWithLinearModelForMeanAndProjData.cxx.obj):(.omp_outlined.)
>>> referenced by recon_buildblock.lib(PoissonLogLikelihoodWithLinearModelForMeanAndProjData.cxx.obj):(.omp_outlined..1)

I don't think this is our problem, but CMake's FindOpenMP.

Originally posted by @KrisThielemans in #1127 (comment)

@KrisThielemans
Copy link
Collaborator Author

8eaa7dc removed any trace of sccache from the build, just to check.

https://ci.appveyor.com/project/KrisThielemans/stir/builds/45873849#L31028 shows that no openmp flag nor library is added for linking. Cutting some stuff it reads

C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -fuse-ld=lld-link -nostartfiles -nostdlib -Wno-undefined-var-template -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt   src/utilities/CMakeFiles/list_detector_and_bin_info.dir/list_detector_and_bin_info.cxx.obj <cut> 
 src/buildblock/buildblock.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames"

other bits from the log

cmake.exe .. -G Ninja -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% -DCMAKE_BUILD_TYPE=%CONFIGURATION%  -DCMAKE_CONFIGURATION_TYPES=%CONFIGURATION% -DSTIR_OPENMP=ON
[00:00:11] -- The C compiler identification is Clang 9.0.1 with GNU-like command-line
[00:00:12] -- The CXX compiler identification is Clang 9.0.1 with GNU-like command-line
...
[00:00:16] -- Found OpenMP_C: -fopenmp=libomp (found version "3.1") 
[00:00:16] -- Found OpenMP_CXX: -fopenmp=libomp (found version "3.1") 
[00:00:16] -- Found OpenMP: TRUE (found version "3.1") 
...
[00:00:21] cmake.exe --build . --config %CONFIGURATION%

Relevant CMake lines

set (OpenMP_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX)

target_link_libraries(buildblock ${OpenMP_EXE_LINKER_FLAGS})

target_link_libraries(recon_buildblock ${OpenMP_EXE_LINKER_FLAGS})

@KrisThielemans KrisThielemans changed the title OpenMP linkiing errors on Windows using Ninja and clang OpenMP linking errors on Windows using Ninja and clang Jan 9, 2023
@KrisThielemans
Copy link
Collaborator Author

Appveyor for VS 2015 is running with cmake version 3.16.2, that'll explain a lot as CLang support has improved in CMake. I guess best to try with VS 2019 or 2022 where it will use 3.24.2.

https://www.appveyor.com/docs/windows-images-software/

@KrisThielemans
Copy link
Collaborator Author

This still occurs with cmake version 3.24.2 and Clang 14.0.6 (on AppVeyor with the VS 2022 VM, so therefore Ninja 1.11.1). Build is https://ci.appveyor.com/project/KrisThielemans/stir/builds/45938757. Log file copied here.
log.txt

@KrisThielemans
Copy link
Collaborator Author

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

No branches or pull requests

1 participant