Skip to content

Commit aa78827

Browse files
committed
add module flag to emit CodeView for COFF object files
see #516
1 parent 1c28631 commit aa78827

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ make install
189189
./zig build --build-file ../build.zig test
190190
```
191191

192+
#### Windows
193+
194+
See https://github.com/zig-lang/zig/wiki/Building-Zig-on-Windows
195+
192196
### Release / Install Build
193197

194198
Once installed, `ZIG_LIBC_LIB_DIR` and `ZIG_LIBC_INCLUDE_DIR` can be overridden

src/codegen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4992,7 +4992,11 @@ static void init(CodeGen *g) {
49924992

49934993
LLVMSetTarget(g->module, buf_ptr(&g->triple_str));
49944994

4995-
ZigLLVMAddModuleDebugInfoFlag(g->module);
4995+
if (g->zig_target.oformat == ZigLLVM_COFF) {
4996+
ZigLLVMAddModuleCodeViewFlag(g->module);
4997+
} else {
4998+
ZigLLVMAddModuleDebugInfoFlag(g->module);
4999+
}
49965000

49975001
LLVMTargetRef target_ref;
49985002
char *err_msg = nullptr;

src/zig_llvm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {
706706
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
707707
}
708708

709+
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {
710+
unwrap(module)->addModuleFlag(Module::Warning, "CodeView", 1);
711+
}
712+
709713
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
710714
switch (Ordering) {
711715
case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;

src/zig_llvm.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ unsigned ZigLLVMTag_DW_structure_type(void);
112112

113113
ZigLLVMDIBuilder *ZigLLVMCreateDIBuilder(LLVMModuleRef module, bool allow_unresolved);
114114
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);
115+
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);
115116

116117
void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column, ZigLLVMDIScope *scope);
117118
void ZigLLVMClearCurrentDebugLocation(LLVMBuilderRef builder);

0 commit comments

Comments
 (0)