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
gollvm: -fPIC is not supported, if using ld or lld, with Clang++ #41527
Comments
CC @thanm @cherrymui |
For some reason it looks as though some of the cmake config checks that LLVM runs (this is outside of the gollvm cmake rules) are using -Werror (but only for C++ compiles, not for C compiles). So what's happening is that the cmake rules run "clang++ -c foo.cpp -fuse-ld=..." and clang warns because the linker option is not used ... and then the warning is turned into an error. I guess I would tack on "-Qunused-arguments" in this situation in addition to "-fuse-ld=xxx". Also, not sure what the intended effect of "-fuse-ld=ld" is. The argument of this option should be one of {bfd,gold,ldd}. |
@lattner , @topperc, @RKSimon, @arsenm, @echristo , @tobiasgrosser , @EricWF , @ppc : could you clarify an actual summary, for specific linkers, without CMake's auto-detection? |
It seems possible to invoke the C compiler in a way that `-fuse-linker` is considered unused, and this is often the way that flags are probed. This was keeping the LLVM `-fPIC` check from working properly. The go folks reported a similar issue: golang/go#41527
It seems possible to invoke the C compiler in a way that `-fuse-linker` is considered unused, and this is often the way that flags are probed. This was keeping the LLVM `-fPIC` check from working properly. The go folks reported a similar issue: golang/go#41527
Discovered an issue working in StableHLO when attempting to build with `-Wall -Werror`: openxla/stablehlo#137 Currently, if `LLVM_USE_LLD` and `-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"` are both specified for build, the build will error with: ``` -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Failed CMake Error at /usr/local/google/home/gleasonk/Coding/llvm-build/lib/cmake/llvm/HandleLLVMOptions.cmake:309 (message): Host compiler does not support '-fuse-ld=lld' ... $ cat <build_dir>/CMakeFiles/CMakeError.log ... clang: error: argument unused during compilation: '-fuse-ld=lld' [-Werror,-Wunused-command-line-argument] ``` It looks like other repos have hit this same issue: - golang/go#41527 (mentioned in comment) - iree-org/iree#7450 This can be reproduced in llvm-project with the following build command: ``` # Compile command taken from https://mlir.llvm.org/getting_started/ # and modified for use case cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_BUILD_EXAMPLES=ON \ -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang \ -DLLVM_ENABLE_LLD=ON \ -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror" ``` Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D134206
Can this be closed? |
I was figuring out linker's options.
So if I am properly dealing with CMake's flags
should be what I tried.
And lld is invoked via
If I do like this:
There is no clear/current summary on -fPIC flag support, in some practical manner. I am proposing that it should be documented.
Ivan
The text was updated successfully, but these errors were encountered: