summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2023-03-13 15:16:06 +0100
committerLinus Färnstrand <faern@faern.net>2023-03-14 09:27:46 +0100
commitdd052143038874875942918025265f7546983f94 (patch)
tree6dfd95bf76dcec60948d15762097d499e8fe0df0
parent0c10514693fc95bb184b73364e558ab5130e526a (diff)
downloadmullvadvpn-dd052143038874875942918025265f7546983f94.tar.xz
mullvadvpn-dd052143038874875942918025265f7546983f94.zip
Allow using mold in containers
Opt in with USE_MOLD=true
-rwxr-xr-xbuilding/container-run.sh14
-rwxr-xr-xci/buildserver-build-android.sh4
-rwxr-xr-xci/buildserver-build.sh2
3 files changed, 14 insertions, 6 deletions
diff --git a/building/container-run.sh b/building/container-run.sh
index ed8eedd0c1..173f02f9e8 100755
--- a/building/container-run.sh
+++ b/building/container-run.sh
@@ -3,12 +3,10 @@
# Gives you a shell or runs a given command in the Android or Linux build container,
# as designated by the *-container-image.txt files. Uses podman unless overridden using the
# environment variable `CONTAINER_RUNNER`. Note that this script uses named
-# docker volumes that can be overridden using enviornment variables (see the
+# docker volumes that can be overridden using environment variables (see the
# beginning of the script).
#
# Usage: $ container-run.sh <linux/android> [command ...]
-#
-# Not supplying any command gives you a shell in the container.
set -eu
@@ -18,6 +16,9 @@ CARGO_REGISTRY_VOLUME_NAME=${CARGO_REGISTRY_VOLUME_NAME:-"cargo-registry"}
GRADLE_CACHE_VOLUME_NAME=${GRADLE_CACHE_VOLUME_NAME:-"gradle-cache"}
ANDROID_CREDENTIALS_DIR=${ANDROID_CREDENTIALS_DIR:-""}
CONTAINER_RUNNER=${CONTAINER_RUNNER:-"podman"}
+# Don't use mold by default until we have published the images with mold in
+# and swapped our builds to use them.
+USE_MOLD=${USE_MOLD:-"false"}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
@@ -45,6 +46,11 @@ case ${1-:""} in
exit 1
esac
+optional_mold=""
+if [[ "$USE_MOLD" == "true" ]]; then
+ optional_mold="mold -run"
+fi
+
set -x
exec "$CONTAINER_RUNNER" run --rm -it \
-v "$REPO_DIR:$REPO_MOUNT_TARGET:Z" \
@@ -52,4 +58,4 @@ exec "$CONTAINER_RUNNER" run --rm -it \
-v "$CARGO_REGISTRY_VOLUME_NAME:/root/.cargo/registry:Z" \
"${optional_gradle_cache_volume[@]}" \
"${optional_android_credentials_volume[@]}" \
- "$container_image_name" bash -c "$*"
+ "$container_image_name" bash -c "$optional_mold $*"
diff --git a/ci/buildserver-build-android.sh b/ci/buildserver-build-android.sh
index 81098eb9e8..61bf556d83 100755
--- a/ci/buildserver-build-android.sh
+++ b/ci/buildserver-build-android.sh
@@ -60,7 +60,9 @@ function build_ref {
git clean -df
echo "Building Android app"
- ANDROID_CREDENTIALS_DIR=$ANDROID_CREDENTIALS_DIR ./building/containerized-build.sh android --app-bundle || return 0
+ ANDROID_CREDENTIALS_DIR=$ANDROID_CREDENTIALS_DIR \
+ USE_MOLD=false \
+ ./building/containerized-build.sh android --app-bundle || return 0
# If there is a tag for this commit then we append that to the produced artifacts
# A version suffix should only be created if there is a tag for this commit and it is not a release build
diff --git a/ci/buildserver-build.sh b/ci/buildserver-build.sh
index aa85313cfe..1a74b8b8ca 100755
--- a/ci/buildserver-build.sh
+++ b/ci/buildserver-build.sh
@@ -68,7 +68,7 @@ function upload {
# means in a container on Linux, and straight up in the local shell elsewhere.
function run_in_build_env {
if [[ "$(uname -s)" == "Linux" ]]; then
- ./building/container-run.sh linux "$@"
+ USE_MOLD=false ./building/container-run.sh linux "$@"
else
bash -c "$*"
fi