diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-23 09:35:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-23 09:35:56 -0500 |
| commit | 6fd8d455bcc6765e7411fa00d23dca1eb270aac9 (patch) | |
| tree | 047a654678400140fd46ffa64d7c4248050247cd /src/os.cpp | |
| parent | 52bb71867d8d6e738eefb7dafead875eb21a4ae7 (diff) | |
| download | zig-6fd8d455bcc6765e7411fa00d23dca1eb270aac9.tar.gz zig-6fd8d455bcc6765e7411fa00d23dca1eb270aac9.zip | |
better libc detection (#1996)
* better libc detection
This introduces a new command `zig libc` which prints
the various paths of libc files. It outputs them to stdout
in a simple text file format that it is capable of parsing.
You can use `zig libc libc.txt` to validate a file.
These arguments are gone:
--libc-lib-dir [path] directory where libc crt1.o resides
--libc-static-lib-dir [path] directory where libc crtbegin.o resides
--msvc-lib-dir [path] (windows) directory where vcruntime.lib resides
--kernel32-lib-dir [path] (windows) directory where kernel32.lib resides
Instead we have this argument:
--libc [file] Provide a file which specifies libc paths
This is used to pass a libc text file (which can be generated with
`zig libc`). So it is easier to manage multiple cross compilation
environments.
`--cache on` now works when linking against libc.
`ZigTarget` now has a bool field `is_native`
Better error messaging when you try to link against libc or use
`@cImport` but the various paths cannot be found. It should also be
faster.
* save native_libc.txt in zig-cache
This avoids having to detect libc at runtime on every invocation.
Diffstat (limited to 'src/os.cpp')
| -rw-r--r-- | src/os.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/os.cpp b/src/os.cpp index c11840b1cf..95febca9bc 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -1550,7 +1550,7 @@ void os_stderr_set_color(TermColor color) { #endif } -int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) { +Error os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) { #if defined(ZIG_OS_WINDOWS) buf_resize(output_buf, 0); buf_appendf(output_buf, "%s\\Lib\\%s\\ucrt\\", sdk->path10_ptr, sdk->version10_ptr); @@ -1571,7 +1571,7 @@ int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_Arch buf_init_from_buf(tmp_buf, output_buf); buf_append_str(tmp_buf, "ucrt.lib"); if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) { - return 0; + return ErrorNone; } else { buf_resize(output_buf, 0); @@ -1582,12 +1582,12 @@ int os_get_win32_ucrt_lib_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_Arch #endif } -int os_get_win32_ucrt_include_path(ZigWindowsSDK *sdk, Buf* output_buf) { +Error os_get_win32_ucrt_include_path(ZigWindowsSDK *sdk, Buf* output_buf) { #if defined(ZIG_OS_WINDOWS) buf_resize(output_buf, 0); buf_appendf(output_buf, "%s\\Include\\%s\\ucrt", sdk->path10_ptr, sdk->version10_ptr); if (GetFileAttributesA(buf_ptr(output_buf)) != INVALID_FILE_ATTRIBUTES) { - return 0; + return ErrorNone; } else { buf_resize(output_buf, 0); @@ -1598,7 +1598,7 @@ int os_get_win32_ucrt_include_path(ZigWindowsSDK *sdk, Buf* output_buf) { #endif } -int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) { +Error os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchType platform_type) { #if defined(ZIG_OS_WINDOWS) { buf_resize(output_buf, 0); @@ -1620,7 +1620,7 @@ int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchTy buf_init_from_buf(tmp_buf, output_buf); buf_append_str(tmp_buf, "kernel32.lib"); if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) { - return 0; + return ErrorNone; } } { @@ -1643,7 +1643,7 @@ int os_get_win32_kern32_path(ZigWindowsSDK *sdk, Buf* output_buf, ZigLLVM_ArchTy buf_init_from_buf(tmp_buf, output_buf); buf_append_str(tmp_buf, "kernel32.lib"); if (GetFileAttributesA(buf_ptr(tmp_buf)) != INVALID_FILE_ATTRIBUTES) { - return 0; + return ErrorNone; } } return ErrorFileNotFound; |
