Include compiler-specific headers in musl toolchain sysroot
Currently our musl sysroot does not include any compiler-specific headers. This makes the musl
toolchain unable to build more complicated things like QEMU. Since the musl toolchain is not actually
a real toolchain, but just a thin wrapper around the host toolchain this is a problem as these headers
are not static. For a lack of better options it has thus been decided that we're just going to manually
merge the headers for our build container in.
This is expected to be removed as soon as we have a proper toolchain.
Test Plan: Tested in subsequent revision
X-Origin-Diff: phab/D737
GitOrigin-RevId: a1ed1d229c87980341c80b22263f5d9a4cf9924c
diff --git a/build/toolchain/musl-host-gcc/sysroot/tarball.bzl b/build/toolchain/musl-host-gcc/sysroot/tarball.bzl
index 5466690..14b7bbd 100644
--- a/build/toolchain/musl-host-gcc/sysroot/tarball.bzl
+++ b/build/toolchain/musl-host-gcc/sysroot/tarball.bzl
@@ -34,6 +34,8 @@
linux_headers = ctx.file.linux_headers
linux_headers_path = linux_headers.path
+ compiler_headers_path = "lib/gcc/x86_64-redhat-linux/10/include"
+
musl_root = detect_root(ctx.attr.musl)
musl_files = ctx.files.musl
@@ -46,14 +48,19 @@
arguments = [tarball.path]
command = "tar -chJf $1"
- arguments += [musl_headers_path]
- command += " --transform 's|^'$2'|include|' $2"
+ # Order is important here as this is a terrible hack producing a tar file with duplicate files. The decompressor
+ # will then overwrite the wrong one with the correct one for us.
+ arguments += [compiler_headers_path]
+ command += " --transform 's|^'$2'|include|' /$2"
- arguments += [linux_headers_path]
+ arguments += [musl_headers_path]
command += " --transform 's|^'$3'|include|' $3"
+ arguments += [linux_headers_path]
+ command += " --transform 's|^'$4'|include|' $4"
+
arguments += [musl_root]
- command += " --transform 's|^'$4'|lib|' $4"
+ command += " --transform 's|^'$5'|lib|' $5"
ctx.actions.run_shell(
inputs = [musl_headers, linux_headers] + ctx.files.musl,
@@ -64,7 +71,7 @@
use_default_shell_env = True,
command = command,
)
- return [DefaultInfo(files=depset([tarball]))]
+ return [DefaultInfo(files = depset([tarball]))]
musl_gcc_tarball = rule(
implementation = _musl_gcc_tarball,