From d026202a26e56e7e2ea20ca49509fdcf8b937020 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Thu, 6 Apr 2023 10:16:20 +0200 Subject: 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. --- src/zig_llvm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/zig_llvm.cpp') diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index a884420422..af53bd1d27 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -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) { -- cgit v1.2.3