This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix linking libc++abi in standalone builds
ClosedPublic

Authored by tambre on Apr 2 2020, 4:04 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rGbcaa01752f5e: [libc++] Fix linking libc++abi in standalone builds
Summary

In standalone builds the cxxabi_shared and cxxabi_static targets don't exist.
We need to link against the library itself.

Diff Detail

Event Timeline

tambre created this revision.Apr 2 2020, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2020, 4:04 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
tambre edited the summary of this revision. (Show Details)Apr 2 2020, 4:05 AM
ldionne accepted this revision.Apr 2 2020, 6:28 AM

LGTM, but is there some documentation about how to build libc++ standalone? How do you build it? Do we have any bots that exercise this code path?

This revision is now accepted and ready to land.Apr 2 2020, 6:28 AM
This revision was automatically updated to reflect the committed changes.

LGTM, but is there some documentation about how to build libc++ standalone? How do you build it? Do we have any bots that exercise this code path?

I'd be happy to write some documentation for this. I do builds like this for assembling a toolchain at work using an internal tool. Main reason being that I don't want to crosscompile LLVM for my target platform (ARM64), just the libraries (compiler-rt, libunwind, libcxxabi, libcxx).
I'm skeptical that there would be bots for this, as building LLVM with subprojects seems to be the most common setup. But I'm new so I don't know much.

I am getting quite a few emails about failed bot runs. But I see you've already fixed my oversight. Thanks!

ldionne added a comment.EditedApr 2 2020, 12:39 PM

LGTM, but is there some documentation about how to build libc++ standalone? How do you build it? Do we have any bots that exercise this code path?

I'd be happy to write some documentation for this. I do builds like this for assembling a toolchain at work using an internal tool. Main reason being that I don't want to crosscompile LLVM for my target platform (ARM64), just the libraries (compiler-rt, libunwind, libcxxabi, libcxx).
I'm skeptical that there would be bots for this, as building LLVM with subprojects seems to be the most common setup. But I'm new so I don't know much.

Can you please share what exact CMake configuration you're using?

I am getting quite a few emails about failed bot runs. But I see you've already fixed my oversight. Thanks!

Yes, I think the issues are fixed now. No worries!

tambre added a comment.Apr 3 2020, 2:11 AM

LGTM, but is there some documentation about how to build libc++ standalone? How do you build it? Do we have any bots that exercise this code path?

I'd be happy to write some documentation for this. I do builds like this for assembling a toolchain at work using an internal tool. Main reason being that I don't want to crosscompile LLVM for my target platform (ARM64), just the libraries (compiler-rt, libunwind, libcxxabi, libcxx).
I'm skeptical that there would be bots for this, as building LLVM with subprojects seems to be the most common setup. But I'm new so I don't know much.

Can you please share what exact CMake configuration you're using?

Sure! Here's the whole process with the relevant parts:

  1. Host compiler
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_ENABLE_PLUGINS=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_RUNTIMES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_UTILS=OFF -GNinja -S/opt/tools/drive/llvm/llvm -DLLVM_TARGETS_TO_BUILD=AArch64;X86 -DLLVM_ENABLE_PROJECTS=clang;compiler-rt;lld -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCLANG_DEFAULT_LINKER=lld -DCLANG_ENABLE_ARCMT=OFF -DCLANG_PLUGIN_SUPPORT=OFF -DLLVM_TOOL_BUGPOINT_BUILD=OFF -DCMAKE_INSTALL_PREFIX=/opt/tools/drive/host
  1. compiler-rt
cmake -DCMAKE_ASM_COMPILER_TARGET=aarch64-linux-gnu -DLLVM_CONFIG_PATH=/opt/tools/drive/host/bin/llvm-config -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCOMPILER_RT_INCLUDE_TESTS=OFF -DSANITIZER_CXX_ABI=libc++ -DSANITIZER_USE_STATIC_CXX_ABI=ON -DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=/opt/tools/drive/host/bin/clang -DCMAKE_CXX_COMPILER=/opt/tools/drive/host/bin/clang++ -DCMAKE_AR=/opt/tools/drive/host/bin/llvm-ar -DCMAKE_RANLIB=/opt/tools/drive/host/bin/llvm-ranlib -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -GNinja -S/opt/tools/drive/llvm/compiler-rt -DCMAKE_INSTALL_PREFIX=/opt/tools/drive/sysroot/opt/drive/sysroot/lib/clang/11.0.0
  1. libunwind
cmake -DCMAKE_ASM_COMPILER_TARGET=aarch64-linux-gnu -DLIBUNWIND_ENABLE_PIC=ON -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBUNWIND_USE_COMPILER_RT=ON -DLLVM_ENABLE_LIBCXX=ON -DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=/opt/tools/drive/host/bin/clang -DCMAKE_CXX_COMPILER=/opt/tools/drive/host/bin/clang++ -DCMAKE_AR=/opt/tools/drive/host/bin/llvm-ar -DCMAKE_RANLIB=/opt/tools/drive/host/bin/llvm-ranlib -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DLLVM_PATH=/opt/tools/drive/llvm/llvm -GNinja -S/opt/tools/drive/llvm/libunwind -DCMAKE_INSTALL_PREFIX=/opt/tools/drive/libunwind
  1. libc++abi
cmake -DLIBCXXABI_ENABLE_SHARED=OFF -DLIBCXXABI_USE_COMPILER_RT=ON -DLIBCXXABI_INCLUDE_TESTS=OFF -DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF -DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON -DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=/opt/tools/drive/host/bin/clang -DCMAKE_CXX_COMPILER=/opt/tools/drive/host/bin/clang++ -DCMAKE_AR=/opt/tools/drive/host/bin/llvm-ar -DCMAKE_RANLIB=/opt/tools/drive/host/bin/llvm-ranlib -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DLLVM_PATH=/opt/tools/drive/llvm/llvm -DLIBCXXABI_UNWIND_LIBRARY_PATH=/opt/tools/drive/libunwind/lib -GNinja -S/opt/tools/drive/llvm/libcxxabi -DCMAKE_INSTALL_PREFIX=/opt/tools/drive/libcxxabi
  1. libc++, packaging for the target machine
cmake -DLIBCXX_ABI_UNSTABLE=ON -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON -DLIBCXX_INCLUDE_BENCHMARKS=OFF -DLIBCXX_USE_COMPILER_RT=ON -DCMAKE_C_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_CXX_COMPILER_TARGET=aarch64-linux-gnu -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=/opt/tools/drive/host/bin/clang -DCMAKE_CXX_COMPILER=/opt/tools/drive/host/bin/clang++ -DCMAKE_AR=/opt/tools/drive/host/bin/llvm-ar -DCMAKE_RANLIB=/opt/tools/drive/host/bin/llvm-ranlib -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=/opt/tools/drive/sysroot/opt/drive/sysroot/include -DLLVM_PATH=/opt/tools/drive/llvm/llvm -DLIBCXX_CXX_ABI_INCLUDE_PATHS=/opt/tools/drive/llvm/libcxxabi/include -DLIBCXX_CXX_ABI_LIBRARY_PATH=/opt/tools/drive/libcxxabi/lib -GNinja -S/opt/tools/drive/llvm/libcxx -DCMAKE_INSTALL_PREFIX=/opt/tools/drive/sysroot/opt/drive/sysroot
  1. IR PGO compiler, profile
  2. CSIR PGO compiler, profile
  3. Final compiler.