Skip to contentSkip to conversation

rust-common.bbclass: use built-in rust targets for -native builds

PATCH Alexander Kanavin 1 participant 1 message Nov 1, 2022 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Alexander Kanavin via lists.openembedded.org

Rust targets have the form of 'arch-unknown-linux-gnu' while oe's native targets are 'arch-linux-gnu', e.g. omit the vendor.

The effect this has on rust-native builds is that rust first builds itself as stage0 for arch-unknown-linux-gnu, then builds itself again for arch-unknown-linux-gnu, then finally uses the compiler from second step to 'cross-compile' a compiler for 'arch-linux-gnu'.

Quoted 4 lines

This last step is really not necessary, and we could save 4 minutes out of 12 if it is eliminated. Which is what this patch does by setting the target directly to 'arch-unknown-linux-gnu'; rust's build system then shortcuts the build process after the second step.

This begs the question of whether we can use the same 'unknown' targets for actual cross builds, and the answer is that alas, we cannot. Openembedded builds things differently (for the same target) depending on whether they're intended for the build system ('native') or for the target syste. One particular point where this matters is whether the resulting binaries are linked with a uninative ELF loader, or with a regular loader, and this difference is encoded in linker wrapper scripts which are different and are associated with target names.

Rust has no concept of host vs target: the only thing that defines a build is the triplet string: 'arch-vendor-system'. There is no room there to make a host vs. target distinction, if using only standard targets. Which is why we have to continue with the custom targets, and the replication of upstream definitions for various llvm settings - a significant maintenance overhead.

Alex