diff options
| author | David Gonzalez Martin <davidgm94.work@protonmail.com> | 2023-04-06 10:16:20 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-04-20 14:46:53 -0700 |
| commit | d026202a26e56e7e2ea20ca49509fdcf8b937020 (patch) | |
| tree | 12f872577f617312e9c6e68e0d53a29f1986d06e /src/main.zig | |
| parent | fac120bc3ad58a10ab80952e42becd0084aec059 (diff) | |
| download | zig-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/main.zig')
| -rw-r--r-- | src/main.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 2bc4961cba..81a83d580d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -844,6 +844,7 @@ fn buildOutputType( var reference_trace: ?u32 = null; var error_tracing: ?bool = null; var pdb_out_path: ?[]const u8 = null; + var dwarf_format: ?std.dwarf.Format = null; // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names. // This array is populated by zig cc frontend and then has to be converted to zig-style @@ -1355,6 +1356,10 @@ fn buildOutputType( strip = true; } else if (mem.eql(u8, arg, "-fno-strip")) { strip = false; + } else if (mem.eql(u8, arg, "-gdwarf32")) { + dwarf_format = .dwarf32; + } else if (mem.eql(u8, arg, "-gdwarf64")) { + dwarf_format = .dwarf64; } else if (mem.eql(u8, arg, "-fformatted-panics")) { formatted_panics = true; } else if (mem.eql(u8, arg, "-fno-formatted-panics")) { @@ -3145,6 +3150,7 @@ fn buildOutputType( .test_runner_path = test_runner_path, .disable_lld_caching = !output_to_cache, .subsystem = subsystem, + .dwarf_format = dwarf_format, .wasi_exec_model = wasi_exec_model, .debug_compile_errors = debug_compile_errors, .enable_link_snapshots = enable_link_snapshots, |
