From 1554dd9697b77b4fe4a309247982c3e29048f124 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 2 Nov 2018 00:07:43 -0400 Subject: support building static self hosted compiler on macos * add a --system-linker-hack command line parameter to work around poor LLD macho code. See #1535 * build.zig correctly handles static as well as dynamic dependencies when building the self hosted compiler. - no more unnecessary libxml2 dependency - a static build on macos produces a completely static self-hosted compiler for macos (except for libSystem as intended). --- src/link.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/link.cpp') diff --git a/src/link.cpp b/src/link.cpp index 424b06169e..0e729fa918 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -778,7 +778,8 @@ static bool darwin_version_lt(DarwinPlatform *platform, int major, int minor) { static void construct_linker_job_macho(LinkJob *lj) { CodeGen *g = lj->codegen; - lj->args.append("-error-limit=0"); + // LLD MACH-O has no error limit option. + //lj->args.append("-error-limit=0"); lj->args.append("-demangle"); if (g->linker_rdynamic) { @@ -1007,7 +1008,17 @@ void codegen_link(CodeGen *g) { Buf diag = BUF_INIT; codegen_add_time_event(g, "LLVM Link"); - if (!zig_lld_link(g->zig_target.oformat, lj.args.items, lj.args.length, &diag)) { + if (g->system_linker_hack && g->zig_target.os == OsMacOSX) { + Termination term; + ZigList args = {}; + for (size_t i = 1; i < lj.args.length; i += 1) { + args.append(lj.args.at(i)); + } + os_spawn_process("ld", args, &term); + if (term.how != TerminationIdClean || term.code != 0) { + exit(1); + } + } else if (!zig_lld_link(g->zig_target.oformat, lj.args.items, lj.args.length, &diag)) { fprintf(stderr, "%s\n", buf_ptr(&diag)); exit(1); } -- cgit v1.2.3