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.
This commit is contained in:
David Gonzalez Martin
2023-04-06 10:16:20 +02:00
committed by Andrew Kelley
parent fac120bc3a
commit d026202a26
9 changed files with 39 additions and 4 deletions

View File

@@ -1163,9 +1163,13 @@ void ZigLLVMGetNativeTarget(ZigLLVM_ArchType *arch_type,
free(native_triple);
}
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module, bool produce_dwarf64) {
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4);
if (produce_dwarf64) {
unwrap(module)->addModuleFlag(Module::Warning, "DWARF64", 1);
}
}
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {