authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-06 17:21:47-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-06 17:59:44-05:00
logd9fe38789b2a4e8376b71d839181d9c28d098164
tree3002aeed920df99b3440a9d32f0f3ddd9dff5ef2
parent63f636e7b775bc8d2881104248f9579a089c4240

macos: use the same code as linux to determine libc include path

this fixes .h file locating on macos 10.14

1 files changed, 12 insertions(+), 8 deletions(-)

src/analyze.cpp+12-8
......@@ -4488,7 +4488,7 @@ static ZigWindowsSDK *get_windows_sdk(CodeGen *g) {
44884488}
44894489
44904490
4491Buf *get_linux_libc_lib_path(const char *o_file) {
4491static Buf *get_linux_libc_lib_path(const char *o_file) {
44924492 const char *cc_exe = getenv("CC");
44934493 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;
44944494 ZigList<const char *> args = {};
......@@ -4514,7 +4514,7 @@ Buf *get_linux_libc_lib_path(const char *o_file) {
45144514 return result;
45154515}
45164516
4517Buf *get_linux_libc_include_path(void) {
4517static Buf *get_posix_libc_include_path(void) {
45184518 const char *cc_exe = getenv("CC");
45194519 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;
45204520 ZigList<const char *> args = {};
......@@ -4569,6 +4569,10 @@ Buf *get_linux_libc_include_path(void) {
45694569
45704570void find_libc_include_path(CodeGen *g) {
45714571 if (g->libc_include_dir == nullptr) {
4572 if (!g->is_native_target) {
4573 fprintf(stderr, "Unable to determine libc include path. --libc-include-dir");
4574 exit(1);
4575 }
45724576
45734577 if (g->zig_target.os == OsWindows) {
45744578 ZigWindowsSDK *sdk = get_windows_sdk(g);
......@@ -4577,13 +4581,13 @@ void find_libc_include_path(CodeGen *g) {
45774581 fprintf(stderr, "Unable to determine libc include path. --libc-include-dir");
45784582 exit(1);
45794583 }
4580 } else if (g->zig_target.os == OsLinux) {
4581 g->libc_include_dir = get_linux_libc_include_path();
4582 } else if (g->zig_target.os == OsMacOSX) {
4583 g->libc_include_dir = buf_create_from_str("/usr/include");
4584 } else if (g->zig_target.os == OsLinux || g->zig_target.os == OsMacOSX) {
4585 g->libc_include_dir = get_posix_libc_include_path();
45844586 } else {
4585 // TODO find libc at runtime for other operating systems
4586 zig_panic("Unable to determine libc include path.");
4587 fprintf(stderr, "Unable to determine libc include path.\n"
4588 "TODO: implement finding libc at runtime for other operating systems.\n"
4589 "in the meantime, you can use as a workaround: --libc-include-dir\n");
4590 exit(1);
45874591 }
45884592 }
45894593 assert(buf_len(g->libc_include_dir) != 0);