diff options
| author | David Wood <david.wood@huawei.com> | 2022-11-07 15:15:24 +0000 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-11-08 10:35:53 +0000 |
| commit | 29dc08307dde3051ab6bf17c53f2db99e32681ee (patch) | |
| tree | a5701461b32706897d4155904f70ca882ec0db89 /compiler/rustc_codegen_llvm/src | |
| parent | 9bcc083c873be61e62446d0240a72f99d71350e0 (diff) | |
| download | rust-29dc08307dde3051ab6bf17c53f2db99e32681ee.tar.gz rust-29dc08307dde3051ab6bf17c53f2db99e32681ee.zip | |
llvm: dwo only emitted when object code emitted
`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files). Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/write.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 11053a8f6c4..97d0de47b3a 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -765,11 +765,21 @@ pub(crate) unsafe fn codegen( drop(handlers); } + // `.dwo` files are only emitted if: + // + // - Object files are being emitted (i.e. bitcode only or metadata only compilations will not + // produce dwarf objects, even if otherwise enabled) + // - Target supports Split DWARF + // - Split debuginfo is enabled + // - Split DWARF kind is `split` (i.e. debuginfo is split into `.dwo` files, not different + // sections in the `.o` files). + let dwarf_object_emitted = matches!(config.emit_obj, EmitObj::ObjectCode(_)) + && cgcx.target_can_use_split_dwarf + && cgcx.split_debuginfo != SplitDebuginfo::Off + && cgcx.split_dwarf_kind == SplitDwarfKind::Split; Ok(module.into_compiled_module( config.emit_obj != EmitObj::None, - cgcx.target_can_use_split_dwarf - && cgcx.split_debuginfo != SplitDebuginfo::Off - && cgcx.split_dwarf_kind == SplitDwarfKind::Split, + dwarf_object_emitted, config.emit_bc, &cgcx.output_filenames, )) |
