diff options
| author | Ralf Jung <post@ralfj.de> | 2020-05-09 13:36:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-09 13:36:32 +0200 |
| commit | ce05553c62689bd58184970cf58e59a663cc4658 (patch) | |
| tree | 836c9cb6fc1b58e02bffab0d1e1ab2b7e0d4a3fe /src/librustc_codegen_llvm | |
| parent | 1704dca270e86f5d33c84e1952897c2c33ad5256 (diff) | |
| parent | 0e7d5be4b808bd7ccb1d45aa8f7e5026a15aee93 (diff) | |
Rollup merge of #71234 - maurer:init-array, r=cuviper
rustllvm: Use .init_array rather than .ctors LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. Fixes: #71233
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/back/write.rs | 8 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm/ffi.rs | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index e261ac65446..dd9ada0b95d 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -165,6 +165,13 @@ pub fn target_machine_factory( let asm_comments = sess.asm_comments(); let relax_elf_relocations = sess.target.target.options.relax_elf_relocations; + + let use_init_array = !sess + .opts + .debugging_opts + .use_ctors_section + .unwrap_or(sess.target.target.options.use_ctors_section); + Arc::new(move || { let tm = unsafe { llvm::LLVMRustCreateTargetMachine( @@ -184,6 +191,7 @@ pub fn target_machine_factory( asm_comments, emit_stack_size_section, relax_elf_relocations, + use_init_array, ) }; diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index 477712f5053..0d466c2cd74 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1956,6 +1956,7 @@ extern "C" { AsmComments: bool, EmitStackSizeSection: bool, RelaxELFRelocations: bool, + UseInitArray: bool, ) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); pub fn LLVMRustAddBuilderLibraryInfo( |
