blob: a77f7d512233add54c7f3057c3dc1f6f6bfe3878 [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001require rust.inc
2inherit cross
3
4python do_rust_gen_targets () {
5 wd = d.getVar('WORKDIR') + '/targets/'
6 # It is important 'TARGET' is last here so that it overrides our less
7 # informed choices for BUILD & HOST if TARGET happens to be the same as
8 # either of them.
9 for thing in ['BUILD', 'HOST', 'TARGET']:
10 bb.debug(1, "rust_gen_target for " + thing)
11 features = ""
12 cpu = "generic"
13 arch = d.getVar('{}_ARCH'.format(thing))
Andrew Geisslereff27472021-10-29 15:35:00 -050014 abi = ""
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050015 if thing is "TARGET":
Andrew Geisslereff27472021-10-29 15:35:00 -050016 abi = d.getVar('ABIEXTENSION')
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050017 # arm and armv7 have different targets in llvm
18 if arch == "arm" and target_is_armv7(d):
19 arch = 'armv7'
20 features = d.getVar('TARGET_LLVM_FEATURES') or ""
21 cpu = d.getVar('TARGET_LLVM_CPU')
Andrew Geisslereff27472021-10-29 15:35:00 -050022 rust_gen_target(d, thing, wd, features, cpu, arch, abi)
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050023}
24
25# Otherwise we'll depend on what we provide
26INHIBIT_DEFAULT_RUST_DEPS = "1"
27
28# Unlike native (which nicely maps it's DEPENDS) cross wipes them out completely.
29# Generally, we (and cross in general) need the same things that native needs,
30# so it might make sense to take it's mapping. For now, though, we just mention
31# the bits we need explicitly.
32DEPENDS += "rust-llvm-native"
33DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc"
34DEPENDS += "rust-native"
35
36PROVIDES = "virtual/${TARGET_PREFIX}rust"
Andrew Geissler595f6302022-01-24 19:11:47 +000037PN = "rust-cross-${TUNE_PKGARCH}-${TCLIBC}"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050038
39# In the cross compilation case, rustc doesn't seem to get the rpath quite
40# right. It manages to include '../../lib/${TARGET_PREFIX}', but doesn't
41# include the '../../lib' (ie: relative path from cross_bindir to normal
42# libdir. As a result, we end up not being able to properly reference files in normal ${libdir}.
43# Most of the time this happens to work fine as the systems libraries are
44# subsituted, but sometimes a host system will lack a library, or the right
45# version of a library (libtinfo was how I noticed this).
46#
47# FIXME: this should really be fixed in rust itself.
48# FIXME: using hard-coded relative paths is wrong, we should ask bitbake for
49# the relative path between 2 of it's vars.
50HOST_POST_LINK_ARGS:append = " -Wl,-rpath=../../lib"
51BUILD_POST_LINK_ARGS:append = " -Wl,-rpath=../../lib"
52
53# We need the same thing for the calls to the compiler when building the runtime crap
54TARGET_CC_ARCH:append = " --sysroot=${STAGING_DIR_TARGET}"
55
56do_rust_setup_snapshot () {
57}
58
59do_configure () {
60}
61
62do_compile () {
63}
64
65do_install () {
66 mkdir -p ${D}${prefix}/${base_libdir_native}/rustlib
67 cp ${WORKDIR}/targets/${TARGET_SYS}.json ${D}${prefix}/${base_libdir_native}/rustlib
68}
69
70rust_cross_sysroot_preprocess() {
71 sysroot_stage_dir ${D}${prefix}/${base_libdir_native}/rustlib ${SYSROOT_DESTDIR}${prefix}/${base_libdir_native}/rustlib
72}
73SYSROOT_PREPROCESS_FUNCS += "rust_cross_sysroot_preprocess"