diff options
| author | Matthew Maurer <matthew.r.maurer@gmail.com> | 2020-04-16 19:40:11 -0700 |
|---|---|---|
| committer | Matthew Maurer <matthew.r.maurer@gmail.com> | 2020-04-29 13:38:59 -0700 |
| commit | 0e7d5be4b808bd7ccb1d45aa8f7e5026a15aee93 (patch) | |
| tree | f96a66037263baa82b0267d9f450eb09c1799a4f /src/rustllvm/PassWrapper.cpp | |
| parent | 825cf51ad7d2578fcd60a0b7b107d7b0ab3017ff (diff) | |
| download | rust-0e7d5be4b808bd7ccb1d45aa8f7e5026a15aee93.tar.gz rust-0e7d5be4b808bd7ccb1d45aa8f7e5026a15aee93.zip | |
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. To support legacy systems which may use .ctors, targets may now specify that they use .ctors via the use_ctors attribute which defaults to false. For debugging and manual control, -Z use-ctors-section=yes/no will allow manual override. Fixes: #71233
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index e31dd77d8af..0acedc25db8 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -445,7 +445,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( bool Singlethread, bool AsmComments, bool EmitStackSizeSection, - bool RelaxELFRelocations) { + bool RelaxELFRelocations, + bool UseInitArray) { auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc); @@ -471,6 +472,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( Options.MCOptions.PreserveAsmComments = AsmComments; Options.MCOptions.ABIName = ABIStr; Options.RelaxELFRelocations = RelaxELFRelocations; + Options.UseInitArray = UseInitArray; if (TrapUnreachable) { // Tell LLVM to codegen `unreachable` into an explicit trap instruction. |
