solo5: fix paths detection in compiler and linker wrappers.

This commit is contained in:
Lana Black 2022-08-13 01:27:18 +00:00 committed by ehmry
parent f39e1962c0
commit 9d97ed0d57
2 changed files with 30 additions and 1 deletions

View file

@ -24,7 +24,7 @@ in stdenv.mkDerivation {
sha256 = "sha256-8LftT22XzmmWxgYez+BAHDX4HOyl5DrwrpuO2+bqqcY=";
};
patches = [ ./test_sleep.patch ];
patches = [ ./fix_paths.patch ./test_sleep.patch ];
hardeningEnable = [ "pie" ];

View file

@ -0,0 +1,29 @@
diff --git a/toolchain/cc.in b/toolchain/cc.in
index 337562a..0ec9315 100644
--- a/toolchain/cc.in
+++ b/toolchain/cc.in
@@ -30,9 +30,9 @@
# symbols.
prog="$(basename $0)"
-I="$(dirname $0)/../include"
+I="$(realpath $0 | xargs dirname)/../include"
[ ! -d "${I}" ] && echo "$prog: Could not determine include path" 1>&2 && exit 1
-L="$(dirname $0)/../lib/@@CONFIG_TARGET_TRIPLE@@"
+L="$(realpath $0 | xargs dirname)/../lib/@@CONFIG_TARGET_TRIPLE@@"
[ ! -d "${L}" ] && echo "$prog: Could not determine library path" 1>&2 && exit 1
# we can't really tell if 'cc' is called with no input, but work around the
# most obvious cases and stop them from "succeeding" and producing an "a.out"
diff --git a/toolchain/ld.in b/toolchain/ld.in
index 01dffa8..13dca2c 100644
--- a/toolchain/ld.in
+++ b/toolchain/ld.in
@@ -28,7 +28,7 @@
# linking a unikernel. No default for ABI is provided, as it is expected that a
# caller directly using 'ld' knows what they are doing.
-L="$(dirname $0)/../lib/@@CONFIG_TARGET_TRIPLE@@"
+L="$(realpath $0 | xargs dirname)/../lib/@@CONFIG_TARGET_TRIPLE@@"
[ ! -d "${L}" ] && echo "$0: Could not determine library path" 1>&2 && exit 1
# ld accepts -z solo5-abi=ABI, but does not provide a default ABI
# this is intentional