Skip to content

Commit 0744c83

Browse files
committed
add uwtable attribute to functions on windows
See #516 now we have at least a callstack. we still need updated LLD to get stack traces.
1 parent 5866032 commit 0744c83

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/codegen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ static LLVMCallConv get_llvm_cc(CodeGen *g, CallingConvention cc) {
388388
zig_unreachable();
389389
}
390390

391+
static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) {
392+
if (g->zig_target.os == ZigLLVM_Win32) {
393+
addLLVMFnAttr(fn_val, "uwtable");
394+
}
395+
}
396+
391397
static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
392398
if (fn_table_entry->llvm_value)
393399
return fn_table_entry->llvm_value;
@@ -476,6 +482,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
476482
}
477483

478484
addLLVMFnAttr(fn_table_entry->llvm_value, "nounwind");
485+
add_uwtable_attr(g, fn_table_entry->llvm_value);
479486
addLLVMFnAttr(fn_table_entry->llvm_value, "nobuiltin");
480487
if (g->build_mode == BuildModeDebug && fn_table_entry->fn_inline != FnInlineAlways) {
481488
ZigLLVMAddFunctionAttr(fn_table_entry->llvm_value, "no-frame-pointer-elim", "true");
@@ -885,6 +892,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
885892
LLVMSetLinkage(fn_val, LLVMInternalLinkage);
886893
LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
887894
addLLVMFnAttr(fn_val, "nounwind");
895+
add_uwtable_attr(g, fn_val);
888896
if (g->build_mode == BuildModeDebug) {
889897
ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim", "true");
890898
ZigLLVMAddFunctionAttr(fn_val, "no-frame-pointer-elim-non-leaf", nullptr);

0 commit comments

Comments
 (0)