aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorDavid Gonzalez Martin <davidgm94.work@protonmail.com>2023-04-06 10:16:20 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-04-20 14:46:53 -0700
commitd026202a26e56e7e2ea20ca49509fdcf8b937020 (patch)
tree12f872577f617312e9c6e68e0d53a29f1986d06e /src/codegen/llvm.zig
parentfac120bc3ad58a10ab80952e42becd0084aec059 (diff)
downloadzig-d026202a26e56e7e2ea20ca49509fdcf8b937020.tar.gz
zig-d026202a26e56e7e2ea20ca49509fdcf8b937020.zip
Expose an option for producing 64-bit DWARF format
This commit enables producing 64-bit DWARF format for Zig executables that are produced through the LLVM backend. This is achieved by exposing both command-line flags and CompileStep flags. The production of the 64-bit format only affects binaries that use the DWARF format and it is disabled on MacOS due to it being problematic. This commit, despite generating the interface for the Zig user to be able to tell the compile which format is wanted, is just implemented for the LLVM backend, so clang and the self-hosted backends will need this to be implemented in a future commit. This is an effort to work around #7962, since the emission of the 64-bit format automatically produces 64-bit relocations. Further investigation will be needed to make DWARF 32-bit format to emit bigger relocations when needed and not make the linker angry.
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 47b47cc807..23d9af39e0 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -433,7 +433,14 @@ pub const Object = struct {
if (!options.strip) {
switch (options.target.ofmt) {
.coff => llvm_module.addModuleCodeViewFlag(),
- else => llvm_module.addModuleDebugInfoFlag(),
+ else => {
+ const dwarf_format = options.dwarf_format orelse .dwarf32;
+ const produce_dwarf64 = switch (dwarf_format) {
+ .dwarf32 => false,
+ .dwarf64 => true,
+ };
+ llvm_module.addModuleDebugInfoFlag(produce_dwarf64);
+ },
}
const di_builder = llvm_module.createDIBuilder(true);
opt_di_builder = di_builder;