From cf9b21c09fc641b4697e06981ac5114a8d3d09ab Mon Sep 17 00:00:00 2001 From: alter Date: Mon, 12 Sep 2016 01:01:06 -0300 Subject: MacOSX compatibility - Implemented some syscall for MacOSX - tested on : El Capitan 10.11 x86_64 - make self hosted test run on macosx - modified run_test so it does not fail when parseh throws warnings (most of them are related to buildin types from gcc that arent defined in header files and unions) - making -mmacosx-version-min and -mios-version-min works like gcc (command line paramers have precedence over enviroment variables) --- src/codegen.cpp | 9 +++++++-- src/link.cpp | 6 ++++++ src/main.cpp | 12 ++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/codegen.cpp b/src/codegen.cpp index ddf06b7eef..e2dd435598 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -42,9 +42,14 @@ static void init_darwin_native(CodeGen *g) { g->mmacosx_version_min = buf_create_from_str(osx_target); } else if (ios_target) { g->mios_version_min = buf_create_from_str(ios_target); - } else { - zig_panic("unable to determine -mmacosx-version-min or -mios-version-min"); } + + // we should check for the command line option to throw an error if not specified + // + + /* else { + zig_panic("unable to determine -mmacosx-version-min or -mios-version-min"); + } */ } static PackageTableEntry *new_package(const char *root_src_dir, const char *root_src_path) { diff --git a/src/link.cpp b/src/link.cpp index 6b3d3dce83..56a44c4612 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -643,6 +643,12 @@ static void construct_linker_job_darwin(LinkJob *lj) { lj->args.append((const char *)buf_ptr(&lj->out_file_o)); + if (g->is_test_build) { + const char *test_runner_name = g->link_libc ? "test_runner_libc" : "test_runner_nolibc"; + Buf *test_runner_o_path = build_o(g, test_runner_name); + lj->args.append(buf_ptr(test_runner_o_path)); + } + for (int i = 0; i < g->link_libs.length; i += 1) { Buf *link_lib = g->link_libs.at(i); Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib)); diff --git a/src/main.cpp b/src/main.cpp index 5caa37c66a..23fcaafa99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -388,9 +388,21 @@ int main(int argc, char **argv) { fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n"); return EXIT_FAILURE; } + + if((g->zig_target.os == ZigLLVM_Darwin || + g->zig_target.os == ZigLLVM_MacOSX || + g->zig_target.os == ZigLLVM_IOS) && + (!mmacosx_version_min && + !mios_version_min && + !g->mmacosx_version_min && + !g->mios_version_min) && target) { + zig_panic("unable to determine -mmacosx-version-min or -mios-version-min"); + } + if (mmacosx_version_min) { codegen_set_mmacosx_version_min(g, buf_create_from_str(mmacosx_version_min)); } + if (mios_version_min) { codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min)); } -- cgit v1.2.3