| author | |
| committer | |
| log | 26718a619c572602c21c83b1588e50723447709a |
| tree | 6c28906895aaf119e7d344c58b5b0f2c2380fb7a |
| parent | 6b7ffd4cbe1006013cda4a36c9659c4822ae1b53 |
See #5410 files changed, 29 insertions(+), 4 deletions(-)
CMakeLists.txt+2| ... | ... | @@ -18,6 +18,7 @@ set(ZIG_LIBC_LIB_DIR "" CACHE STRING "Default native target libc directory where |
| 18 | 18 | set(ZIG_LIBC_STATIC_LIB_DIR "" CACHE STRING "Default native target libc directory where crtbeginT.o can be found") |
| 19 | 19 | set(ZIG_LIBC_INCLUDE_DIR "/usr/include" CACHE STRING "Default native target libc include directory") |
| 20 | 20 | set(ZIG_LD_PATH "ld" CACHE STRING "Path to ld for the native target") |
| 21 | set(ZIG_AR_PATH "ar" CACHE STRING "Path to ar for the native target") | |
| 21 | 22 | set(ZIG_DYNAMIC_LINKER "" CACHE STRING "Override dynamic linker for native target") |
| 22 | 23 | |
| 23 | 24 | option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF) |
| ... | ... | @@ -217,6 +218,7 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/linux_i386.zig" DESTINATION "${ZIG_STD_DE |
| 217 | 218 | install(FILES "${CMAKE_SOURCE_DIR}/std/mem.zig" DESTINATION "${ZIG_STD_DEST}") |
| 218 | 219 | install(FILES "${CMAKE_SOURCE_DIR}/std/list.zig" DESTINATION "${ZIG_STD_DEST}") |
| 219 | 220 | install(FILES "${CMAKE_SOURCE_DIR}/std/hash_map.zig" DESTINATION "${ZIG_STD_DEST}") |
| 221 | install(FILES "${CMAKE_SOURCE_DIR}/std/empty.zig" DESTINATION "${ZIG_STD_DEST}") | |
| 220 | 222 | |
| 221 | 223 | add_executable(run_tests ${TEST_SOURCES}) |
| 222 | 224 | target_link_libraries(run_tests) |
src/all_types.hpp+1| ... | ... | @@ -1214,6 +1214,7 @@ struct CodeGen { |
| 1214 | 1214 | Buf *libc_include_dir; |
| 1215 | 1215 | Buf *dynamic_linker; |
| 1216 | 1216 | Buf *linker_path; |
| 1217 | Buf *ar_path; | |
| 1217 | 1218 | Buf triple_str; |
| 1218 | 1219 | bool is_release_build; |
| 1219 | 1220 | bool is_test_build; |
src/codegen.cpp+6| ... | ... | @@ -85,6 +85,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { |
| 85 | 85 | g->libc_static_lib_dir = buf_create_from_str(""); |
| 86 | 86 | g->libc_include_dir = buf_create_from_str(""); |
| 87 | 87 | g->linker_path = buf_create_from_str(""); |
| 88 | g->ar_path = buf_create_from_str(""); | |
| 88 | 89 | g->darwin_linker_version = buf_create_from_str(""); |
| 89 | 90 | } else { |
| 90 | 91 | // native compilation, we can rely on the configuration stuff |
| ... | ... | @@ -96,6 +97,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { |
| 96 | 97 | g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR); |
| 97 | 98 | g->libc_include_dir = buf_create_from_str(ZIG_LIBC_INCLUDE_DIR); |
| 98 | 99 | g->linker_path = buf_create_from_str(ZIG_LD_PATH); |
| 100 | g->ar_path = buf_create_from_str(ZIG_AR_PATH); | |
| 99 | 101 | g->darwin_linker_version = buf_create_from_str(ZIG_HOST_LINK_VERSION); |
| 100 | 102 | |
| 101 | 103 | if (g->zig_target.os == ZigLLVM_Darwin || |
| ... | ... | @@ -171,6 +173,10 @@ void codegen_set_linker_path(CodeGen *g, Buf *linker_path) { |
| 171 | 173 | g->linker_path = linker_path; |
| 172 | 174 | } |
| 173 | 175 | |
| 176 | void codegen_set_ar_path(CodeGen *g, Buf *ar_path) { | |
| 177 | g->ar_path = ar_path; | |
| 178 | } | |
| 179 | ||
| 174 | 180 | void codegen_add_lib_dir(CodeGen *g, const char *dir) { |
| 175 | 181 | g->lib_dirs.append(dir); |
| 176 | 182 | } |
src/codegen.hpp+1| ... | ... | @@ -32,6 +32,7 @@ void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir); |
| 32 | 32 | void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); |
| 33 | 33 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker); |
| 34 | 34 | void codegen_set_linker_path(CodeGen *g, Buf *linker_path); |
| 35 | void codegen_set_ar_path(CodeGen *g, Buf *ar_path); | |
| 35 | 36 | void codegen_set_windows_subsystem(CodeGen *g, bool mwindows, bool mconsole); |
| 36 | 37 | void codegen_set_windows_unicode(CodeGen *g, bool municode); |
| 37 | 38 | void codegen_add_lib_dir(CodeGen *codegen, const char *dir); |
src/config.h.in+1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | #define ZIG_LIBC_LIB_DIR "@ZIG_LIBC_LIB_DIR@" |
| 13 | 13 | #define ZIG_LIBC_STATIC_LIB_DIR "@ZIG_LIBC_STATIC_LIB_DIR@" |
| 14 | 14 | #define ZIG_LD_PATH "@ZIG_LD_PATH@" |
| 15 | #define ZIG_AR_PATH "@ZIG_AR_PATH@" | |
| 15 | 16 | #define ZIG_DYNAMIC_LINKER "@ZIG_DYNAMIC_LINKER@" |
| 16 | 17 | #define ZIG_HOST_LINK_VERSION "@ZIG_HOST_LINK_VERSION@" |
| 17 | 18 |
src/link.cpp+1| ... | ... | @@ -152,6 +152,7 @@ static void construct_linker_job_linux(LinkJob *lj) { |
| 152 | 152 | find_libc_lib_path(g); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | lj->args.append("--gc-sections"); | |
| 155 | 156 | |
| 156 | 157 | lj->args.append("-m"); |
| 157 | 158 | lj->args.append(getLDMOption(&g->zig_target)); |
src/main.cpp+6| ... | ... | @@ -37,6 +37,7 @@ static int usage(const char *arg0) { |
| 37 | 37 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" |
| 38 | 38 | " --dynamic-linker [path] set the path to ld.so\n" |
| 39 | 39 | " --ld-path [path] set the path to the linker\n" |
| 40 | " --ar-path [path] set the path to ar\n" | |
| 40 | 41 | " -isystem [dir] add additional search path for other .h files\n" |
| 41 | 42 | " -dirafter [dir] same as -isystem but do it last\n" |
| 42 | 43 | " --library-path [dir] add a directory to the library search path\n" |
| ... | ... | @@ -118,6 +119,7 @@ int main(int argc, char **argv) { |
| 118 | 119 | const char *libc_include_dir = nullptr; |
| 119 | 120 | const char *dynamic_linker = nullptr; |
| 120 | 121 | const char *linker_path = nullptr; |
| 122 | const char *ar_path = nullptr; | |
| 121 | 123 | ZigList<const char *> clang_argv = {0}; |
| 122 | 124 | ZigList<const char *> lib_dirs = {0}; |
| 123 | 125 | ZigList<const char *> link_libs = {0}; |
| ... | ... | @@ -196,6 +198,8 @@ int main(int argc, char **argv) { |
| 196 | 198 | dynamic_linker = argv[i]; |
| 197 | 199 | } else if (strcmp(arg, "--ld-path") == 0) { |
| 198 | 200 | linker_path = argv[i]; |
| 201 | } else if (strcmp(arg, "--ar-path") == 0) { | |
| 202 | ar_path = argv[i]; | |
| 199 | 203 | } else if (strcmp(arg, "-isystem") == 0) { |
| 200 | 204 | clang_argv.append("-isystem"); |
| 201 | 205 | clang_argv.append(argv[i]); |
| ... | ... | @@ -356,6 +360,8 @@ int main(int argc, char **argv) { |
| 356 | 360 | codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker)); |
| 357 | 361 | if (linker_path) |
| 358 | 362 | codegen_set_linker_path(g, buf_create_from_str(linker_path)); |
| 363 | if (ar_path) | |
| 364 | codegen_set_ar_path(g, buf_create_from_str(ar_path)); | |
| 359 | 365 | codegen_set_verbose(g, verbose); |
| 360 | 366 | codegen_set_errmsg_color(g, color); |
| 361 | 367 |
std/empty.zig createdstd/index.zig+6| ... | ... | @@ -8,7 +8,13 @@ pub const net = @import("net.zig"); |
| 8 | 8 | pub const list = @import("list.zig"); |
| 9 | 9 | pub const hash_map = @import("hash_map.zig"); |
| 10 | 10 | pub const mem = @import("mem.zig"); |
| 11 | pub const linux = switch(@compile_var("os")) { | |
| 12 | linux => @import("linux.zig"), | |
| 13 | else => null_import, | |
| 14 | }; | |
| 11 | 15 | |
| 12 | 16 | pub fn assert(b: bool) { |
| 13 | 17 | if (!b) unreachable{} |
| 14 | 18 | } |
| 19 | ||
| 20 | const null_import = @import("empty.zig"); |
std/io.zig+5-4| ... | ... | @@ -119,10 +119,10 @@ pub struct OutStream { |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | pub fn flush(os: &OutStream) -> %void { |
| 122 | const amt_written = linux.write(os.fd, &os.buffer[0], os.index); | |
| 123 | os.index = 0; | |
| 124 | if (amt_written < 0) { | |
| 125 | return switch (-amt_written) { | |
| 122 | const write_ret = linux.write(os.fd, &os.buffer[0], os.index); | |
| 123 | const write_err = linux.get_errno(write_ret); | |
| 124 | if (write_err > 0) { | |
| 125 | return switch (write_err) { | |
| 126 | 126 | errno.EINVAL => unreachable{}, |
| 127 | 127 | errno.EDQUOT => error.DiskQuota, |
| 128 | 128 | errno.EFBIG => error.FileTooBig, |
| ... | ... | @@ -134,6 +134,7 @@ pub struct OutStream { |
| 134 | 134 | else => error.Unexpected, |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | os.index = 0; | |
| 137 | 138 | } |
| 138 | 139 | |
| 139 | 140 | pub fn close(os: &OutStream) -> %void { |