From 8e44c2e8e3a9f27c4661a4414a9d5f7d0959ceab Mon Sep 17 00:00:00 2001 From: Nick Stevens Date: Tue, 13 Feb 2018 15:33:06 -0600 Subject: [PATCH 1/3] Replace SYSROOT_DIRS with SYSROOT_PREPROCESS_FUNCS Prior to Yocto Morty, there was not support for the SYSROOT_DIRS variables in the staging bbclass. Instead, use the more-manual SYSROOT_PREPROCESS_FUNCS functionality Signed-off-by: Nick Stevens --- recipes-devtools/rust/cargo-bin-cross.inc | 12 +++++++----- recipes-devtools/rust/rust-bin-cross.inc | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/recipes-devtools/rust/cargo-bin-cross.inc b/recipes-devtools/rust/cargo-bin-cross.inc index 1b78f32..04ab29f 100644 --- a/recipes-devtools/rust/cargo-bin-cross.inc +++ b/recipes-devtools/rust/cargo-bin-cross.inc @@ -10,11 +10,13 @@ PN = "cargo-bin-cross-${TARGET_ARCH}" CARGO_HOST_TARGET = "${@rust_target(d, 'HOST')}" -SYSROOT_DIRS_NATIVE += "${prefix}" -SYSROOT_DIRS_BLACKLIST += "\ - ${prefix}/share \ - ${prefix}/etc \ -" +SYSROOT_PREPROCESS_FUNCS = "cargo_process_sysroot" +cargo_process_sysroot() { + sysroot_stage_dir ${D}${prefix}/bin ${SYSROOT_DESTDIR}${prefix}/bin + sysroot_stage_dir ${D}${prefix}/lib ${SYSROOT_DESTDIR}${prefix}/lib + rm -rf ${SYSROOT_DESTDIR}${prefix}/share + rm -rf ${SYSROOT_DESTDIR}${prefix}/etc +} # Stripping fails because of mixed arch types (host and target) INHIBIT_PACKAGE_STRIP = "1" diff --git a/recipes-devtools/rust/rust-bin-cross.inc b/recipes-devtools/rust/rust-bin-cross.inc index df606e0..4507789 100644 --- a/recipes-devtools/rust/rust-bin-cross.inc +++ b/recipes-devtools/rust/rust-bin-cross.inc @@ -22,11 +22,13 @@ RUST_ALL_TARGETS = "${RUST_BUILD_TARGET} ${RUST_TARGET_TARGET} ${EXTRA_RUST_TARG S = "${WORKDIR}/rustc-${PV}-${RUST_BUILD_TARGET}" -SYSROOT_DIRS_NATIVE += "${prefix}" -SYSROOT_DIRS_BLACKLIST += "\ - ${prefix}/share \ - ${prefix}/etc \ -" +SYSROOT_PREPROCESS_FUNCS = "rust_process_sysroot" +rust_process_sysroot() { + sysroot_stage_dir ${D}${prefix}/bin ${SYSROOT_DESTDIR}${prefix}/bin + sysroot_stage_dir ${D}${prefix}/lib ${SYSROOT_DESTDIR}${prefix}/lib + rm -rf ${SYSROOT_DESTDIR}${prefix}/share + rm -rf ${SYSROOT_DESTDIR}${prefix}/etc +} # Stripping fails because of mixed arch types (host and target) INHIBIT_PACKAGE_STRIP = "1" From bba6cb17c92f7e8ef2642a5258ec05c1da0d0c02 Mon Sep 17 00:00:00 2001 From: Nick Stevens Date: Wed, 14 Feb 2018 10:36:55 -0600 Subject: [PATCH 2/3] Add missing vardeps on *_OS and *_ARCH In the `rust_target` function, we dynamically construct lookups for BUILD_OS, TARGET_OS, BUILD_ARCH, TARGET_ARCH, etc. As a result Bitbake is not able to automatically dertermine our reliance on these variables when generating the sstate cache. This commit manually adds vardeps onto those variables. Signed-off-by: Nick Stevens (cherry picked from commit bbc889dc9b02b9d97b362eca063912227b071aa8) --- classes/rust-common.bbclass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/rust-common.bbclass b/classes/rust-common.bbclass index 45bb06a..b30ea5e 100644 --- a/classes/rust-common.bbclass +++ b/classes/rust-common.bbclass @@ -8,6 +8,10 @@ def rust_target(d, spec_type): arch = d.getVar('%s_ARCH' % spec_type, True) os = d.getVar('%s_OS' % spec_type, True) + # Make sure that tasks properly recalculate after ARCH or OS change + d.appendVarFlag("rust_target", "vardeps", " %s_ARCH" % spec_type) + d.appendVarFlag("rust_target", "vardeps", " %s_OS" % spec_type) + # Sometimes bitbake mixes the calling convention into the OS, sometimes it # doesn't... let's just take the first part os = os.split('-')[0] From 2c714ecaa7207fd27875d63e76177ee8fa95de12 Mon Sep 17 00:00:00 2001 From: Nick Stevens Date: Wed, 14 Feb 2018 10:41:17 -0600 Subject: [PATCH 3/3] Exclude WORKDIR from recipe stamps, allowing caching During install of rust-bin and cargo-bin binaries are placed into ${S}, which itself builds on ${WORKDIR}. Normally ${WORKDIR} is ignored for sstate cache but it is not being ignored properly in rust-bin and cargo-bin for two different reasons: In rust-bin, a dependency is being created on the value of ${S} instead of creating a transitive dependency on ${S} -> ${WORKDIR} and then ignoring ${WORKDIR}. It's not clear why exactly this is the case, but it was confirmed by looking at the output of the stamps for the rust-bin recipe. The fix is to explicitly exclude ${WORKDIR} from the creation of ${S} with a `vardepsexclude` In cargo-bin the issue is more straight-forward: the ${S} value was being explicitly assembled in Python code, so Bitbake never sees that ${S} is formed from ${WORKDIR}. Adding explicit `vardeps` and `vardepsexcludes` in the Python section fixes this. Signed-off-by: Nick Stevens (cherry picked from commit 30ff1e7384a16c4286ec44447f44a3ad9dacfc93) --- recipes-devtools/rust/cargo-bin-cross.inc | 5 ++++- recipes-devtools/rust/rust-bin-cross.inc | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/recipes-devtools/rust/cargo-bin-cross.inc b/recipes-devtools/rust/cargo-bin-cross.inc index 04ab29f..1f74d17 100644 --- a/recipes-devtools/rust/cargo-bin-cross.inc +++ b/recipes-devtools/rust/cargo-bin-cross.inc @@ -38,6 +38,9 @@ python () { (cargo_url(target), cargo_md5(target), cargo_sha256(target), d.getVar("PN", True) + "-" + pv + "-" + target + ".tar.gz")) src_uri = d.getVar("SRC_URI", True).split() + cargo_extract_path = cargo_url(target).split('/')[-1].replace('.tar.gz', '') d.setVar("SRC_URI", ' '.join(src_uri + [cargo_uri])) - d.setVar("S", "{}/{}".format(d.getVar("WORKDIR", True), cargo_url(target).split('/')[-1].replace('.tar.gz', ''))) + d.setVar("S", "${{WORKDIR}}/{}".format(cargo_extract_path)) + d.appendVarFlag("S", "vardeps", " cargo_url") + d.appendVarFlag("S", "vardepsexclude", " WORKDIR") } diff --git a/recipes-devtools/rust/rust-bin-cross.inc b/recipes-devtools/rust/rust-bin-cross.inc index 4507789..f6b749b 100644 --- a/recipes-devtools/rust/rust-bin-cross.inc +++ b/recipes-devtools/rust/rust-bin-cross.inc @@ -22,6 +22,9 @@ RUST_ALL_TARGETS = "${RUST_BUILD_TARGET} ${RUST_TARGET_TARGET} ${EXTRA_RUST_TARG S = "${WORKDIR}/rustc-${PV}-${RUST_BUILD_TARGET}" +# Relocating WORKDIR doesn't matter to installer +S[vardepsexclude] += "WORKDIR" + SYSROOT_PREPROCESS_FUNCS = "rust_process_sysroot" rust_process_sysroot() { sysroot_stage_dir ${D}${prefix}/bin ${SYSROOT_DESTDIR}${prefix}/bin