Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 1 | require rust.inc |
| 2 | inherit cross |
| 3 | |
| 4 | python 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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 14 | abi = "" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 15 | if thing is "TARGET": |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 16 | abi = d.getVar('ABIEXTENSION') |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 17 | # 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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 22 | rust_gen_target(d, thing, wd, features, cpu, arch, abi) |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | # Otherwise we'll depend on what we provide |
| 26 | INHIBIT_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. |
| 32 | DEPENDS += "rust-llvm-native" |
| 33 | DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc" |
| 34 | DEPENDS += "rust-native" |
| 35 | |
| 36 | PROVIDES = "virtual/${TARGET_PREFIX}rust" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 37 | PN = "rust-cross-${TUNE_PKGARCH}-${TCLIBC}" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 38 | |
| 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. |
| 50 | HOST_POST_LINK_ARGS:append = " -Wl,-rpath=../../lib" |
| 51 | BUILD_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 |
| 54 | TARGET_CC_ARCH:append = " --sysroot=${STAGING_DIR_TARGET}" |
| 55 | |
| 56 | do_rust_setup_snapshot () { |
| 57 | } |
| 58 | |
| 59 | do_configure () { |
| 60 | } |
| 61 | |
| 62 | do_compile () { |
| 63 | } |
| 64 | |
| 65 | do_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 | |
| 70 | rust_cross_sysroot_preprocess() { |
| 71 | sysroot_stage_dir ${D}${prefix}/${base_libdir_native}/rustlib ${SYSROOT_DESTDIR}${prefix}/${base_libdir_native}/rustlib |
| 72 | } |
| 73 | SYSROOT_PREPROCESS_FUNCS += "rust_cross_sysroot_preprocess" |