diff options
| author | Guillaume Boisseau <Nadrieril@users.noreply.github.com> | 2024-02-07 18:24:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-07 18:24:41 +0100 |
| commit | 7954c28cf932c00cd331598f189145861bf42b7c (patch) | |
| tree | df496eace289812572b543e7263dd971237b5a53 /compiler/rustc_codegen_llvm/src | |
| parent | 6931780f40c92291eaceec42f09069515390bb17 (diff) | |
| parent | 06a41687b160cbb4cbf8fce0b3ad3a2e352e8338 (diff) | |
| download | rust-7954c28cf932c00cd331598f189145861bf42b7c.tar.gz rust-7954c28cf932c00cd331598f189145861bf42b7c.zip | |
Rollup merge of #119162 - heiher:direct-access-external-data, r=petrochenkov
Add unstable `-Z direct-access-external-data` cmdline flag for `rustc` The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707 Fixes #118053
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/mono_item.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index f796ce0990f..f7630719368 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -123,6 +123,17 @@ impl CodegenCx<'_, '_> { return false; } + // Match clang by only supporting COFF and ELF for now. + if self.tcx.sess.target.is_like_osx { + return false; + } + + // With pie relocation model calls of functions defined in the translation + // unit can use copy relocations. + if self.tcx.sess.relocation_model() == RelocModel::Pie && !is_declaration { + return true; + } + // Thread-local variables generally don't support copy relocations. let is_thread_local_var = llvm::LLVMIsAGlobalVariable(llval) .is_some_and(|v| llvm::LLVMIsThreadLocal(v) == llvm::True); @@ -130,18 +141,12 @@ impl CodegenCx<'_, '_> { return false; } - // Match clang by only supporting COFF and ELF for now. - if self.tcx.sess.target.is_like_osx { - return false; + // Respect the direct-access-external-data to override default behavior if present. + if let Some(direct) = self.tcx.sess.direct_access_external_data() { + return direct; } // Static relocation model should force copy relocations everywhere. - if self.tcx.sess.relocation_model() == RelocModel::Static { - return true; - } - - // With pie relocation model calls of functions defined in the translation - // unit can use copy relocations. - self.tcx.sess.relocation_model() == RelocModel::Pie && !is_declaration + self.tcx.sess.relocation_model() == RelocModel::Static } } |
