Hi,
I've spent the last several days trying to build a fast, full-featured
relocatable distribution of LLVM/Clang 9.0.1 on Linux RHEL7, which has an older
native GCC (4.8.5)—I can't require the RH toolset. I have access to a modern
version of GCC in order to make the stage-1 build, but I need the final product
not only to be relocatable, but also to be free of any dependence on that GCC
or its libraries. In other words, I want to be able to distribute an LLVM/CLang
which defaults to compiling using libc++, libcxxabi, compiler-rt, libunwind,
and ldd, and which itself depends neither on libstdc++ or libgcc_s. I'd also
like to be able to to provide LTO, but whether the compiler is itself the
beneficiary of LTO is optional. As a final wish, I'd like the distribution as
installed to serve as an SDK against which to build other components such as
separately packaged lldb and f18. Oh, and I want a pony.
Here's what I have so far (CMake cache files attached for stages 1 and 2).
Invoked in a separate build directory with:
env CC=gcc-9 CXX=g++-9 \
'CXXFLAGS=-Wno-cast-function-type -Wno-deprecated-copy -Wno-init-list-lifetime
-Wno-pessimizing-move -Wno-redundant-move -Wno-uninitialized
-Wno-unused-function -Wno-unused-variable' \
cmake -GNinja -C FNAL.cmake -DCMAKE_INSTALL_PREFIX=<install-path> \
-DBOOTSTRAP_LLVM_CXX_STD=c++17 <src-path>
ninja
ninja install
(The CXXFLAGS are just to keep the noise down during the stage-1 build).
I appear (finally) to have a mostly functioning build in situ, but the
installed compiler depends upon libstdc++ to be able to run, and I should have
put --rtlib=compiler-rt in LINKER_FLAGS rather than CXX_FLAGS. Additionally, I
haven't been able to come up with a good set of targets for
LLVM_DISTRIBUTION_COMPONENTS, but when I do I think I need to exclude static
libraries if I'm doing LTO, no?
I suspect I need a three stage build—well, two stage 2s, at least—but any
advice would be appreciated as I'm wandering around in the dark at this point.
Many thanks for any help,
Chris.
# A full-featured bootstrapped build of LLVM, Clang and friends for FNAL.
set(PACKAGE_VENDOR FNAL CACHE STRING "")
set(LLVM_ENABLE_PROJECTS
"clang;clang-tools-extra;libclc;lld;llgo;openmp;polly"
CACHE STRING "")
set(LLVM_ENABLE_RUNTIMES "all" CACHE STRING "")
set(LLVM_TARGETS_TO_BUILD "X86;ARM;AArch64;AMDGPU;NVPTX;BPF;PowerPC"
CACHE STRING "")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "--rtlib=compiler-rt -O3 -gline-tables-only
-DNDEBUG"
CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "--stdlib=libc++ --rtlib=compiler-rt -O3
-gline-tables-only -DNDEBUG"
CACHE STRING "")
# setup toolchain
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
set(LLVM_TOOLCHAIN_TOOLS
dsymutil
llvm-cov
llvm-cxxfilt
llvm-dwarfdump
llvm-profdata
llvm-objdump
llvm-nm
llvm-size
CACHE STRING "")
if (APPLE)
set(COMPILER_RT_ENABLE_IOS ON CACHE BOOL "Build iOS Compiler-RT libraries")
set(LLVM_CREATE_XCODE_TOOLCHAIN ON CACHE BOOL
"Generate targets to create and install an Xcode compatible toolchain")
set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "External debuginfo files")
endif()
set(CMAKE_C_FLAGS
"-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled"
CACHE STRING "")
set(CMAKE_CXX_FLAGS
"-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled"
CACHE STRING "")
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(LINK_POLLY_INTO_TOOLS ON CACHE BOOL "")
set(LLVM_BUILD_LLVM_DYLIB ON CACHE BOOL "")
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
set(LLVM_ENABLE_FFI ON CACHE BOOL "")
set(LLVM_ENABLE_LTO Full CACHE STRING "")
set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
set(LLVM_LINK_LLVM_DYLIB ON CACHE BOOL "")
set(WITH_POLLY ON CACHE BOOL "")
# This file sets up a CMakeCache for a simple distribution bootstrap build.
#Enable LLVM projects and runtimes
set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING
"")
# Optimize the stage1 compiler, but don't LTO it because that wastes time.
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
# Setup vendor-specific settings.
set(PACKAGE_VENDOR FNAL CACHE STRING "")
# Setting up the stage2 LTO option needs to be done on the stage1 build so that
# the proper LTO library dependencies can be connected.
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
if (APPLE)
set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
# Disabling embedded darwin compiler-rt on stage1 builds is required because
we
# don't build stage1 to support arm code generation.
set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "")
set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
else()
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
# Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()
set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
# Expose stage2 targets through the stage1 build configuration.
set(CLANG_BOOTSTRAP_TARGETS
check-all
check-llvm
check-clang
llvm-config
test-suite
test-depends
llvm-test-depends
clang-test-depends
clang
distribution
install-distribution
CACHE STRING "")
if (APPLE)
set(CLANG_BOOTSTRAP_TARGETS
${CLANG_BOOTSTRAP_TARGETS}
install-xcode-toolchain
install-distribution-toolchain
CACHE STRING "")
endif()
# Setup the bootstrap build.
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
if(STAGE2_CACHE_FILE)
set(CLANG_BOOTSTRAP_CMAKE_ARGS
-C ${STAGE2_CACHE_FILE}
CACHE STRING "")
else()
set(CLANG_BOOTSTRAP_CMAKE_ARGS
-C ${CMAKE_CURRENT_LIST_DIR}/FNAL-stage2.cmake
CACHE STRING "")
endif()
_______________________________________________
cfe-users mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users