Since libc++abi is built with -nodefaultlibs, we should be using this option even for CMake checks to avoid any inconsistency and also to avoid dependency on a working C++ standard library just for the setting up the build itself because check_cxx_compile_flags adds the flag to COMPILE_DEFINITIONS when calling try_compile and this variable is only considered for compilation but not for linking where -nodefaultlibs actually makes a difference.. The implementation is largely similar to the one used by libc++.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi, I have a question about this patch. I appreciate any answers. Thanks!
libcxxabi/trunk/cmake/config-ix.cmake | ||
---|---|---|
26 ↗ | (On Diff #94563) | Hi! Is it possible to ask about this implementation? I'm trying to build libcxxabi.so and libclang_rt.builtins-ve.a for VE architecture. However, generated libcxxabi.so requires libclang_rt.builtins-ve.a for __multi3 function. Then, ld causes following errors, when I compile any c++ test programs using generated clang++, libc++.so, libcxxabi.so, and libclang_rt.builtins-ve.a. I think that this is an error trying to refer __multi3 function in libclang_rt.builtins-ve.a from libcxxabi.so. /opt/nec/ve/bin/nld: cmTC_f428b: hidden symbol `__veabi_multi3' in /home/jam/llvm-upstream/install/lib/clang/12.0.0/lib/linux/libclang_rt.builtins-ve.a(multi3.c.o) is referenced by DSO /opt/nec/ve/bin/nld: final link failed: Bad value In order to solve this problem, I can add following CMakefile code to link libcxxabi.so with libclang_rt.builtins-ve.a at build-time. It works fine for VE. But, I'm not sure whther this modification works for all other architectures or not. Or, I guess, there is better answer for this problem. list(APPEND CMAKE_REQUIRED_FLAGS -rtlib=compiler-rt) find_compiler_rt_library(builtins LIBCXXABI_BUILTINS_LIBRARY) list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXXABI_BUILTINS_LIBRARY}") + # CMAKE_REQUIRED_LIBRARIES is not used to link libc++abi.so, so + # append builtins to LIBCXXABI_SHARED_LIBRARIES too + list(APPEND LIBCXXABI_SHARED_LIBRARIES "${LIBCXXABI_BUILTINS_LIBRARY}") I appreciate if you have any suggestions for me here. Thanks! |
libcxxabi/trunk/cmake/config-ix.cmake | ||
---|---|---|
26 ↗ | (On Diff #94563) | I think this is because no other target requires builtins, looks like VE architecture is the first one that does. Rather than using the LIBCXXABI_SHARED_LIBRARIES global variable, we prefer to set dependencies directly for each target which is a more modern CMake approach. See how this is implemented in libcxx: https://github.com/llvm/llvm-project/blob/cfc60730179042a93cb9cb338982e71d20707a24/libcxx/CMakeLists.txt#L750. I'd prefer to use a similar implementation for libcxxabi. |
libcxxabi/trunk/cmake/config-ix.cmake | ||
---|---|---|
26 ↗ | (On Diff #94563) | Thank you for your answer. That makes sense. I appreciate if you have time to modify it in described way. Or, I can try to modify config-ix.cmake following your suggestions. Please let me know which way is good for you. Thanks! |
libcxxabi/trunk/cmake/config-ix.cmake | ||
---|---|---|
26 ↗ | (On Diff #94563) | I was working on CMakeLists, but I've understood modifying libcxxabi/CMakeLists.txt similar to libcxx/CMakeLists.txt is not easy... So, I'll submit a patch to modify only this config-ix.cmake. Thank you for your previous answer. |