blob: a043095f624717274a9af008fdf74576a512aa6b [file] [log] [blame]
Patrick Williams169d7bc2024-01-05 11:33:25 -06001When building for the target, some build paths end up embedded in the binaries.
Andrew Geissler517393d2023-01-13 08:55:19 -06002These 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
Patrick Williams169d7bc2024-01-05 11:33:25 -06009diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
10index b4b2ab1e1f8a..8bb3e3f0557c 100644
11--- a/compiler/rustc_codegen_llvm/src/context.rs
12+++ b/compiler/rustc_codegen_llvm/src/context.rs
13@@ -158,46 +158,6 @@ pub unsafe fn create_module<'ll>(
Andrew Geissler517393d2023-01-13 08:55:19 -060014 }
15 }
16
17- // Ensure the data-layout values hardcoded remain the defaults.
18- if sess.target.is_builtin {
Patrick Williams169d7bc2024-01-05 11:33:25 -060019- // tm is disposed by its drop impl
Andrew Geissler517393d2023-01-13 08:55:19 -060020- let tm = crate::back::write::create_informational_target_machine(tcx.sess);
Patrick Williams169d7bc2024-01-05 11:33:25 -060021- llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, &tm);
Andrew Geissler517393d2023-01-13 08:55:19 -060022-
23- let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
24- let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
25- .expect("got a non-UTF8 data-layout from LLVM");
26-
27- // Unfortunately LLVM target specs change over time, and right now we
28- // don't have proper support to work with any more than one
29- // `data_layout` than the one that is in the rust-lang/rust repo. If
30- // this compiler is configured against a custom LLVM, we may have a
31- // differing data layout, even though we should update our own to use
32- // that one.
33- //
34- // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
35- // disable this check entirely as we may be configured with something
36- // that has a different target layout.
37- //
38- // Unsure if this will actually cause breakage when rustc is configured
39- // as such.
40- //
41- // FIXME(#34960)
42- let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
Andrew Geissler028142b2023-05-05 11:29:21 -050043- let custom_llvm_used = !cfg_llvm_root.trim().is_empty();
Andrew Geissler517393d2023-01-13 08:55:19 -060044-
45- if !custom_llvm_used && target_data_layout != llvm_data_layout {
46- bug!(
47- "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
48- differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
49- rustc_target = sess.opts.target_triple,
50- rustc_layout = target_data_layout,
51- llvm_target = sess.target.llvm_target,
52- llvm_layout = llvm_data_layout
53- );
54- }
55- }
56-
57 let data_layout = SmallCStr::new(&target_data_layout);
58 llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
59