Patrick Williams | 169d7bc | 2024-01-05 11:33:25 -0600 | [diff] [blame^] | 1 | When building for the target, some build paths end up embedded in the binaries. |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 2 | These changes remove that. Further investigation is needed to work out the way |
| 3 | to resolve these issues properly upstream. |
| 4 | |
| 5 | Upstream-Status: Inappropriate [patches need rework] |
| 6 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 7 | Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 8 | |
Patrick Williams | 169d7bc | 2024-01-05 11:33:25 -0600 | [diff] [blame^] | 9 | diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs |
| 10 | index 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 Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 14 | } |
| 15 | } |
| 16 | |
| 17 | - // Ensure the data-layout values hardcoded remain the defaults. |
| 18 | - if sess.target.is_builtin { |
Patrick Williams | 169d7bc | 2024-01-05 11:33:25 -0600 | [diff] [blame^] | 19 | - // tm is disposed by its drop impl |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 20 | - let tm = crate::back::write::create_informational_target_machine(tcx.sess); |
Patrick Williams | 169d7bc | 2024-01-05 11:33:25 -0600 | [diff] [blame^] | 21 | - llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, &tm); |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 22 | - |
| 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 Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 43 | - let custom_llvm_used = !cfg_llvm_root.trim().is_empty(); |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 44 | - |
| 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 | |