Skip to content

Commit 7d1bf4d

Browse files
committed
Use 3stages
1 parent d188a03 commit 7d1bf4d

File tree

5 files changed

+31
-49
lines changed

5 files changed

+31
-49
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
# Stage 1:
2-
# * Build the prerequisites for stage 2.
3-
# * We will be building an LTO optimized libcxx in stage 2, so we need to
4-
# build clang and lld.
1+
# Stage 1
2+
# * Build an LTO optimized libcxx, so we can staticially link it into stage 2
3+
# clang.
54

65

76
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
87
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
9-
set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
8+
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE)
9+
set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "" FORCE)
1010

1111
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
12-
set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage2.cmake CACHE BOOL "")
13-
set(CLANG_BOOTSTRAP_TARGETS stage3-check-all stage3-distribution stage3-install-distribution stage3-clang stage3-clang-bolt CACHE BOOL "")
12+
set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage2-instrumented.cmake CACHE BOOL "")
13+
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE BOOL "")
14+
set(CLANG_BOOTSTRAP_TARGETS stage2-check-all stage2-distribution stage2-install-distribution stage2-clang stage2-clang-bolt CACHE BOOL "")
15+
set(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY ON CACHE STRING "")
16+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" CACHE STRING "")
17+
set(LLVM_ENABLE_LLD ON CACHE STRING "")
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Stage 3 instrumented:
2-
# * Build an instrumented clang, so we can generate profile data for stage 3.
1+
# Stage 2 instrumented:
2+
# * Build an instrumented clang, so we can generate profile data for stage 2.
33

44

55
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
6-
set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage3.cmake CACHE BOOL "")
6+
set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage2.cmake CACHE BOOL "")
77
set(CLANG_BOOTSTRAP_TARGETS clang check-all distribution install-distribution clang-bolt CACHE BOOL "")
88
set(CLANG_BOLT OFF CACHE STRING "")
99

10-
include(${CMAKE_CURRENT_LIST_DIR}/stage3.cmake)
10+
include(${CMAKE_CURRENT_LIST_DIR}/stage2.cmake)
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# Stage 2:
2-
# * Build an LTO optimized libcxx, so we can staticially link it into stage 3
3-
# clang.
4-
# * Stage 3 will be PGO optimized, so we need to build clang, lld, and
5-
# compiler-rt in stage 2.
2+
# * This is the final stage.
3+
# * The goal is to have a clang that is LTO, PGO, and bolt optimized and also
4+
# statically linked to libcxx and compiler-rt.
65

7-
8-
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
96
set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
107
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE)
11-
set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "" FORCE)
12-
13-
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
14-
set(CLANG_BOOTSTRAP_CMAKE_ARGS -C ${CMAKE_CURRENT_LIST_DIR}/stage3-instrumented.cmake CACHE BOOL "")
15-
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE BOOL "")
16-
set(CLANG_BOOTSTRAP_TARGETS stage3-check-all stage3-distribution stage3-install-distribution stage3-clang stage3-clang-bolt CACHE BOOL "")
17-
set(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY ON CACHE STRING "")
18-
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" CACHE STRING "")
8+
set(LLVM_ENABLE_PROJECTS "clang;lld;bolt;" CACHE STRING "" FORCE)
199
set(LLVM_ENABLE_LLD ON CACHE STRING "")
20-
#set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
10+
set(LLVM_ENABLE_LTO THIN CACHE STRING "")
11+
set(LLVM_ENABLE_LIBCXX ON CACHE STRING "")
12+
set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE STRING "")
13+
set(CLANG_BOLT "INSTRUMENT" CACHE STRING "")
14+
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow -rtlib=compiler-rt --unwindlib=libunwind -static-libgcc" CACHE STRING "")
15+
set(CMAKE_SHARED_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind -static-libgcc" CACHE STRING "")
16+
set(LLVM_DISTRIBUTION_COMPONENTS "clang;lld;runtimes;clang-resource-headers" CACHE STRING "")

clang/cmake/caches/llvm-toolchain/stage3.cmake

Lines changed: 0 additions & 16 deletions
This file was deleted.

clang/cmake/caches/llvm-toolchain/usage.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ This directory contains cache files for building a complete LLVM-based toolchain
44
The resulting clang build will be LTO, PGO, and BOLT optimized and statically
55
linked against libc++ and compiler-rt.
66

7-
The build is done in 4 stages:
7+
The build is done in 3 stages:
88

9-
* Stage 1: Build clang/lld.
10-
* Stage 2: Build an LTO optimized libc++ with Stage 1 clang/lld.
11-
* Stage 3 Instrumented: Build clang with instrumentation in order to generate
9+
* Stage 1: Build an LTO optimized libc++ with Stage 1 clang/lld.
10+
* Stage 2 Instrumented: Build clang with instrumentation in order to generate
1211
profile data for PGO.
13-
* Stage 3: Build clang with LTO, PGO, and BOLT optimizations and statically link
12+
* Stage 2: Build clang with LTO, PGO, and BOLT optimizations and statically link
1413
with stage2 libc++ and compiler-rt.
1514

1615
## Usage
1716

1817
::
19-
2018
$ cmake -S llvm -B build -C clang/cmake/caches/llvm-toolchain/stage1.cmake
21-
$ ninja stage3-install-distribution
19+
$ ninja stage2-install-distribution

0 commit comments

Comments
 (0)