2021-09-07 11:21:36 +03:00
|
|
|
set(CMAKE_SYSTEM_NAME SerenityOS)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
|
|
|
|
|
|
|
|
set(triple @SERENITY_ARCH@-pc-serenity)
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 13:11:12 +03:00
|
|
|
set(TOOLCHAIN_ROOT @SERENITY_SOURCE_DIR@/Toolchain/Local/clang/)
|
2021-09-07 11:21:36 +03:00
|
|
|
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
|
|
|
|
|
|
|
# where to read from/write to
|
|
|
|
set(CMAKE_SYSROOT @SERENITY_BUILD_DIR@/Root)
|
|
|
|
set(CMAKE_STAGING_PREFIX @SERENITY_BUILD_DIR@/Root/usr/local)
|
2021-10-18 17:08:37 +03:00
|
|
|
set(CMAKE_INSTALL_PREFIX /usr/local)
|
|
|
|
set(CMAKE_INSTALL_DATAROOTDIR share)
|
2021-09-07 11:21:36 +03:00
|
|
|
|
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/clang)
|
|
|
|
set(CMAKE_C_COMPILER_TARGET ${triple})
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/clang++)
|
|
|
|
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
|
|
|
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PATH}/clang)
|
|
|
|
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
|
|
|
set(CMAKE_LINKER ${TOOLCHAIN_PATH}/ld.lld)
|
2022-02-19 22:51:19 +03:00
|
|
|
set(CMAKE_AR ${TOOLCHAIN_PATH}/llvm-ar)
|
|
|
|
set(CMAKE_NM ${TOOLCHAIN_PATH}/llvm-nm)
|
|
|
|
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/llvm-objcopy)
|
2021-09-07 11:21:36 +03:00
|
|
|
set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/llvm-ranlib)
|
|
|
|
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
|
2021-09-01 05:38:34 +03:00
|
|
|
set(SERENITY_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
|
2021-09-07 11:21:36 +03:00
|
|
|
|
|
|
|
# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
|
|
|
|
# in a separate build stage before the main build to ensure that LibC is available
|
|
|
|
# for the try_compile check for the main build.
|
2021-11-01 13:42:30 +03:00
|
|
|
# Note that `set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)` is not a suitable replacement,
|
|
|
|
# since applications might try and use `try_compile()` to detect which library a symbol is in,
|
|
|
|
# which doesn't work when using static linking.
|
|
|
|
# Instead, just tell CMake directly that the compiler works fine, so that it doesn't have to run
|
|
|
|
# a compile check before the build.
|
|
|
|
set(CMAKE_C_COMPILER_WORKS TRUE)
|
|
|
|
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
2021-09-07 11:21:36 +03:00
|
|
|
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
2023-08-17 12:32:32 +03:00
|
|
|
|
|
|
|
# Sets a common default architecture for all toolchains. Be sure to update this in GNUToolchain as well!
|
|
|
|
if("${SERENITY_ARCH}" STREQUAL "riscv64")
|
|
|
|
add_compile_options(-march=rv64gc)
|
|
|
|
endif()
|