@@ -7,6 +7,17 @@ The resulting toolchain is written to `./output/llvm-pauth.squashfs` - it is a
77compressed read-only file system image which is intended to be ` mount ` ed to
88` /opt/llvm-pauth ` .
99
10+ Another option is building the toolchain without containers, purely on the host,
11+ but keep in mind that Clang is able to auto-discover system-provided sysroots
12+ for cross-compilation (for example, the sysroot under ` /usr/aarch64-linux-gnu `
13+ which is installed as a dependency of the ` gcc-aarch64-linux-gnu ` package in
14+ Ubuntu running on x86_64 host). This is hopefully not an issue for these scripts,
15+ as they explicitly specify the sysroots in Clang ` *.cfg ` files, and everything
16+ compiles successfully in x86_64 containerized build. Anyway, containerized
17+ builds (especially, when performed on a non-AArch64 host) look like yet another
18+ layer of protection against unintentionally linking to any system-provided
19+ libraries.
20+
1021The versions of LLVM and Musl as well as a few other tunables are set in ` config ` :
1122by default, mainline ` llvmorg-21.1.0-rc1 ` tag is used together with a patched
1223version of Musl that can be obtained at https://github.com/access-softek/musl .
@@ -25,25 +36,25 @@ not checked whether the working copy is clean or not.
2536Ensure ` llvm-project ` and ` musl ` repositories are cloned on the host and contain
2637the commits specified in the ` ./config ` file (by default, you need the mainline
2738LLVM monorepo and patched Musl version from https://github.com/access-softek/musl ).
28- Alternatively, you can pass https:// or git:// URLs directly to ` ./docker .sh sources ` .
39+ Alternatively, you can pass https:// or git:// URLs directly to ` ./build .sh sources ` .
2940
3041Checkout the particular commits of LLVM and Musl sources under ` ./src ` and
3142download Linux kernel tarball by running:
3243
3344```
34- ./docker .sh sources <llvm_repo_url> <musl_repo_url>
45+ ./build .sh sources <llvm_repo_url> <musl_repo_url>
3546```
3647
3748if LLVM and Musl are already cloned on the host, use
3849
3950```
40- ./docker .sh sources file:///absolute/path/to/llvm-project file:///absolute/path/to/musl
51+ ./build .sh sources file:///absolute/path/to/llvm-project file:///absolute/path/to/musl
4152```
4253
4354Then build the toolchain by running
4455
4556```
46- ./docker .sh build
57+ ./build .sh build
4758```
4859
4960The build artifact is ` ./output/llvm-pauth.squashfs ` file.
@@ -118,3 +129,44 @@ $ gdb-multiarch
118129>>> b main
119130>>> c
120131```
132+
133+ # Building the toolchain without Docker
134+
135+ The preferred way to use these scripts is building inside a container, though
136+ it is possible to build the toolchain purely on the host.
137+
138+ This can be achieved by running ` ./build.sh host-build ` instead of
139+ ` ./build.sh build ` after checking out the sources to ` ./src/* ` the same way as
140+ for a containerized build. After a successful build, the toolchain is installed
141+ to the ` ./inst ` subdirectory inside this repository (can be customized in
142+ ` ./config ` ) and no archive is created under ` ./output ` .
143+
144+ When the toolchain is being built inside a container, a temporary volume is
145+ attached as a build directory, which is discarded when the container is stopped,
146+ thus the subsequent invocation of ` ./build.sh build ` uses a fresh build directory
147+ automatically. When building on the host, on the other hand, the user is
148+ responsible for removing the half-built subdirectories of the main build
149+ directory after investigating the errors.
150+
151+ Inside the main build directory (which is ` ./build ` by default), each build step
152+ corresponds to ` {build step}-{target triple} ` subdirectory (it depends on the
153+ particular build step, whether this subdirectory is created or not) and a
154+ corresponding stamp file with ` .stamp ` suffix (which is always created ** after**
155+ the build step finishes successfully):
156+ * the step is skipped if corresponding stamp file exists (whether the directory
157+ exists or not)
158+ * an error is reported if a half-built subdirectory exists without a stamp file
159+ indicating a successful build
160+ * otherwise, a build step is performed and the stamp file is ` touch ` ed on
161+ success
162+
163+ Please note that each step is performed without taking the dependencies into
164+ account, thus the user is responsible for removing the subdirectories
165+ corresponding to the steps that have to be redone after some other steps (such
166+ as rebuilding everything linking to ` crt1.o ` after the start files were
167+ rebuilt). It is generally possible to simply remove the entire ` ./build ` and
168+ ` ./inst ` subdirectories, since LLVM should be rebuilt rather quickly thanks to
169+ ccache - the main reason for not removing ` ./build ` automatically, aside from
170+ simplifying the debugging in case of errors, is not to run ` rm -rf ` with
171+ computed paths, as this can be harmful to the host system in case of
172+ misconfiguration.
0 commit comments