aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakuto Ikuta <tikuta@chromium.org>2018-08-29 15:07:30 +0900
committerMike Frysinger <vapier@gentoo.org>2023-12-22 00:31:14 -0500
commit8f404c038705389cefd86e8a1fba1b50074a01ae (patch)
tree4a5ec7da2fa39e465c2d5d265827a6d2fcc3a7f9
parentlddtree: fix argcomplete typing (diff)
downloadpax-utils-8f404c038705389cefd86e8a1fba1b50074a01ae.tar.gz
pax-utils-8f404c038705389cefd86e8a1fba1b50074a01ae.tar.bz2
pax-utils-8f404c038705389cefd86e8a1fba1b50074a01ae.zip
lddtree: keep relativeness of invoked program in elf wrapper
This makes clang's resource dir relative when we pass -no-canonical-prefixes flag like below. $ chromium/.cros_cache/chrome-sdk/tarballs/$BOARD+$VERSION+target_toolchain/usr/bin/clang -no-canonical-prefixes -### Chromium OS 7.0_pre328903_p20180425-r5 clang version 7.0.0 (/var/cache/chromeos-cache/distfiles/host/egit-src/clang.git e7408fe366bb18923fa360b069b4e4566203f34f) (/var/cache/chromeos-cache/distfiles/host/egit-src/llvm.git 95561668f063fbcb8195bde05ecede721ece4ba4) (based on LLVM 7.0.0svn) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: chromium/.cros_cache/chrome-sdk/tarballs/kevin+10750.0.0+target_toolchain/usr/bin Without this patch, -no-canonical-prefixes has no meaning. $ chromium/.cros_cache/chrome-sdk/tarballs/$BOARD+$VERSION+target_toolchain/usr/bin/clang -no-canonical-prefixes -### Chromium OS 7.0_pre328903_p20180425-r5 clang version 7.0.0 (/var/cache/chromeos-cache/distfiles/host/egit-src/clang.git e7408fe366bb18923fa360b069b4e4566203f34f) (/var/cache/chromeos-cache/distfiles/host/egit-src/llvm.git 95561668f063fbcb8195bde05ecede721ece4ba4) (based on LLVM 7.0.0svn) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: $HOME/chromium/.cros_cache/chrome-sdk/tarballs/kevin+10750.0.0+target_toolchain/usr/bin This is a part of effort for build cache sharing when using goma by removing absolute path from compile result. Instead of enforcing relative path, I keep relativeness of compiler path. I confirmed this works as following with a debug line to show ${base}.elf. (sdk daisy R70-11005.0.0) tikuta@tikuta ~/chromium/src $ ln -s build/cros_cache/chrome-sdk/tarballs/daisy+11005.0.0+target_toolchain/usr/bin/clang-7 clang (sdk daisy R70-11005.0.0) tikuta@tikuta ~/chromium/src $ ./clang ${base}.elf: './build/cros_cache/chrome-sdk/tarballs/daisy+11005.0.0+target_toolchain/usr/bin/clang-7.elf' clang-7: error: no input files In previous versions of this change, it ran like below: (sdk daisy R70-11005.0.0) tikuta@tikuta ~/chromium/src $ ./clang ${base}.elf: '/usr/local/google/home/tikuta/chromium/src/build/cros_cache/chrome-sdk/tarballs/daisy+11005.0.0+target_toolchain/usr/bin/clang-7.elf' clang-7: error: no input files I confirmed this can build base_unittests on daisy and amd64-generic after creating a new CrOS SDK with chromiumos-sdk-tryjob. Bug: https://crbug.com/846610 Bug: https://crbug.com/876604 Signed-off-by: Takuto Ikuta <tikuta@chromium.org> Signed-off-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xlddtree.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lddtree.py b/lddtree.py
index 80808fc..bbf9df9 100755
--- a/lddtree.py
+++ b/lddtree.py
@@ -182,8 +182,12 @@ def GenerateLdsoWrapper(
"argv0_arg": '--argv0 "$0"' if interp_supports_argv0(root + interp) else "",
"preload_arg": f'--preload "{preload}"' if preload else "",
}
+
+ # Keep path relativeness of argv0 (in ${base}.elf). This allows tools to
+ # remove absolute paths from build outputs and enables directory independent
+ # cache sharing in distributed build systems.
wrapper = """#!/bin/sh
-if ! base=$(realpath "$0" 2>/dev/null); then
+if ! base=$(dirname "$0")/$(readlink "$0" 2>/dev/null); then
case $0 in
/*) base=$0;;
*) base=${PWD:-`pwd`}/$0;;