[PATCH] D31639: [CMake][libcxxabi] Use -nodefaultlibs for CMake checks

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 10:46:05 PST 2021


phosek added inline comments.


================
Comment at: libcxxabi/trunk/cmake/config-ix.cmake:26
+    find_compiler_rt_library(builtins LIBCXXABI_BUILTINS_LIBRARY)
+    list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXXABI_BUILTINS_LIBRARY}")
+  elseif (LIBCXXABI_HAS_GCC_S_LIB)
----------------
kaz7 wrote:
> 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!
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.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D31639/new/

https://reviews.llvm.org/D31639



More information about the llvm-commits mailing list