Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This directory contains scripts to build an LLVM PAuth toolchain from scratch.

The sources of LLVM, Musl and Linux kernel are first checked out on host under
`./src/` and then the toolchain is built inside a Docker container.
To speed up rebuilds significantly, a `./ccache/` directory is mounted from the host.
To speed up rebuilds significantly, a `./ccache-docker/` directory is mounted from the host.
The resulting toolchain is written to `./output/llvm-pauth.squashfs` - it is a
compressed read-only file system image which is intended to be `mount`ed to
`/opt/llvm-pauth`.
Expand Down
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ build_in_docker() {
check_repo_sha "$LLVM_SOURCE_DIR_docker_host" "$LLVM_SHA"
check_repo_sha "$MUSL_SOURCE_DIR_docker_host" "$MUSL_SHA"

# Assuming our non-privileged user is allowed to run `docker` directly, create
# the directories like ./output as the regular user before executing `docker run`,
# so that their direct contents (such as ./output/llvm-pauth.squashfs) can be
# renamed/deleted without `sudo`.
mkdir -p "$OUTPUT_DIR_docker_host"
mkdir -p "$CCACHE_DIR_docker_host"
mkdir -p "$REPO_ROOT_docker_host/tmp"

$DOCKER_CMD build \
-t "$DOCKER_IMAGE_NAME" \
-f Dockerfile.builder \
Expand Down
6 changes: 5 additions & 1 deletion scripts/global-vars.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ set_global_variables() {
local host_repo_root="$2" # Must be empty if purpose is "docker"

local repo_root
local ccache_dir
case "$purpose" in
host_build)
repo_root="$host_repo_root"
ccache_dir="$repo_root/ccache-host"
;;
docker_host)
repo_root="$host_repo_root"
ccache_dir="$repo_root/ccache-docker"
;;
docker)
[ "x$host_repo_root" != "x" ] && \
report_fatal_error "Do not specify host_repo_root with 'docker'."

repo_root="/repo"
ccache_dir="$repo_root/ccache-docker"
;;
*)
report_fatal_error "Expected one of host_build, docker_host, docker."
Expand All @@ -45,7 +49,7 @@ set_global_variables() {

eval REPO_ROOT_$purpose='"$repo_root"'
eval OUTPUT_DIR_$purpose='"$repo_root/output"'
eval CCACHE_DIR_$purpose='"$repo_root/ccache"'
eval CCACHE_DIR_$purpose='"$ccache_dir"'
eval BUILD_TMP_$purpose='"$repo_root/build"'

eval SRC_DIR_$purpose='"$repo_root/src"'
Expand Down