build/toolchain/musl-host-gcc: handle non-workspace-root execution
This is needed to build stdlib with cgo, which is in turn required for
the race checker to be enabled.
Change-Id: Ic81542925a02c626f157dfd8c6650de3dbb30c7d
Reviewed-on: https://review.monogon.dev/c/monogon/+/1832
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/build/toolchain/musl-host-gcc/gcc-wrapper.sh b/build/toolchain/musl-host-gcc/gcc-wrapper.sh
index a430e75..33048c0 100755
--- a/build/toolchain/musl-host-gcc/gcc-wrapper.sh
+++ b/build/toolchain/musl-host-gcc/gcc-wrapper.sh
@@ -1,2 +1,3 @@
#!/usr/bin/env bash
-exec /usr/bin/gcc "$@" -specs build/toolchain/musl-host-gcc/musl.spec
+SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
+exec /usr/bin/gcc "$@" -specs $SCRIPT_DIR/musl.spec
diff --git a/build/toolchain/musl-host-gcc/musl.spec b/build/toolchain/musl-host-gcc/musl.spec
index 376d0d9..c726fe5 100644
--- a/build/toolchain/musl-host-gcc/musl.spec
+++ b/build/toolchain/musl-host-gcc/musl.spec
@@ -1,25 +1,25 @@
%rename cpp_options old_cpp_options
*cpp_options:
--nostdinc %(old_cpp_options) -isystem external/musl_sysroot/include
+-nostdinc %(old_cpp_options) -isystem $SYSROOT/include
*cc1:
-%(cc1_cpu) -nostdinc -isystem external/musl_sysroot/include
+%(cc1_cpu) -nostdinc -isystem $SYSROOT/include
*link_libgcc:
--L .%s -L external/musl_sysroot/lib
+-L .%s -L %R/lib
*libgcc:
libgcc.a%s %:if-exists(libgcc_eh.a%s)
*startfile:
-%{!shared: external/musl_sysroot/lib/Scrt1.o} external/musl_sysroot/lib/crti.o crtbeginS.o%s
+%{!shared: %R/lib/Scrt1.o} %R/lib/crti.o crtbeginS.o%s
*endfile:
-crtendS.o%s external/musl_sysroot/lib/crtn.o
+crtendS.o%s %R/lib/crtn.o
*link:
--nostdlib -no-dynamic-linker -static %{rdynamic:-export-dynamic}
+-no-dynamic-linker -nostdlib -static %{rdynamic:-export-dynamic}
*esp_link: