-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*-musl cross builds fail on proc_macro
#8
Comments
There's several workarounds I've been thinking about:
|
libc switch updateI managed to get our binaries to build, however the proc_macro feature still seems to be causing problems. Without our package, the glibc build continues and successfully finishes for VirtualBox. The new problem with
|
Fun fact: The problematic crate ( |
So to be clear we added proc-macro true to one of our crates and it fixed the proc-macro2 issue? Now that I've successfully built for mips I'm trying to correlate all the facts. |
I did not add |
@jkilpatr Pasting the script that worked for you (the version you posted on Riot) so it doesn't get lost #!/bin/bash
export CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=/home/justin/repos/althea-firmware/build/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl/bin/mips-openwrt-linux-gcc
export TARGET_CC=/home/justin/repos/althea-firmware/build/staging_dir/toolchain-mips_24kc_gcc-5.5.0_musl/bin/mips-openwrt-linux-gcc
export HOST_CC=gcc
export OPENSSL_STATIC=true
export MIPS_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/home/justin/repos/althea-firmware/build/staging_dir/target-mips_24kc_musl/usr/
export PKG_CONFIG_ALLOW_CROSS=1
#cargo clean
cargo build --target mips-unknown-linux-musl --release |
You could technically say that this issue is resolved as it doesn't get in our way anymore, but I think we'll see more of it in the future. |
Steps to reproduce
The issue happens in the
proc-macro2
crate on which we indirectly depend.serde
depends on it, so we probably won't get away with "dependency amputation". For just reproducing the issue:althea-firmware
roles/prepare-config/defaults/main.yml
feeds_list
tosrc-git althea https://github.com/drozdziak1/althea-packages.git;proc-macro-debug-trash
ansible-playbook
should exit with an errorcd build/
to investigatemake -j1 package/althea-rust-binaries/compile V=s
to see the full build outputSteps 1-5. need to be done only once and as long as you don't swap out the
althea-pachages
to use you only need to do 6. in order to rebuild.To experiment with our OpenWrt package definition Makefile (This requires doing the steps from the list above):
proc-macro-debug-trash
althea-firmware
and again openroles/prepare-config/defaults/main.yml
src-link althea </full/path/to/where/you/cloned/althea-packages>
cd build/
scripts/feeds uninstall althea-rust-binaries
scripts/feeds uninstall althea-babeld
scripts/feeds uninstall generate-ipv6-address
cd ..
back toalthea-firmware
rootNow changes in
althea/althea-rust-binaries/Makefile
should be immediately applied to the firmware build upon rebuilding (step 6. from the first list inalthea-firmware/build
)To experiment with
althea_rs
in the cross build (This requires doing the steps from the list above):git checkout -b proc-macro-debug-trash
to create a disposable trash branch to experiment incd
into the path where your copy ofalthea-packages
checked out atproc-macro-debug-trash
isalthea/althea-rust-binaries/Makefile
PKG_SOURCE_VERSION
toproc-macro-debug-trash
PKG_SOURCE_URL
to the full path to the copy ofalthea_rs
that you just clonedNow
althea-firmware
should've builtalthea_rs
using the copy you cloned in step 1. After making a change in your localalthea_rs
commit it to theproc-macro-debug-trash
branch and dorm -rf dl/althea-rust-binaries*
inalthea-firmware/build
. Now you can rebuild (step 6 from the first list) and see the effect.Expected result
The build succeeds and installs
rita
andguac-light-client
in the firmwareWhat's actually happening
The cross build for
*-musl
targets fails because aproc_macro
crate cannot be found, presently while building aproc-macro2
crate.The underlying issue
This seems to be a flaw in Rust itself as only musl targets are ever affected regardless of whether we use OpenWrt or not or whether we build
althea_rs
or anything else that usesproc_macro
(check out the minimal test case below). The problem is that the procedural macro crate is a dynamically linked library. For some reason this messes up builds against themusl
libc implementation. SeeLinks
for more information.Minimal test case
Apart from the relatively complicated reproduction steps above, it's possible to trivially reproduce the underlying issue outside the OpenWrt cross-build:
cargo new blah
blah/src/lib.rs
and addextern crate proc_macro;
on topcargo build --target <some -musl target>
The build should fail on
proc_macro
being not found and at the same time compile normally without--target <some -musl target>
or a-gnu
target. If theproc_macro
issue was not present, the build should complain about the linker being unspecified. OpenWrt deals with this by supplying all necessary cross environment information through env variables.Links
proc-macro2
(the crate where the actual error appears) Build fails on-musl
targets because ofproc_macro
dtolnay/proc-macro2#52proc_macro
on musl target rust-lang/rust#40174The text was updated successfully, but these errors were encountered: