aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-05-08 22:43:11 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-05-08 22:45:49 -0400
commita7346ea49f4d9b1af2d0babf67354b234a87fe42 (patch)
tree18fe76c5f8958d1cf2533fb5136311d855346f4a /src/codegen.cpp
parent4b9e12be50a8d075d06b127712573b531d068837 (diff)
downloadzig-a7346ea49f4d9b1af2d0babf67354b234a87fe42.tar.gz
zig-a7346ea49f4d9b1af2d0babf67354b234a87fe42.zip
fix build on macOS
Sadly due to a workaround for LLD linker limitations on macOS we cannot put libuserland into an .a file; instead we have to use object files. Again due to linker limitations, bundling compiler_rt.o into another relocatable object also doesn't work. So we're left with disabling stack probing on macOS for the stage1 self-hosted code. These workarounds could all be removed if the macos support in the LLD linker improved, or if Zig project had its own linker that did not have these issues.
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 23d3c5dc5c..d21ada1b23 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -401,7 +401,7 @@ static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) {
static void add_probe_stack_attr(CodeGen *g, LLVMValueRef fn_val) {
// Windows already emits its own stack probes
- if (g->zig_target->os != OsWindows &&
+ if (!g->disable_stack_probing && g->zig_target->os != OsWindows &&
(g->zig_target->arch == ZigLLVM_x86 ||
g->zig_target->arch == ZigLLVM_x86_64)) {
addLLVMFnAttrStr(fn_val, "probe-stack", "__zig_probe_stack");
@@ -7043,6 +7043,11 @@ static void zig_llvm_emit_output(CodeGen *g) {
}
validate_inline_fns(g);
g->link_objects.append(output_path);
+ if (g->bundle_compiler_rt && (g->out_type == OutTypeObj ||
+ (g->out_type == OutTypeLib && !g->is_dynamic)))
+ {
+ zig_link_add_compiler_rt(g);
+ }
break;
case EmitFileTypeAssembly:
@@ -9347,6 +9352,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
cache_bool(ch, g->each_lib_rpath);
cache_bool(ch, g->disable_gen_h);
cache_bool(ch, g->bundle_compiler_rt);
+ cache_bool(ch, g->disable_stack_probing);
cache_bool(ch, want_valgrind_support(g));
cache_bool(ch, g->have_pic);
cache_bool(ch, g->have_dynamic_link);