| ... | ... | @@ -4488,7 +4488,7 @@ static ZigWindowsSDK *get_windows_sdk(CodeGen *g) { |
| 4488 | 4488 | } |
| 4489 | 4489 | |
| 4490 | 4490 | |
| 4491 | | Buf *get_linux_libc_lib_path(const char *o_file) { |
| 4491 | static Buf *get_linux_libc_lib_path(const char *o_file) { |
| 4492 | 4492 | const char *cc_exe = getenv("CC"); |
| 4493 | 4493 | cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe; |
| 4494 | 4494 | ZigList<const char *> args = {}; |
| ... | ... | @@ -4514,7 +4514,7 @@ Buf *get_linux_libc_lib_path(const char *o_file) { |
| 4514 | 4514 | return result; |
| 4515 | 4515 | } |
| 4516 | 4516 | |
| 4517 | | Buf *get_linux_libc_include_path(void) { |
| 4517 | static Buf *get_posix_libc_include_path(void) { |
| 4518 | 4518 | const char *cc_exe = getenv("CC"); |
| 4519 | 4519 | cc_exe = (cc_exe == nullptr) ? "cc" : cc_exe; |
| 4520 | 4520 | ZigList<const char *> args = {}; |
| ... | ... | @@ -4569,6 +4569,10 @@ Buf *get_linux_libc_include_path(void) { |
| 4569 | 4569 | |
| 4570 | 4570 | void find_libc_include_path(CodeGen *g) { |
| 4571 | 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 | } |
| 4572 | 4576 | |
| 4573 | 4577 | if (g->zig_target.os == OsWindows) { |
| 4574 | 4578 | ZigWindowsSDK *sdk = get_windows_sdk(g); |
| ... | ... | @@ -4577,13 +4581,13 @@ void find_libc_include_path(CodeGen *g) { |
| 4577 | 4581 | fprintf(stderr, "Unable to determine libc include path. --libc-include-dir"); |
| 4578 | 4582 | exit(1); |
| 4579 | 4583 | } |
| 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(); |
| 4584 | 4586 | } 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); |
| 4587 | 4591 | } |
| 4588 | 4592 | } |
| 4589 | 4593 | assert(buf_len(g->libc_include_dir) != 0); |