sunfishcode / io-lifetimes

A low-level I/O ownership and borrowing library
Other
98 stars 10 forks source link

fix cross compilation with custom sysroot #57

Closed cmeissl closed 1 year ago

cmeissl commented 1 year ago

compiling rust programs in yocto uses a custom target triple with a custom sysroot not specifying the sysroot when executing rustc can lead to errors like "can't find crate for std" this patch forwards the sysroot for testing features

sunfishcode commented 1 year ago

Instead of parsing the sysroot out of CARGO_ENCODED_RUSTFLAGS, would it work to split the CARGO_ENCODED_RUSTFLAGS on 0x1f (the delimiter according to this) and pass all the strings as arguments to every rustc invocation?

cmeissl commented 1 year ago

Instead of parsing the sysroot out of CARGO_ENCODED_RUSTFLAGS, would it work to split the CARGO_ENCODED_RUSTFLAGS on 0x1f (the delimiter according to this) and pass all the strings as arguments to every rustc invocation?

yes, that should work too. anyhow seems to do exactly that. I will update this PR later today or tomorrow.

cmeissl commented 1 year ago

I removed the build dep to rustflags and changed to code to just forward all flags. Would be awesome to get that change released soon as this currently blocks some builds for me :)

sunfishcode commented 1 year ago

Thanks!

sunfishcode commented 1 year ago

This PR is now in the io-lifetimes 1.0.4 release.

cmeissl commented 1 year ago

This PR is now in the io-lifetimes 1.0.4 release.

Awesome, thanks! Can confirm this fixes my build when using the yocto cargo.bbclass .

sunfishcode commented 1 year ago

Following anyhow's change and this documentation I'm planning to change this from using CARGO_RUSTC_WRAPPER to using RUSTC_WRAPPER.

If I understand correctly, CARGO_RUSTC_WRAPPER wasn't ever set, and just the CARGO_ENCODED_RUSTFLAGS part of this PR was what fixed the build for you, so this change shouldn't have any affect. But I wanted to ping this issue just as a heads up.