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.
This commit is contained in:
Andrew Kelley
2019-05-08 22:43:11 -04:00
parent 4b9e12be50
commit a7346ea49f
7 changed files with 31 additions and 6 deletions

View File

@@ -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);