aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-09-13 14:11:00 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-09-13 14:11:00 -0400
commit187a6d198fd06dfedbb121aa5a79791b34b24794 (patch)
tree774caf931a1c0b89698a5ef37dbb1912247182ee /src
parenteb7d36ae0d240b8ef5421703e613d164cf691d8d (diff)
parentc15e464320ebb8c64ae19005e44ba5cb711f83c6 (diff)
downloadzig-187a6d198fd06dfedbb121aa5a79791b34b24794.tar.gz
zig-187a6d198fd06dfedbb121aa5a79791b34b24794.zip
Merge branch 'nrdmn-uefi'
closes #2944
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cpp14
-rw-r--r--src/target.cpp6
2 files changed, 11 insertions, 9 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 200589cd2a..b720b84ec6 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -516,7 +516,9 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
}
}
if (g->have_stack_probing && !fn->def_scope->safety_off) {
- addLLVMFnAttrStr(llvm_fn, "probe-stack", "__zig_probe_stack");
+ addLLVMFnAttrStr(fn->llvm_value, "probe-stack", "__zig_probe_stack");
+ } else {
+ addLLVMFnAttrStr(fn->llvm_value, "no-stack-arg-probe", "");
}
} else {
maybe_import_dll(g, llvm_fn, linkage);
@@ -9081,10 +9083,6 @@ static bool want_startup_code(CodeGen *g) {
if (g->is_test_build)
return false;
- // start code does not handle UEFI target
- if (g->zig_target->os == OsUefi)
- return false;
-
// WASM freestanding can still have an entry point but other freestanding targets do not.
if (g->zig_target->os == OsFreestanding && !target_is_wasm(g->zig_target))
return false;
@@ -9094,8 +9092,12 @@ static bool want_startup_code(CodeGen *g) {
return false;
// If there is a pub main in the root source file, that means we need start code.
- if (g->have_pub_main)
+ if (g->have_pub_main) {
return true;
+ } else {
+ if (g->zig_target->os == OsUefi)
+ return false;
+ }
if (g->out_type == OutTypeExe) {
// For build-exe, we might add start code even though there is no pub main, so that the
diff --git a/src/target.cpp b/src/target.cpp
index b87ecbe256..5376686548 100644
--- a/src/target.cpp
+++ b/src/target.cpp
@@ -1110,7 +1110,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
}
bool target_allows_addr_zero(const ZigTarget *target) {
- return target->os == OsFreestanding;
+ return target->os == OsFreestanding || target->os == OsUefi;
}
const char *target_o_file_ext(const ZigTarget *target) {
@@ -1535,12 +1535,12 @@ bool target_supports_fpic(const ZigTarget *target) {
}
bool target_supports_stack_probing(const ZigTarget *target) {
- return target->os != OsWindows && (target->arch == ZigLLVM_x86 || target->arch == ZigLLVM_x86_64);
+ return target->os != OsWindows && target->os != OsUefi && (target->arch == ZigLLVM_x86 || target->arch == ZigLLVM_x86_64);
}
bool target_requires_pic(const ZigTarget *target, bool linking_libc) {
// This function returns whether non-pic code is completely invalid on the given target.
- return target->os == OsWindows || target_os_requires_libc(target->os) ||
+ return target->os == OsWindows || target->os == OsUefi || target_os_requires_libc(target->os) ||
(linking_libc && target_is_glibc(target));
}