summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rust
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:44:20 +0100
commit411304c3e99f6d3320cb307a61b5d03eda9f7b4d (patch)
tree1db37afcd0893f14fb48f7efed7c028f97864867 /meta/recipes-devtools/rust
parentb2ffb96705e9d7bcf268f879c756727e32fb7c88 (diff)
downloadpoky-411304c3e99f6d3320cb307a61b5d03eda9f7b4d.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. (From OE-Core rev: c08c522fc29445aef0c64f0dd8df8a3531c04afa) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/rust')
-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 @@
1SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust" 1SRC_URI += "https://static.rust-lang.org/dist/rustc-${PV}-src.tar.xz;name=rust"
2SRC_URI[rust.sha256sum] = "6c00ef115c894c2645e60b5049a4f5dacf1dc0c993f3074f7ae4fdf4c755dd5e" 2SRC_URI[rust.sha256sum] = "6c00ef115c894c2645e60b5049a4f5dacf1dc0c993f3074f7ae4fdf4c755dd5e"
3 3
4SRC_URI:append:class-target:pn-rust = " file://hardcodepaths.patch"
5SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch"
6
4RUSTSRC = "${WORKDIR}/rustc-${PV}-src" 7RUSTSRC = "${WORKDIR}/rustc-${PV}-src"
5 8
6UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html" 9UPSTREAM_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 @@
1When building for the target, some build paths end up embedded in the binaries.
2These changes remove that. Further investigation is needed to work out the way
3to resolve these issues properly upstream.
4
5Upstream-Status: Inappropriate [patches need rework]
6Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
7
8Index: rustc-1.62.0-src/src/tools/clippy/src/driver.rs
9===================================================================
10--- rustc-1.62.0-src.orig/src/tools/clippy/src/driver.rs
11+++ rustc-1.62.0-src/src/tools/clippy/src/driver.rs
12@@ -255,7 +255,6 @@ pub fn main() {
13 .and_then(|out| String::from_utf8(out.stdout).ok())
14 .map(|s| PathBuf::from(s.trim()))
15 })
16- .or_else(|| option_env!("SYSROOT").map(PathBuf::from))
17 .or_else(|| {
18 let home = option_env!("RUSTUP_HOME")
19 .or(option_env!("MULTIRUST_HOME"))
20Index: rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
21===================================================================
22--- rustc-1.62.0-src.orig/compiler/rustc_codegen_llvm/src/context.rs
23+++ rustc-1.62.0-src/compiler/rustc_codegen_llvm/src/context.rs
24@@ -167,46 +167,6 @@ pub unsafe fn create_module<'ll>(
25 }
26 }
27
28- // Ensure the data-layout values hardcoded remain the defaults.
29- if sess.target.is_builtin {
30- let tm = crate::back::write::create_informational_target_machine(tcx.sess);
31- llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
32- llvm::LLVMRustDisposeTargetMachine(tm);
33-
34- let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
35- let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
36- .expect("got a non-UTF8 data-layout from LLVM");
37-
38- // Unfortunately LLVM target specs change over time, and right now we
39- // don't have proper support to work with any more than one
40- // `data_layout` than the one that is in the rust-lang/rust repo. If
41- // this compiler is configured against a custom LLVM, we may have a
42- // differing data layout, even though we should update our own to use
43- // that one.
44- //
45- // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
46- // disable this check entirely as we may be configured with something
47- // that has a different target layout.
48- //
49- // Unsure if this will actually cause breakage when rustc is configured
50- // as such.
51- //
52- // FIXME(#34960)
53- let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
54- let custom_llvm_used = cfg_llvm_root.trim() != "";
55-
56- if !custom_llvm_used && target_data_layout != llvm_data_layout {
57- bug!(
58- "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
59- differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
60- rustc_target = sess.opts.target_triple,
61- rustc_layout = target_data_layout,
62- llvm_target = sess.target.llvm_target,
63- llvm_layout = llvm_data_layout
64- );
65- }
66- }
67-
68 let data_layout = SmallCStr::new(&target_data_layout);
69 llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
70