blob: 19c494ad9a4f7665399f990784ed3a299f551a39 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001When 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>
Andrew Geissler028142b2023-05-05 11:29:21 -05007Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Andrew Geissler517393d2023-01-13 08:55:19 -06008
Andrew Geissler028142b2023-05-05 11:29:21 -05009--- rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/context.rs.orig 2023-04-21 08:38:23.092458478 +0100
10+++ rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/context.rs 2023-04-21 08:39:00.266819755 +0100
11@@ -156,46 +156,6 @@
Andrew Geissler517393d2023-01-13 08:55:19 -060012 }
13 }
14
15- // Ensure the data-layout values hardcoded remain the defaults.
16- if sess.target.is_builtin {
17- let tm = crate::back::write::create_informational_target_machine(tcx.sess);
18- llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
19- llvm::LLVMRustDisposeTargetMachine(tm);
20-
21- let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
22- let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
23- .expect("got a non-UTF8 data-layout from LLVM");
24-
25- // Unfortunately LLVM target specs change over time, and right now we
26- // don't have proper support to work with any more than one
27- // `data_layout` than the one that is in the rust-lang/rust repo. If
28- // this compiler is configured against a custom LLVM, we may have a
29- // differing data layout, even though we should update our own to use
30- // that one.
31- //
32- // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
33- // disable this check entirely as we may be configured with something
34- // that has a different target layout.
35- //
36- // Unsure if this will actually cause breakage when rustc is configured
37- // as such.
38- //
39- // FIXME(#34960)
40- let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
Andrew Geissler028142b2023-05-05 11:29:21 -050041- let custom_llvm_used = !cfg_llvm_root.trim().is_empty();
Andrew Geissler517393d2023-01-13 08:55:19 -060042-
43- if !custom_llvm_used && target_data_layout != llvm_data_layout {
44- bug!(
45- "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
46- differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
47- rustc_target = sess.opts.target_triple,
48- rustc_layout = target_data_layout,
49- llvm_target = sess.target.llvm_target,
50- llvm_layout = llvm_data_layout
51- );
52- }
53- }
54-
55 let data_layout = SmallCStr::new(&target_data_layout);
56 llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
57