authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-27 19:25:58-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-05-27 19:25:58-04:00
logf68d8060ec2c65e3062007348c0e331ffbe86f37
tree149eef2c891e592849c1fc52e0ad9a145db35a72
parent6a56091213a48118c8c61c0683466f0ffadf6b55
parentd110818cfe96b8038e02d49122d42070d6059197
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2526 from LemonBoy/arch-format-osx

Build archives using the K_DARWIN format when targeting osx

5 files changed, 4 insertions(+), 21 deletions(-)

CMakeLists.txt-2
...@@ -6714,8 +6714,6 @@ target_link_libraries(zig0 compiler)...@@ -6714,8 +6714,6 @@ target_link_libraries(zig0 compiler)
67146714
6715if(WIN32)6715if(WIN32)
6716 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")6716 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")
6717elseif(APPLE)
6718 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.o")
6719else()6717else()
6720 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")6718 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
6721endif()6719endif()
build.zig+2-10
...@@ -383,17 +383,9 @@ const Context = struct {...@@ -383,17 +383,9 @@ const Context = struct {
383};383};
384384
385fn addLibUserlandStep(b: *Builder) void {385fn addLibUserlandStep(b: *Builder) void {
386 // Sadly macOS requires hacks to work around the buggy MACH-O linker code.386 const artifact = b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
387 const artifact = if (builtin.os == .macosx)
388 b.addObject("userland", "src-self-hosted/stage1.zig")
389 else
390 b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
391 artifact.disable_gen_h = true;387 artifact.disable_gen_h = true;
392 if (builtin.os == .macosx) {388 artifact.bundle_compiler_rt = true;
393 artifact.disable_stack_probing = true;
394 } else {
395 artifact.bundle_compiler_rt = true;
396 }
397 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);389 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
398 artifact.linkSystemLibrary("c");390 artifact.linkSystemLibrary("c");
399 const libuserland_step = b.step("libuserland", "Build the userland compiler library for use in stage1");391 const libuserland_step = b.step("libuserland", "Build the userland compiler library for use in stage1");
src/link.cpp-8
...@@ -776,14 +776,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {...@@ -776,14 +776,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
776}776}
777777
778static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path, OutType child_out_type) {778static Buf *build_a_raw(CodeGen *parent_gen, const char *aname, Buf *full_path, OutType child_out_type) {
779 // The Mach-O LLD code is not well maintained, and trips an assertion
780 // when we link compiler_rt and libc.zig as libraries rather than objects.
781 // Here we workaround this by having compiler_rt and libc.zig be objects.
782 // TODO write our own linker. https://github.com/ziglang/zig/issues/1535
783 if (parent_gen->zig_target->os == OsMacOSX) {
784 child_out_type = OutTypeObj;
785 }
786
787 CodeGen *child_gen = create_child_codegen(parent_gen, full_path, child_out_type,779 CodeGen *child_gen = create_child_codegen(parent_gen, full_path, child_out_type,
788 parent_gen->libc);780 parent_gen->libc);
789 codegen_set_out_name(child_gen, buf_create_from_str(aname));781 codegen_set_out_name(child_gen, buf_create_from_str(aname));
src/os.cpp+1-1
...@@ -1350,7 +1350,7 @@ static void init_rand() {...@@ -1350,7 +1350,7 @@ static void init_rand() {
1350 zig_panic("unable to open /dev/urandom");1350 zig_panic("unable to open /dev/urandom");
1351 }1351 }
1352 char bytes[sizeof(unsigned)];1352 char bytes[sizeof(unsigned)];
1353 size_t amt_read;1353 ssize_t amt_read;
1354 while ((amt_read = read(fd, bytes, sizeof(unsigned))) == -1) {1354 while ((amt_read = read(fd, bytes, sizeof(unsigned))) == -1) {
1355 if (errno == EINTR) continue;1355 if (errno == EINTR) continue;
1356 zig_panic("unable to read /dev/urandom");1356 zig_panic("unable to read /dev/urandom");
src/zig_llvm.cpp+1
...@@ -877,6 +877,7 @@ bool ZigLLVMWriteArchive(const char *archive_name, const char **file_names, size...@@ -877,6 +877,7 @@ bool ZigLLVMWriteArchive(const char *archive_name, const char **file_names, size
877 case ZigLLVM_Linux:877 case ZigLLVM_Linux:
878 kind = object::Archive::K_GNU;878 kind = object::Archive::K_GNU;
879 break;879 break;
880 case ZigLLVM_MacOSX:
880 case ZigLLVM_Darwin:881 case ZigLLVM_Darwin:
881 case ZigLLVM_IOS:882 case ZigLLVM_IOS:
882 kind = object::Archive::K_DARWIN;883 kind = object::Archive::K_DARWIN;