diff --git a/README.md b/README.md index 38b1ddb..5a53c48 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/build.sh b/build.sh index a19f2b1..5b6d75b 100755 --- a/build.sh +++ b/build.sh @@ -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 \ diff --git a/scripts/global-vars.inc.sh b/scripts/global-vars.inc.sh index b69362e..e77cf19 100644 --- a/scripts/global-vars.inc.sh +++ b/scripts/global-vars.inc.sh @@ -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." @@ -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"'