-
Notifications
You must be signed in to change notification settings - Fork 25
Description
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:
- Enter
althea-firmware
- Open
roles/prepare-config/defaults/main.yml
- Swap out the entry in
feeds_list
tosrc-git althea https://github.com/drozdziak1/althea-packages.git;proc-macro-debug-trash
- Start the build with any of the defined targets -
ansible-playbook
should exit with an error cd build/
to investigate- Rebuild with
make -j1 package/althea-rust-binaries/compile V=s
to see the full build output
Steps 1-5. need to be done only once and as long as you don't swap out thealthea-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):
- Clone this and check out branch
proc-macro-debug-trash
- Get back to
althea-firmware
and again openroles/prepare-config/defaults/main.yml
- This time swap the entry out for
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
root- do steps 4-6 from the first list
Now changes inalthea/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):
- Clone this
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
is- open
althea/althea-rust-binaries/Makefile
- Change
PKG_SOURCE_VERSION
toproc-macro-debug-trash
- Change
PKG_SOURCE_URL
to the full path to the copy ofalthea_rs
that you just cloned - Do steps 4-6 from the first list
Nowalthea-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
and guac-light-client
in the firmware
What's actually happening
The cross build for *-musl
targets fails because a proc_macro
crate cannot be found, presently while building a proc-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 uses proc_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 the musl
libc implementation. See Links
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:
- Create a new cargo library project with
cargo new blah
- Open
blah/src/lib.rs
and addextern crate proc_macro;
on top - Run
cargo 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 the proc_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
- Ongoing discussion in
proc-macro2
(the crate where the actual error appears) Build fails on-musl
targets because ofproc_macro
dtolnay/proc-macro2#52 - A similar closed issue in the official Rust repo: Unable to find crate
proc_macro
on musl target rust-lang/rust#40174