diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-05 13:15:31 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-08 15:41:36 +0100 |
commit | 9160e4a37561d8ac882057450a818621bec13bed (patch) | |
tree | cfc51e97afcc48e16c2584b3a10eaafb65f5da20 /meta/classes | |
parent | b30ee171de9cd736d16d783410cf748e35309257 (diff) | |
download | openembedded-core-contrib-9160e4a37561d8ac882057450a818621bec13bed.tar.gz |
rust: Generate per recipe target configuration files
Instead of generating target configuration files centrally and often getting
it wrong, or having trouble finding the right set, generate them dynamically
from the bbclass into WORKDIR per recipe.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/cargo.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/rust-bin.bbclass | 1 | ||||
-rw-r--r-- | meta/classes/rust-common.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/rust-target-config.bbclass | 18 |
4 files changed, 12 insertions, 12 deletions
diff --git a/meta/classes/cargo.bbclass b/meta/classes/cargo.bbclass index 539ff03ec7..2475d05b3d 100644 --- a/meta/classes/cargo.bbclass +++ b/meta/classes/cargo.bbclass @@ -4,6 +4,7 @@ ## Cargo. inherit cargo_common +inherit rust-target-config # the binary we will use CARGO = "cargo" @@ -40,7 +41,7 @@ BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}" oe_cargo_build () { export RUSTFLAGS="${RUSTFLAGS}" - export RUST_TARGET_PATH="${RUST_TARGET_PATH}" + bbnote "Using rust targets from ${RUST_TARGET_PATH}" bbnote "cargo = $(which ${CARGO})" bbnote "rustc = $(which ${RUSTC})" bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@" diff --git a/meta/classes/rust-bin.bbclass b/meta/classes/rust-bin.bbclass index c87343b3cf..7a70a7b6ba 100644 --- a/meta/classes/rust-bin.bbclass +++ b/meta/classes/rust-bin.bbclass @@ -93,7 +93,6 @@ do_configure () { } oe_runrustc () { - export RUST_TARGET_PATH="${RUST_TARGET_PATH}" bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" "${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" } diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass index 1bce7761ab..adcf96f0cd 100644 --- a/meta/classes/rust-common.bbclass +++ b/meta/classes/rust-common.bbclass @@ -1,4 +1,5 @@ inherit python3native +inherit rust-target-config # Common variables used by all Rust builds export rustlibdir = "${libdir}/rust" @@ -10,7 +11,6 @@ RUSTLIB = "-L ${STAGING_LIBDIR}/rust" RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}" RUSTLIB_DEP ?= "libstd-rs" -export RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib" RUST_PANIC_STRATEGY ?= "unwind" # Native builds are not effected by TCLIBC. Without this, rust-native diff --git a/meta/classes/rust-target-config.bbclass b/meta/classes/rust-target-config.bbclass index ab177cf59f..bc6bd77abb 100644 --- a/meta/classes/rust-target-config.bbclass +++ b/meta/classes/rust-target-config.bbclass @@ -292,6 +292,7 @@ def rust_gen_target(d, thing, wd, arch): import json sys = d.getVar('{}_SYS'.format(thing)) prefix = d.getVar('{}_PREFIX'.format(thing)) + rustsys = d.getVar('RUST_{}_SYS'.format(thing)) abi = None cpu = "generic" @@ -318,13 +319,9 @@ def rust_gen_target(d, thing, wd, arch): features = features or d.getVarFlag('FEATURES', arch_abi) or "" features = features.strip() - llvm_target = d.getVar('RUST_TARGET_SYS') - if thing == "BUILD": - llvm_target = d.getVar('RUST_HOST_SYS') - # build tspec tspec = {} - tspec['llvm-target'] = llvm_target + tspec['llvm-target'] = rustsys tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) if tspec['data-layout'] is None: bb.fatal("No rust target defined for %s" % arch_abi) @@ -358,7 +355,7 @@ def rust_gen_target(d, thing, wd, arch): tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY") # write out the target spec json file - with open(wd + sys + '.json', 'w') as f: + with open(wd + rustsys + '.json', 'w') as f: json.dump(tspec, f, indent=4) # These are accounted for in tmpdir path names so don't need to be in the task sig @@ -366,10 +363,13 @@ rust_gen_target[vardepsexclude] += "ABIEXTENSION llvm_cpu" do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES" -RUST_TARGETGENS = "BUILD" +RUST_TARGETS_DIR = "${WORKDIR}/rust-targets/" +export RUST_TARGET_PATH = "${RUST_TARGETS_DIR}" + +RUST_TARGETGENS = "BUILD HOST TARGET" python do_rust_gen_targets () { - wd = d.getVar('WORKDIR') + '/targets/' + wd = d.getVar('RUST_TARGETS_DIR') # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH')) if "HOST" in d.getVar("RUST_TARGETGENS"): @@ -379,5 +379,5 @@ python do_rust_gen_targets () { } addtask rust_gen_targets after do_patch before do_compile -do_rust_gen_targets[dirs] += "${WORKDIR}/targets" +do_rust_gen_targets[dirs] += "${RUST_TARGETS_DIR}" |