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)
67146714
67156715if(WIN32)
67166716 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")
6717elseif(APPLE)
6718 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.o")
67196717else()
67206718 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
67216719endif()
build.zig+2-10
......@@ -383,17 +383,9 @@ const Context = struct {
383383};
384384
385385fn addLibUserlandStep(b: *Builder) void {
386 // Sadly macOS requires hacks to work around the buggy MACH-O linker code.
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");
386 const artifact = b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
391387 artifact.disable_gen_h = true;
392 if (builtin.os == .macosx) {
393 artifact.disable_stack_probing = true;
394 } else {
395 artifact.bundle_compiler_rt = true;
396 }
388 artifact.bundle_compiler_rt = true;
397389 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
398390 artifact.linkSystemLibrary("c");
399391 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) {
776776}
777777
778778static 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
787779 CodeGen *child_gen = create_child_codegen(parent_gen, full_path, child_out_type,
788780 parent_gen->libc);
789781 codegen_set_out_name(child_gen, buf_create_from_str(aname));
src/os.cpp+1-1
......@@ -1350,7 +1350,7 @@ static void init_rand() {
13501350 zig_panic("unable to open /dev/urandom");
13511351 }
13521352 char bytes[sizeof(unsigned)];
1353 size_t amt_read;
1353 ssize_t amt_read;
13541354 while ((amt_read = read(fd, bytes, sizeof(unsigned))) == -1) {
13551355 if (errno == EINTR) continue;
13561356 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
877877 case ZigLLVM_Linux:
878878 kind = object::Archive::K_GNU;
879879 break;
880 case ZigLLVM_MacOSX:
880881 case ZigLLVM_Darwin:
881882 case ZigLLVM_IOS:
882883 kind = object::Archive::K_DARWIN;