From 940c28d072c449295f6e1225446b829bea2d3053 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Sat, 3 Dec 2022 13:03:01 +0100 Subject: [PATCH] guix: use patchelf to strip interpreter and RPATH --- contrib/guix/build.sh | 8 +++++++- contrib/guix/guix-build.sh | 12 +++++++++++- contrib/guix/manifest.scm | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/contrib/guix/build.sh b/contrib/guix/build.sh index 2377693a..44fbf773 100755 --- a/contrib/guix/build.sh +++ b/contrib/guix/build.sh @@ -22,7 +22,6 @@ EOF # We need to set RUSTC_BOOTSTRAP=1 as a workaround to be able to use unstable # features in the GUI dependencies -# FIXME: GUIX_LD_WRAPPER_DISABLE_RPATH=yes RUSTC_BOOTSTRAP=1 cargo -vvv \ --color always \ --frozen \ @@ -31,4 +30,11 @@ RUSTC_BOOTSTRAP=1 cargo -vvv \ --release \ --target-dir "$TARGET_DIR" +# Assume 64bits. Even bitcoind doesn't ship 32bits binaries for x86. +# FIXME: is there a cleaner way than using patchelf for this? +patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 "$TARGET_DIR/release/$BINARY_NAME" + +# FIXME: Find a way to use GUIX_LD_WRAPPER_DISABLE_RPATH=yes instead +patchelf --remove-rpath "$TARGET_DIR/release/$BINARY_NAME" + set +ex diff --git a/contrib/guix/guix-build.sh b/contrib/guix/guix-build.sh index 368a0ad8..8ac2ffe9 100755 --- a/contrib/guix/guix-build.sh +++ b/contrib/guix/guix-build.sh @@ -101,6 +101,16 @@ for project_folder in "" "gui"; do sed -i '/checksum/d' "$BUILD_ROOT/Cargo.lock" fi + # FIXME: find a cleaner way to get the binary name, or get rid of patchelf entirely + if [ "$project_folder" = "" ]; then + BINARY_NAME="lianad" + elif [ "$project_folder" = "gui" ]; then + BINARY_NAME="liana-gui" + else + echo "Can't determine binary name" + exit 1 + fi + # Bootstrap a reproducible environment as specified by the manifest in an isolated # container, and build the project. time_machine shell --no-cwd \ @@ -113,7 +123,7 @@ for project_folder in "" "gui"; do --share="$PROJECT_OUT_DIR=$PROJECT_OUT_DIR" \ --container \ -m $PWD/contrib/guix/manifest.scm \ - -- env CC=gcc VENDOR_DIR="$PROJECT_VENDOR_DIR" TARGET_DIR="$PROJECT_OUT_DIR" \ + -- env CC=gcc VENDOR_DIR="$PROJECT_VENDOR_DIR" TARGET_DIR="$PROJECT_OUT_DIR" BINARY_NAME="$BINARY_NAME" \ /bin/sh -c "cd /liana && ./build.sh" done diff --git a/contrib/guix/manifest.scm b/contrib/guix/manifest.scm index f3ec6b0a..515bf822 100644 --- a/contrib/guix/manifest.scm +++ b/contrib/guix/manifest.scm @@ -5,7 +5,6 @@ "coreutils" "pkg-config" ;; For the GUI "eudev" ;; For the GUI - "cmake" ;; For the GUI - "make" ;; For the GUI "fontconfig" ;; For the GUI + "patchelf" "gcc-toolchain@10.3.0"))