Skip to content

Commit 6b42b73

Browse files
committed
cmake: add some caches for Linux
This adds a set of cmake caches to build a toolchain and runtime for Linux x86_64. It is derived from the Windows configuration, but works for Linux.
1 parent 17f1cf9 commit 6b42b73

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed

cmake/caches/Linux-x86_64.cmake

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
set(LLVM_ENABLE_PROJECTS
2+
clang
3+
clang-tools-extra
4+
lld
5+
lldb
6+
CACHE STRING "")
7+
8+
set(LLVM_EXTERNAL_PROJECTS
9+
cmark
10+
swift
11+
CACHE STRING "")
12+
13+
set(LLVM_ENABLE_RUNTIMES
14+
compiler-rt
15+
CACHE STRING "")
16+
17+
# NOTE(compnerd) always enable assertions, the toolchain will not provide enough
18+
# context to resolve issues otherwise and may silently generate invalid output.
19+
set(LLVM_ENABLE_ASSERTIONS YES CACHE BOOL "")
20+
21+
set(ENABLE_X86_RELAX_RELOCATIONS YES CACHE BOOL "")
22+
23+
# NOTE(compnerd) we can hardcode the default target triple since the cache files
24+
# are target dependent.
25+
set(LLVM_DEFAULT_TARGET_TRIPLE x86_64-unknown-linux-gnu CACHE STRING "")
26+
27+
set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
28+
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
29+
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
30+
set(LLVM_BUILTIN_TARGETS
31+
x86_64-unknown-linux-gnu
32+
CACHE STRING "")
33+
foreach(target ${LLVM_RUNTIME_TARGETS})
34+
set(BUILTINS_${target}_LLVM_ENABLE_RUNTIMES
35+
compiler-rt
36+
CACHE STRING "")
37+
set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
38+
set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
39+
set(BUILTINS_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
40+
set(BUILTINS_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
41+
set(BUILTINS_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
42+
set(BUILTINS_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
43+
set(BUILTINS_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
44+
set(BUILTINS_${target}_COMPILER_RT_DEFAULT_TARGET_ONLY YES CACHE BOOL "")
45+
set(BUILTINS_${target}_COMPILER_RT_INCLUDE_TESTS NO CACHE BOOL "")
46+
endforeach()
47+
48+
set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
49+
50+
# Disable certain targets to reduce the configure time or to avoid configuration
51+
# differences (and in some cases weird build errors on a complete build).
52+
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
53+
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
54+
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
55+
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
56+
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
57+
set(LLVM_ENABLE_TERMINFO NO CACHE BOOL "")
58+
set(LLVM_ENABLE_Z3_SOLVER NO CACHE BOOL "")
59+
set(LLVM_ENABLE_ZLIB NO CACHE BOOL "")
60+
set(LLVM_INCLUDE_BENCHMARKS NO CACHE BOOL "")
61+
set(LLVM_INCLUDE_DOCS NO CACHE BOOL "")
62+
set(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "")
63+
set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
64+
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
65+
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
66+
67+
# Avoid swig dependency for lldb
68+
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
69+
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
70+
71+
# This requires perl which may not be available on Windows
72+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
73+
set(SWIFT_BUILD_ENABLE_PARSER_LIB YES CACHE BOOL "")
74+
# static linking is not supported on Windows yet
75+
set(SWIFT_BUILD_STATIC_STDLIB NO CACHE BOOL "")
76+
set(SWIFT_BUILD_STATIC_SDK_OVERLAY NO CACHE BOOL "")
77+
78+
set(LLVM_INSTALL_BINUTILS_SYMLINKS YES CACHE BOOL "")
79+
set(LLVM_INSTALL_TOOLCHAIN_ONLY YES CACHE BOOL "")
80+
set(LLVM_TOOLCHAIN_TOOLS
81+
addr2line
82+
ar
83+
c++filt
84+
dsymutil
85+
dwp
86+
# lipo
87+
llvm-ar
88+
llvm-cov
89+
llvm-cvtres
90+
llvm-cxxfilt
91+
llvm-dlltool
92+
llvm-dwarfdump
93+
llvm-dwp
94+
llvm-lib
95+
llvm-lipo
96+
llvm-mt
97+
llvm-nm
98+
llvm-objcopy
99+
llvm-objdump
100+
llvm-pdbutil
101+
llvm-profdata
102+
llvm-ranlib
103+
llvm-rc
104+
llvm-readelf
105+
llvm-readobj
106+
llvm-size
107+
llvm-strings
108+
llvm-strip
109+
llvm-symbolizer
110+
llvm-undname
111+
nm
112+
objcopy
113+
objdump
114+
ranlib
115+
readelf
116+
size
117+
strings
118+
CACHE STRING "")
119+
120+
set(CLANG_TOOLS
121+
clang
122+
clangd
123+
clang-format
124+
clang-resource-headers
125+
clang-tidy
126+
CACHE STRING "")
127+
128+
set(LLD_TOOLS
129+
lld
130+
CACHE STRING "")
131+
132+
set(LLDB_TOOLS
133+
liblldb
134+
lldb
135+
lldb-argdumper
136+
lldb-python-scripts
137+
lldb-server
138+
lldb-vscode
139+
repl_swift
140+
CACHE STRING "")
141+
142+
set(SWIFT_INSTALL_COMPONENTS
143+
autolink-driver
144+
compiler
145+
clang-builtin-headers
146+
editor-integration
147+
tools
148+
sourcekit-inproc
149+
swift-remote-mirror
150+
swift-remote-mirror-headers
151+
parser-lib
152+
CACHE STRING "")
153+
154+
set(LLVM_DISTRIBUTION_COMPONENTS
155+
IndexStore
156+
libclang
157+
libclang-headers
158+
LTO
159+
runtimes
160+
${LLVM_TOOLCHAIN_TOOLS}
161+
${CLANG_TOOLS}
162+
${LLD_TOOLS}
163+
${LLDB_TOOLS}
164+
${SWIFT_INSTALL_COMPONENTS}
165+
CACHE STRING "")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
set(SWIFT_HOST_VARIANT_SDK LINUX CACHE STRING "")
3+
set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "")
4+
5+
# NOTE(compnerd) disable the tools, we are trying to build just the standard
6+
# library.
7+
set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "")
8+
9+
# NOTE(compnerd) cannot build tests since the tests require the toolchain
10+
set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "")
11+
12+
# NOTE(compnerd) cannot build docs since that requires perl
13+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
14+
15+
# NOTE(compnerd) these are part of the toolchain, not the runtime.
16+
set(SWIFT_BUILD_SYNTAXPARSERLIB NO CACHE BOOL "")
17+
set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "")
18+
19+
# NOTE(compnerd) build with the compiler specified, not a just built compiler.
20+
set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "")

0 commit comments

Comments
 (0)