Skip to content

Commit f68d806

Browse files
authored
Merge pull request #2526 from LemonBoy/arch-format-osx
Build archives using the K_DARWIN format when targeting osx
2 parents 6a56091 + d110818 commit f68d806

File tree

5 files changed

+4
-21
lines changed

5 files changed

+4
-21
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6714,8 +6714,6 @@ target_link_libraries(zig0 compiler)
67146714

67156715
if(WIN32)
67166716
set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.lib")
6717-
elseif(APPLE)
6718-
set(LIBUSERLAND "${CMAKE_BINARY_DIR}/userland.o")
67196717
else()
67206718
set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
67216719
endif()

build.zig

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,9 @@ const Context = struct {
383383
};
384384

385385
fn 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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -776,14 +776,6 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file) {
776776
}
777777

778778
static 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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

0 commit comments

Comments
 (0)