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