https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/113267
This cache file demonstrates how to build a complete baremetal Clang/LLVM toolchain that can be used to build the Pico SDK. >From 781d226916e6bc477494f707085b9ccab72befb6 Mon Sep 17 00:00:00 2001 From: Petr Hosek <pho...@google.com> Date: Mon, 21 Oct 2024 23:24:11 -0700 Subject: [PATCH] CMake cache file for building Pico SDK toolchain This cache file demonstrates how to build a complete baremetal Clang/LLVM toolchain that can be used to build the Pico SDK. --- clang/cmake/caches/Pico.cmake | 89 +++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 clang/cmake/caches/Pico.cmake diff --git a/clang/cmake/caches/Pico.cmake b/clang/cmake/caches/Pico.cmake new file mode 100644 index 00000000000000..b0cc357b5b658d --- /dev/null +++ b/clang/cmake/caches/Pico.cmake @@ -0,0 +1,89 @@ +# This file sets up a CMakeCache for the Pico SDK toolchain build. + +set(CMAKE_BUILD_TYPE Release CACHE STRING "") + +set(LLVM_TARGETS_TO_BUILD ARM;RISCV CACHE STRING "") +set(LLVM_ENABLE_PROJECTS clang;lld;llvm CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES compiler-rt;libcxx;libc CACHE STRING "") + +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +set(CLANG_DEFAULT_LINKER lld CACHE STRING "") +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") + +set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") +set(LLVM_TOOLCHAIN_TOOLS + llvm-ar + llvm-cov + llvm-objcopy + llvm-objdump + llvm-profdata + llvm-ranlib + llvm-readelf + llvm-readobj + llvm-size + llvm-strings + llvm-strip + llvm-symbolizer + CACHE STRING "") +set(LLVM_DISTRIBUTION_COMPONENTS + builtins + clang + clang-resource-headers + lld + runtimes + ${LLVM_TOOLCHAIN_TOOLS} + CACHE STRING "") + +# TODO: Switch to newhdrgen for LLVM libc +set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") +set(LIBC_HDRGEN_ONLY ON CACHE BOOL "") + +set(LLVM_BUILTIN_TARGETS armv8m.main-none-eabi;riscv32-unknown-elf CACHE STRING "") +foreach(target ${LLVM_BUILTIN_TARGETS}) + set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "") + set(BUILTINS_${target}_CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "") + set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "") +endforeach() + +set(BUILTINS_armv8m.main-none-eabi_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "") +set(BUILTINS_riscv32-unknown-elf_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "") +foreach(lang C;CXX;ASM) + set(BUILTINS_armv8m.main-none-eabi_CMAKE_${lang}_FLAGS "-march=armv8m.main+fp+dsp -mcpu=cortex-m33 -mfloat-abi=softfp" CACHE STRING "") + set(BUILTINS_riscv32-unknown-elf_CMAKE_${lang}_FLAGS "-march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32" CACHE STRING "") +endforeach() + +set(LLVM_RUNTIME_TARGETS armv8m.main-none-eabi;riscv32-unknown-elf CACHE STRING "") +foreach(target ${LLVM_RUNTIME_TARGETS}) + set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES libc;libcxx CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") + # TODO: Switch to newhdrgen for LLVM libc + set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_LIBC llvm-libc CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_RTTI OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_THREADS OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") +endforeach() + +set(RUNTIMES_armv8m.main-none-eabi_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "") +set(RUNTIMES_riscv32-unknown-elf_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "") +foreach(lang C;CXX;ASM) + # TODO: Use timespec_get instead of gettimeofday in libc++ + # TODO: Use internal logging API instead of fprintf in libc++ + set(RUNTIMES_armv8m.main-none-eabi_CMAKE_${lang}_FLAGS "-march=armv8m.main+fp+dsp -mcpu=cortex-m33 -mfloat-abi=softfp -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dtimeval=struct timeval{int tv_sec; int tv_usec;}\" \"-Dgettimeofday(tv, tz)\" -D_LIBCPP_PRINT=1" CACHE STRING "") + set(RUNTIMES_riscv32-unknown-elf_CMAKE_${lang}_FLAGS "-march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32 -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dtimeval=struct timeval{int tv_sec; int tv_usec;}\" \"-Dgettimeofday(tv, tz)\" -D_LIBCPP_PRINT=1" CACHE STRING "") +endforeach() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits