Skip to content

Commit 78550be

Browse files
authored
[CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (#76849)
This contains compiler-rt builtins and llvm-libc for baremetal use. Differential Revision: https://reviews.llvm.org/D155337
1 parent 5034994 commit 78550be

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "")
66

77
set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
88

9-
set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
9+
set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;libc;lld;llvm;polly")
1010
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
1111

1212
set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -22,8 +22,11 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
2222
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
2323
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
2424
set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
25+
set(LLVM_FORCE_BUILD_RUNTIME ON CACHE BOOL "")
2526
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
2627
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
28+
set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
29+
set(LIBC_HDRGEN_ONLY ON CACHE BOOL "")
2730
set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
2831
set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
2932
set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
@@ -297,6 +300,39 @@ if(FUCHSIA_SDK)
297300
set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "")
298301
endif()
299302

303+
foreach(target riscv32-unknown-elf)
304+
list(APPEND BUILTIN_TARGETS "${target}")
305+
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
306+
set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
307+
set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
308+
set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
309+
foreach(lang C;CXX;ASM)
310+
set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -march=rv32imafc -mabi=ilp32f" CACHE STRING "")
311+
endforeach()
312+
foreach(type SHARED;MODULE;EXE)
313+
set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
314+
endforeach()
315+
set(BUILTINS_${target}_COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
316+
317+
list(APPEND RUNTIME_TARGETS "${target}")
318+
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "")
319+
set(RUNTIMES_${target}_CMAKE_SYSTEM_PROCESSOR RISCV CACHE STRING "")
320+
set(RUNTIMES_${target}_CMAKE_SYSROOT "" CACHE STRING "")
321+
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
322+
set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
323+
foreach(lang C;CXX;ASM)
324+
set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -march=rv32imafc -mabi=ilp32f" CACHE STRING "")
325+
endforeach()
326+
foreach(type SHARED;MODULE;EXE)
327+
set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
328+
endforeach()
329+
set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
330+
set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
331+
set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
332+
set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
333+
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc" CACHE STRING "")
334+
endforeach()
335+
300336
set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
301337
set(LLVM_RUNTIME_TARGETS "${RUNTIME_TARGETS}" CACHE STRING "")
302338

0 commit comments

Comments
 (0)