summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-03 15:10:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-08 15:41:36 +0100
commitc08c522fc29445aef0c64f0dd8df8a3531c04afa (patch)
tree1a9e7287bed0f86704a996e2283403dc7d7df08d /meta
parentdfff5a176765c0e8b212bf31081f80e79025fd1b (diff)
downloadopenembedded-core-contrib-c08c522fc29445aef0c64f0dd8df8a3531c04afa.tar.gz
rust: Work around reproducibility issues
Add a patch which removes the sections of code which encode buildpaths. Whilst not ideal, the patches at least show where the problematic data is coming from and should allow more focused work to resovle it by someone who has a better understanding of rust and what this code is doing. It does look unlikely we actually need this code in our usecases anyway. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/rust/rust-source.inc3
-rw-r--r--meta/recipes-devtools/rust/rust/hardcodepaths.patch70
2 files changed, 73 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index fda26534e8..b814574e55 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -1,6 +1,9 @@
SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust"
SRC_URI[rust.sha256sum] = "6c00ef115c894c2645e60b5049a4f5dacf1dc0c993f3074f7ae4fdf4c755dd5e"
+SRC_URI:append:class-target:pn-rust = " file://hardcodepaths.patch"
+SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch"
+
RUSTSRC = "${WORKDIR}/rustc-${PV}-src"
UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html"
diff --git a/meta/recipes-devtools/rust/rust/hardcodepaths.patch b/meta/recipes-devtools/rust/rust/hardcodepaths.patch
new file mode 100644
index 0000000000..2fdfe6d463
--- /dev/null
+++ b/meta/recipes-devtools/rust/rust/hardcodepaths.patch
@@ -0,0 +1,70 @@
+When building for the target, some build paths end up embedded in the binaries.
+These changes remove that. Further investigation is needed to work out the way
+to resolve these issues properly upstream.
+
+Upstream-Status: Inappropriate [patches need rework]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+Index: rustc-1.62.0-src/src/tools/clippy/src/driver.rs
+===================================================================
+--- rustc-1.62.0-src.orig/src/tools/clippy/src/driver.rs
++++ rustc-1.62.0-src/src/tools/clippy/src/driver.rs
+@@ -255,7 +255,6 @@ pub fn main() {
+ .and_then(|out| String::from_utf8(out.stdout).ok())
+ .map(|s| PathBuf::from(s.trim()))
+ })
+- .or_else(|| option_env!("SYSROOT").map(PathBuf::from))
+ .or_else(|| {
+ let home = option_env!("RUSTUP_HOME")
+ .or(option_env!("MULTIRUST_HOME"))
+Index: rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
+===================================================================
+--- rustc-1.62.0-src.orig/compiler/rustc_codegen_llvm/src/context.rs
++++ rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
+@@ -167,46 +167,6 @@ pub unsafe fn create_module<'ll>(
+ }
+ }
+
+- // Ensure the data-layout values hardcoded remain the defaults.
+- if sess.target.is_builtin {
+- let tm = crate::back::write::create_informational_target_machine(tcx.sess);
+- llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
+- llvm::LLVMRustDisposeTargetMachine(tm);
+-
+- let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
+- let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
+- .expect("got a non-UTF8 data-layout from LLVM");
+-
+- // Unfortunately LLVM target specs change over time, and right now we
+- // don't have proper support to work with any more than one
+- // `data_layout` than the one that is in the rust-lang/rust repo. If
+- // this compiler is configured against a custom LLVM, we may have a
+- // differing data layout, even though we should update our own to use
+- // that one.
+- //
+- // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
+- // disable this check entirely as we may be configured with something
+- // that has a different target layout.
+- //
+- // Unsure if this will actually cause breakage when rustc is configured
+- // as such.
+- //
+- // FIXME(#34960)
+- let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
+- let custom_llvm_used = cfg_llvm_root.trim() != "";
+-
+- if !custom_llvm_used && target_data_layout != llvm_data_layout {
+- bug!(
+- "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
+- differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
+- rustc_target = sess.opts.target_triple,
+- rustc_layout = target_data_layout,
+- llvm_target = sess.target.llvm_target,
+- llvm_layout = llvm_data_layout
+- );
+- }
+- }
+-
+ let data_layout = SmallCStr::new(&target_data_layout);
+ llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
+