Commit 266b2de150

LemonBoy <thatlemon@gmail.com>
2019-05-20 23:09:25
Remove macos-specific linking hacks
1 parent f5657b5
Changed files (3)
src/link.cpp
@@ -776,14 +776,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
 }
 
 static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path, OutType child_out_type) {
-    // The Mach-O LLD code is not well maintained, and trips an assertion
-    // when we link compiler_rt and libc.zig as libraries rather than objects.
-    // Here we workaround this by having compiler_rt and libc.zig be objects.
-    // TODO write our own linker. https://github.com/ziglang/zig/issues/1535
-    if (parent_gen->zig_target->os == OsMacOSX) {
-        child_out_type = OutTypeObj;
-    }
-
     CodeGen *child_gen = create_child_codegen(parent_gen, full_path, child_out_type,
             parent_gen->libc);
     codegen_set_out_name(child_gen, buf_create_from_str(aname));
build.zig
@@ -385,17 +385,9 @@ const Context = struct {
 };
 
 fn addLibUserlandStep(b: *Builder) void {
-    // Sadly macOS requires hacks to work around the buggy MACH-O linker code.
-    const artifact = if (builtin.os == .macosx)
-        b.addObject("userland", "src-self-hosted/stage1.zig")
-    else
-        b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
+    const artifact = b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
     artifact.disable_gen_h = true;
-    if (builtin.os == .macosx) {
-        artifact.disable_stack_probing = true;
-    } else {
-        artifact.bundle_compiler_rt = true;
-    }
+    artifact.bundle_compiler_rt = true;
     artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
     artifact.linkSystemLibrary("c");
     const libuserland_step = b.step("libuserland", "Build the userland compiler library for use in stage1");
CMakeLists.txt
@@ -6707,8 +6707,6 @@ target_link_libraries(zig0 compiler)
 
 if(WIN32)
     set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")
-elseif(APPLE)
-    set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.o")
 else()
     set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
 endif()