Skip to content

Commit

Permalink
add module flag to emit CodeView for COFF object files
Browse files Browse the repository at this point in the history
see #516
  • Loading branch information
andrewrk committed Oct 10, 2017
1 parent 1c28631 commit aa78827
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -189,6 +189,10 @@ make install
./zig build --build-file ../build.zig test
```

#### Windows

See https://github.com/zig-lang/zig/wiki/Building-Zig-on-Windows

### Release / Install Build

Once installed, `ZIG_LIBC_LIB_DIR` and `ZIG_LIBC_INCLUDE_DIR` can be overridden
Expand Down
6 changes: 5 additions & 1 deletion src/codegen.cpp
Expand Up @@ -4992,7 +4992,11 @@ static void init(CodeGen *g) {

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

ZigLLVMAddModuleDebugInfoFlag(g->module);
if (g->zig_target.oformat == ZigLLVM_COFF) {
ZigLLVMAddModuleCodeViewFlag(g->module);
} else {
ZigLLVMAddModuleDebugInfoFlag(g->module);
}

LLVMTargetRef target_ref;
char *err_msg = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions src/zig_llvm.cpp
Expand Up @@ -706,6 +706,10 @@ void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
}

void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {
unwrap(module)->addModuleFlag(Module::Warning, "CodeView", 1);
}

static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
switch (Ordering) {
case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
Expand Down
1 change: 1 addition & 0 deletions src/zig_llvm.hpp
Expand Up @@ -112,6 +112,7 @@ unsigned ZigLLVMTag_DW_structure_type(void);

ZigLLVMDIBuilder *ZigLLVMCreateDIBuilder(LLVMModuleRef module, bool allow_unresolved);
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);

void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column, ZigLLVMDIScope *scope);
void ZigLLVMClearCurrentDebugLocation(LLVMBuilderRef builder);
Expand Down

0 comments on commit aa78827

Please sign in to comment.