llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.31k stars 11.69k forks source link

[OpenMP] support disable CMake thread search for cross compilation #95062

Open ppenzin opened 3 months ago

ppenzin commented 3 months ago

OpenMP has a check for Wasm to disable searching for threading library:

https://github.com/llvm/llvm-project/blob/48aebd4cf88b3632e8c3ed6b976287c973628e14/openmp/runtime/cmake/config-ix.cmake#L157-L158

This would be true for other cross-builds as well, where sysroot doesn't contain a threading library. I've ran into it while doing RISC-V cross-compilation for #87026. I think the check can be expanded into a CMake cache variable.

llvmbot commented 3 months ago

@llvm/issue-subscribers-openmp

Author: Petr Penzin (ppenzin)

OpenMP has a check for Wasm to disable searching for threading library: https://github.com/llvm/llvm-project/blob/48aebd4cf88b3632e8c3ed6b976287c973628e14/openmp/runtime/cmake/config-ix.cmake#L157-L158 This would be true for other cross-builds as well, where sysroot doesn't contain a threading library. I've ran into it while investigating RISC-V cross-compilation for #87026. I think the check can be expanded into a CMake cache variable.
shiltian commented 2 months ago

If the library doesn't exist, won't it cause link error if the source code is not guarded properly as what WASM did?

ppenzin commented 2 months ago

I don't think there are actual calls to pthread routines, it is simply checking that target environment has threads.

For RISC-V it is possible to make the build happy by pointing to Linux headers though.