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