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) {...@@ -4488,7 +4488,7 @@ static ZigWindowsSDK *get_windows_sdk(CodeGen *g) {
4488}4488}
44894489
44904490
4491Buf *get_linux_libc_lib_path(const char *o_file) {4491static Buf *get_linux_libc_lib_path(const char *o_file) {
4492 const char *cc_exe = getenv("CC");4492 const char *cc_exe = getenv("CC");
4493 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;4493 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;
4494 ZigList<const char *> args = {};4494 ZigList<const char *> args = {};
...@@ -4514,7 +4514,7 @@ Buf *get_linux_libc_lib_path(const char *o_file) {...@@ -4514,7 +4514,7 @@ Buf *get_linux_libc_lib_path(const char *o_file) {
4514 return result;4514 return result;
4515}4515}
45164516
4517Buf *get_linux_libc_include_path(void) {4517static Buf *get_posix_libc_include_path(void) {
4518 const char *cc_exe = getenv("CC");4518 const char *cc_exe = getenv("CC");
4519 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;4519 cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe;
4520 ZigList<const char *> args = {};4520 ZigList<const char *> args = {};
...@@ -4569,6 +4569,10 @@ Buf *get_linux_libc_include_path(void) {...@@ -4569,6 +4569,10 @@ Buf *get_linux_libc_include_path(void) {
45694569
4570void find_libc_include_path(CodeGen *g) {4570void find_libc_include_path(CodeGen *g) {
4571 if (g->libc_include_dir == nullptr) {4571 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
4573 if (g->zig_target.os == OsWindows) {4577 if (g->zig_target.os == OsWindows) {
4574 ZigWindowsSDK *sdk = get_windows_sdk(g);4578 ZigWindowsSDK *sdk = get_windows_sdk(g);
...@@ -4577,13 +4581,13 @@ void find_libc_include_path(CodeGen *g) {...@@ -4577,13 +4581,13 @@ void find_libc_include_path(CodeGen *g) {
4577 fprintf(stderr, "Unable to determine libc include path. --libc-include-dir");4581 fprintf(stderr, "Unable to determine libc include path. --libc-include-dir");
4578 exit(1);4582 exit(1);
4579 }4583 }
4580 } else if (g->zig_target.os == OsLinux) {4584 } else if (g->zig_target.os == OsLinux || g->zig_target.os == OsMacOSX) {
4581 g->libc_include_dir = get_linux_libc_include_path();4585 g->libc_include_dir = get_posix_libc_include_path();
4582 } else if (g->zig_target.os == OsMacOSX) {
4583 g->libc_include_dir = buf_create_from_str("/usr/include");
4584 } else {4586 } else {
4585 // TODO find libc at runtime for other operating systems4587 fprintf(stderr, "Unable to determine libc include path.\n"
4586 zig_panic("Unable to determine libc include path.");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);
4587 }4591 }
4588 }4592 }
4589 assert(buf_len(g->libc_include_dir) != 0);4593 assert(buf_len(g->libc_include_dir) != 0);