You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #82 we fixed the build when the target arch is the same as the build arch. A
side effect of the fix is that the rust build-scripts (which are intended to run
on the build host) are now built with the target compiler and cflags.
This is fine in most cases but it breaks when the host system is older than the
system we are building. For example, we might build for a newer glibc that will
be available on the target but when we run the build script on the host, this
version does not exist which leads to the error described in #83.
Another version of the same problem is that we may try to use some build flags
that are available on the compiler for the target (`aarch64-poky-linux-gcc`) but
not on the host compiler (`gcc`) because the host compiler is older than the one
we are using for the target.
This patch fixes the problem by using two unstable features of cargo:
- [`UNSTABLE_TARGET_APPLIES_TO_HOST`](https://doc.rust-lang.org/cargo/reference/unstable.html#target-applies-to-host)
allows us to pass the `CARGO_TARGET_APPLIES_TO_HOST=false` setting so that the
target build settings are not used when building for the host.
- [`UNSTABLE_HOST_CONFIG`](https://doc.rust-lang.org/cargo/reference/unstable.html#host-config)
allows us to set build flags for the host.
The `__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS` environment variable is
required to use these unstable features on a stable rust. This patch works with
stable rust and does not require unstable.
During review of this PR, it was decided to drop the `cargo_home/config` file
completely and use only environment variables.
The inspiration for this solution [comes from buildroot](https://github.com/buildroot/buildroot/blob/25d865996d1d9753fe7d4dfe39cf18c7e9f91224/package/pkg-cargo.mk#L26-L47).
fixes#83
0 commit comments