-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
Otherwise compilation of proc macros, which relies on a functional host Rust compiler, fails. For example, compiling for aarch64-linux-gpu:
Called: `rustc -C linker=/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-gcc -o /workspace/srcdir/mesa/build/meson-private/rusttest.exe /workspace/srcdir/mesa/build/meson-private/sanity.rs` -> 1
stderr:
error: linking with `/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-gcc` failed: exit status: 1
|
= note: "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-gcc" "/tmp/rustcGMmpnD/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcGMmpnD/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/workspace/srcdir/mesa/build/meson-private/rusttest.exe" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: /opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/8.1.0/../../../../x86_64-linux-musl/bin/ld: /workspace/srcdir/mesa/build/meson-private/rusttest.sanity.425e246c73776925-cgu.0.rcgu.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
error: aborting due to 1 previous error
-----------
Compiler for language rust for the build machine not found.
The relocation mismatch happens because the target rustc
compiler is used instead of the host one.
Normally it'd be sufficient to pass --native-file="${MESON_HOST_TOOLCHAIN}"
next to --cross-file="${MESON_TARGET_TOOLCHAIN}"
, however, the toolchain files don't define rust
in the [binaries]
section. The reason we don't run into this for the target toolchain file, is that the target rustc
binary is on PATH. When that binary is used to compile proc macros, the above mismatch occurs.
Workaround:
host=$MACHTYPE
host_rustc=$(echo /opt/bin/${host}*/rustc)
target_rustc=$(echo /opt/bin/${target}*/rustc)
sed -i "/^\[binaries\]/a rust = '$host_rustc'" "${MESON_HOST_TOOLCHAIN}"
sed -i "/^\[binaries\]/a rust = '$target_rustc'" "${MESON_TARGET_TOOLCHAIN}"