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