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:44:20 +0100 |
commit | b1d8d2a3bfe40d83a651448bcd0eeb01434b7ad1 (patch) | |
tree | 8266c80e68acab46fed9e1831149100c31e50a84 /meta | |
parent | 9a093d034889bff444a5801313e24c39a323d7ef (diff) | |
download | poky-b1d8d2a3bfe40d83a651448bcd0eeb01434b7ad1.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.
(From OE-Core rev: 9160e4a37561d8ac882057450a818621bec13bed)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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 | ||||
-rw-r--r-- | meta/recipes-devtools/cargo/cargo.inc | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/rust/libstd-rs.inc | 3 | ||||
-rw-r--r-- | meta/recipes-devtools/rust/rust.inc | 5 | ||||
-rw-r--r-- | meta/recipes-gnome/librsvg/librsvg_2.54.4.bb | 14 |
8 files changed, 26 insertions, 22 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 @@ | |||
4 | ## Cargo. | 4 | ## Cargo. |
5 | 5 | ||
6 | inherit cargo_common | 6 | inherit cargo_common |
7 | inherit rust-target-config | ||
7 | 8 | ||
8 | # the binary we will use | 9 | # the binary we will use |
9 | CARGO = "cargo" | 10 | CARGO = "cargo" |
@@ -40,7 +41,7 @@ BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" | |||
40 | CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}" | 41 | CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}" |
41 | oe_cargo_build () { | 42 | oe_cargo_build () { |
42 | export RUSTFLAGS="${RUSTFLAGS}" | 43 | export RUSTFLAGS="${RUSTFLAGS}" |
43 | export RUST_TARGET_PATH="${RUST_TARGET_PATH}" | 44 | bbnote "Using rust targets from ${RUST_TARGET_PATH}" |
44 | bbnote "cargo = $(which ${CARGO})" | 45 | bbnote "cargo = $(which ${CARGO})" |
45 | bbnote "rustc = $(which ${RUSTC})" | 46 | bbnote "rustc = $(which ${RUSTC})" |
46 | bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@" | 47 | 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 () { | |||
93 | } | 93 | } |
94 | 94 | ||
95 | oe_runrustc () { | 95 | oe_runrustc () { |
96 | export RUST_TARGET_PATH="${RUST_TARGET_PATH}" | ||
97 | bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" | 96 | bbnote ${RUSTC} ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" |
98 | "${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" | 97 | "${RUSTC}" ${RUSTC_ARCHFLAGS} ${RUSTC_FLAGS} "$@" |
99 | } | 98 | } |
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 @@ | |||
1 | inherit python3native | 1 | inherit python3native |
2 | inherit rust-target-config | ||
2 | 3 | ||
3 | # Common variables used by all Rust builds | 4 | # Common variables used by all Rust builds |
4 | export rustlibdir = "${libdir}/rust" | 5 | export rustlibdir = "${libdir}/rust" |
@@ -10,7 +11,6 @@ RUSTLIB = "-L ${STAGING_LIBDIR}/rust" | |||
10 | RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" | 11 | RUST_DEBUG_REMAP = "--remap-path-prefix=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" |
11 | RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}" | 12 | RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}" |
12 | RUSTLIB_DEP ?= "libstd-rs" | 13 | RUSTLIB_DEP ?= "libstd-rs" |
13 | export RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib" | ||
14 | RUST_PANIC_STRATEGY ?= "unwind" | 14 | RUST_PANIC_STRATEGY ?= "unwind" |
15 | 15 | ||
16 | # Native builds are not effected by TCLIBC. Without this, rust-native | 16 | # 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): | |||
292 | import json | 292 | import json |
293 | sys = d.getVar('{}_SYS'.format(thing)) | 293 | sys = d.getVar('{}_SYS'.format(thing)) |
294 | prefix = d.getVar('{}_PREFIX'.format(thing)) | 294 | prefix = d.getVar('{}_PREFIX'.format(thing)) |
295 | rustsys = d.getVar('RUST_{}_SYS'.format(thing)) | ||
295 | 296 | ||
296 | abi = None | 297 | abi = None |
297 | cpu = "generic" | 298 | cpu = "generic" |
@@ -318,13 +319,9 @@ def rust_gen_target(d, thing, wd, arch): | |||
318 | features = features or d.getVarFlag('FEATURES', arch_abi) or "" | 319 | features = features or d.getVarFlag('FEATURES', arch_abi) or "" |
319 | features = features.strip() | 320 | features = features.strip() |
320 | 321 | ||
321 | llvm_target = d.getVar('RUST_TARGET_SYS') | ||
322 | if thing == "BUILD": | ||
323 | llvm_target = d.getVar('RUST_HOST_SYS') | ||
324 | |||
325 | # build tspec | 322 | # build tspec |
326 | tspec = {} | 323 | tspec = {} |
327 | tspec['llvm-target'] = llvm_target | 324 | tspec['llvm-target'] = rustsys |
328 | tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) | 325 | tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) |
329 | if tspec['data-layout'] is None: | 326 | if tspec['data-layout'] is None: |
330 | bb.fatal("No rust target defined for %s" % arch_abi) | 327 | bb.fatal("No rust target defined for %s" % arch_abi) |
@@ -358,7 +355,7 @@ def rust_gen_target(d, thing, wd, arch): | |||
358 | tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY") | 355 | tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY") |
359 | 356 | ||
360 | # write out the target spec json file | 357 | # write out the target spec json file |
361 | with open(wd + sys + '.json', 'w') as f: | 358 | with open(wd + rustsys + '.json', 'w') as f: |
362 | json.dump(tspec, f, indent=4) | 359 | json.dump(tspec, f, indent=4) |
363 | 360 | ||
364 | # These are accounted for in tmpdir path names so don't need to be in the task sig | 361 | # 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" | |||
366 | 363 | ||
367 | do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES" | 364 | do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES" |
368 | 365 | ||
369 | RUST_TARGETGENS = "BUILD" | 366 | RUST_TARGETS_DIR = "${WORKDIR}/rust-targets/" |
367 | export RUST_TARGET_PATH = "${RUST_TARGETS_DIR}" | ||
368 | |||
369 | RUST_TARGETGENS = "BUILD HOST TARGET" | ||
370 | 370 | ||
371 | python do_rust_gen_targets () { | 371 | python do_rust_gen_targets () { |
372 | wd = d.getVar('WORKDIR') + '/targets/' | 372 | wd = d.getVar('RUST_TARGETS_DIR') |
373 | # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last | 373 | # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last |
374 | rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH')) | 374 | rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH')) |
375 | if "HOST" in d.getVar("RUST_TARGETGENS"): | 375 | if "HOST" in d.getVar("RUST_TARGETGENS"): |
@@ -379,5 +379,5 @@ python do_rust_gen_targets () { | |||
379 | } | 379 | } |
380 | 380 | ||
381 | addtask rust_gen_targets after do_patch before do_compile | 381 | addtask rust_gen_targets after do_patch before do_compile |
382 | do_rust_gen_targets[dirs] += "${WORKDIR}/targets" | 382 | do_rust_gen_targets[dirs] += "${RUST_TARGETS_DIR}" |
383 | 383 | ||
diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc index 607c51fc3d..978504052b 100644 --- a/meta/recipes-devtools/cargo/cargo.inc +++ b/meta/recipes-devtools/cargo/cargo.inc | |||
@@ -18,6 +18,8 @@ EXCLUDE_FROM_WORLD = "1" | |||
18 | 18 | ||
19 | inherit cargo pkgconfig | 19 | inherit cargo pkgconfig |
20 | 20 | ||
21 | RUST_TARGETGENS = "BUILD HOST TARGET" | ||
22 | |||
21 | do_cargo_setup_snapshot () { | 23 | do_cargo_setup_snapshot () { |
22 | ${WORKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig | 24 | ${WORKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig |
23 | # Need to use uninative's loader if enabled/present since the library paths | 25 | # Need to use uninative's loader if enabled/present since the library paths |
diff --git a/meta/recipes-devtools/rust/libstd-rs.inc b/meta/recipes-devtools/rust/libstd-rs.inc index d49383ced5..1498b88f0e 100644 --- a/meta/recipes-devtools/rust/libstd-rs.inc +++ b/meta/recipes-devtools/rust/libstd-rs.inc | |||
@@ -12,6 +12,9 @@ DEPENDS:append:libc-musl = " libunwind" | |||
12 | DEPENDS:remove:riscv32 = "libunwind" | 12 | DEPENDS:remove:riscv32 = "libunwind" |
13 | DEPENDS:remove:riscv64 = "libunwind" | 13 | DEPENDS:remove:riscv64 = "libunwind" |
14 | 14 | ||
15 | |||
16 | RUST_TARGETGENS = "BUILD HOST TARGET" | ||
17 | |||
15 | # Embed bitcode in order to allow compiling both with and without LTO | 18 | # Embed bitcode in order to allow compiling both with and without LTO |
16 | RUSTFLAGS += "-Cembed-bitcode=yes" | 19 | RUSTFLAGS += "-Cembed-bitcode=yes" |
17 | # Needed so cargo can find libbacktrace | 20 | # Needed so cargo can find libbacktrace |
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc index 7d1f5347ea..172cd22657 100644 --- a/meta/recipes-devtools/rust/rust.inc +++ b/meta/recipes-devtools/rust/rust.inc | |||
@@ -12,9 +12,6 @@ DEPENDS:append:class-native = " rust-llvm-native" | |||
12 | 12 | ||
13 | S = "${RUSTSRC}" | 13 | S = "${RUSTSRC}" |
14 | 14 | ||
15 | # We generate local targets, and need to be able to locate them | ||
16 | export RUST_TARGET_PATH="${WORKDIR}/targets/" | ||
17 | |||
18 | export FORCE_CRATE_HASH="${BB_TASKHASH}" | 15 | export FORCE_CRATE_HASH="${BB_TASKHASH}" |
19 | 16 | ||
20 | RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" | 17 | RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" |
@@ -40,6 +37,8 @@ setup_cargo_environment () { | |||
40 | 37 | ||
41 | inherit rust-target-config | 38 | inherit rust-target-config |
42 | 39 | ||
40 | RUST_TARGETGENS = "BUILD HOST TARGET" | ||
41 | |||
43 | do_rust_setup_snapshot () { | 42 | do_rust_setup_snapshot () { |
44 | for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do | 43 | for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do |
45 | "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig | 44 | "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig |
diff --git a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb index f3bbeb74eb..82b1bf9bce 100644 --- a/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb +++ b/meta/recipes-gnome/librsvg/librsvg_2.54.4.bb | |||
@@ -14,7 +14,7 @@ SECTION = "x11/utils" | |||
14 | DEPENDS = "cairo gdk-pixbuf glib-2.0 libxml2 pango python3-docutils-native" | 14 | DEPENDS = "cairo gdk-pixbuf glib-2.0 libxml2 pango python3-docutils-native" |
15 | BBCLASSEXTEND = "native nativesdk" | 15 | BBCLASSEXTEND = "native nativesdk" |
16 | 16 | ||
17 | inherit gnomebase pixbufcache upstream-version-is-even gobject-introspection rust vala gi-docgen | 17 | inherit cargo_common gnomebase pixbufcache upstream-version-is-even gobject-introspection rust vala gi-docgen |
18 | 18 | ||
19 | SRC_URI += "file://0001-Makefile.am-pass-rust-target-to-cargo-also-when-not-.patch \ | 19 | SRC_URI += "file://0001-Makefile.am-pass-rust-target-to-cargo-also-when-not-.patch \ |
20 | file://0001-system-deps-src-lib.rs-do-not-probe-into-harcoded-li.patch \ | 20 | file://0001-system-deps-src-lib.rs-do-not-probe-into-harcoded-li.patch \ |
@@ -29,7 +29,6 @@ BASEDEPENDS:append = " cargo-native" | |||
29 | 29 | ||
30 | export RUST_BACKTRACE = "full" | 30 | export RUST_BACKTRACE = "full" |
31 | export RUSTFLAGS | 31 | export RUSTFLAGS |
32 | export RUST_TARGET_PATH | ||
33 | 32 | ||
34 | export RUST_TARGET = "${RUST_HOST_SYS}" | 33 | export RUST_TARGET = "${RUST_HOST_SYS}" |
35 | 34 | ||
@@ -38,16 +37,17 @@ RUSTFLAGS:append:mipsel = " --cfg crossbeam_no_atomic_64" | |||
38 | RUSTFLAGS:append:powerpc = " --cfg crossbeam_no_atomic_64" | 37 | RUSTFLAGS:append:powerpc = " --cfg crossbeam_no_atomic_64" |
39 | RUSTFLAGS:append:riscv32 = " --cfg crossbeam_no_atomic_64" | 38 | RUSTFLAGS:append:riscv32 = " --cfg crossbeam_no_atomic_64" |
40 | 39 | ||
40 | CARGO_DISABLE_BITBAKE_VENDORING = "1" | ||
41 | do_configure[postfuncs] += "cargo_common_do_configure" | ||
42 | |||
43 | inherit rust-target-config | ||
44 | |||
41 | # rust-cross writes the target linker binary into target json definition without any flags. | 45 | # rust-cross writes the target linker binary into target json definition without any flags. |
42 | # This breaks here because the linker isn't going to work without at least knowing where | 46 | # This breaks here because the linker isn't going to work without at least knowing where |
43 | # the sysroot is. So copy the json to workdir, and patch in the path to wrapper from rust class | 47 | # the sysroot is. So copy the json to workdir, and patch in the path to wrapper from rust class |
44 | # which supplies the needed flags. | 48 | # which supplies the needed flags. |
45 | do_compile:prepend() { | 49 | do_compile:prepend() { |
46 | cp ${STAGING_LIBDIR_NATIVE}/rustlib/${HOST_SYS}.json ${WORKDIR} | 50 | sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${RUST_TARGETS_DIR}/${RUST_HOST_SYS}.json |
47 | cp ${STAGING_LIBDIR_NATIVE}/rustlib/${BUILD_SYS}.json ${WORKDIR} | ||
48 | sed -ie 's,"linker": ".*","linker": "${RUST_TARGET_CC}",g' ${WORKDIR}/${RUST_HOST_SYS}.json | ||
49 | RUST_TARGET_PATH="${WORKDIR}" | ||
50 | export RUST_TARGET_PATH | ||
51 | } | 51 | } |
52 | 52 | ||
53 | # Issue only on windows | 53 | # Issue only on windows |