The old cargo.bbclass had no users in meta-rust and had lots of
problems (not least of which was lots of duplicated lines with
cargo_util.bbclass). Delete the old cargo.bbclass and replace it
entirely wiht cargo_util
The local registry is a more future-proof way to prevent cargo from
accessing the network during the build. Unfortunately, this is only
used during the build of cargo-native for now. The snapshot used while
building cargo-native supports using a local registry ("source
replacement") however the version of cargo supported by rust 1.10 does
not.
Until we can build a new-enough version of cargo that supports
source-replacement, we'll have to patch cargo directly to prevent it
from accessing the network. Once we do have a new-enough cargo, we can
stop populating cargo_home/registry and only create cargo_registry.
Instead of building a full compiler, we can use rust-native to
cross-compile. All we need is a cross-compiled standard library, which
libstd-rs builds, and a compiler spec file. rust-cross is now just used
to generate the json spec file for cross-compiling, which is naturally
much faster.
The oe-core/poky change 'base.bbclass wipe ${S} before unpacking
source' (poky: a56fb90dc3805494eeaf04c60538425e8d52efc5, oe-core:
eccae514b71394ffaed8fc45dea7942152a334a1) wipes ${S} in do_unpack prior
to unpacking. This breaks our shared source as we set ${S} to the shared
location, and don't actually unpack anything (the result is we try to
build rustc without any source code, which fails predictably)
Avoid this by clearing do_unpack[cleandirs].
At the same time take pieces of gcc-shared-source.inc and note how & why
we differ from how gcc operates.
This is a bit of a hack, and only happens to work because we know the
exact method that do_unpack uses to clear ${S}, and using python()
happens to get called at the "right time".
RUSTFLAGS is used by Cargo and always passed to the compiler. Put our
non-standard crate_hash argument there because it is required for
reproducible builds.
Add the rpath option to avoid having to patch Cargo.toml for this and
remove the function that does so.
Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
rust-bin.bbclass now only contains what is necessary to build crates
using the rust compiler directly and rust.bbclass contains information
shared between rust-bin and cargo.
Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
This should eliminate the problems that have been seen when bitbake
rebuilds part of the rust stack (due to missing sstate) and ends up
getting hash mismatches. Unlike rust's internally generated hash, ours
is guaranteed to be stable.
With multilib, we may want to install under lib64 but the rust libraries
get published in the build sysroot under the libdir for the build
machine which is usually just lib. Support these being different.
Poky 1.7 uses RPATH is now RUNPATH, so update our grep string appropriately.
Additionally, bitbake is having trouble with the automatic RDEPENDS on
rustlib. Make it explicit for now.
poky 1.7 changes where it publishes cross output to so this recipe
needs to follow that. Unfortunately this path is defined in
cross.bbclass and we can't inherit that since we aren't cross.
Rust library names may have sonames that overlap with C/C++ libraries.
This causes bitbake to not be able to create the correct automatic
RDEPENDS between packages. The result is that dependencies may not get
automatically installed.
Add -rs to the file name and soname. The crate name remains the same,
and rust is not dependent on the file name to look up the crate inside
the library.
Libraries that overlap with the standard library must have explicit
extern declarations. Without something like pkg-config where the
libraries can publish this info, it's easiest to just hard-code the list
of troublesome libraries.
We control static/dynamic by only making one or the other available.
Apparently the default of prefer static causes duplicate symbols for the
standard library.
This provides more defaults that aren't required for compiling with
rustc, but standardize the output for inclusion in a distro.
Things like
- Where to install libraries
- Stripping rustc note sections
- Optimization by default