| author | |
| committer | |
| log | 3a2c4908891cdc9f64f0e94eb570ce084f8bc57c |
| tree | 406893c5de91823ce9da9191d5723e6a0df68e1c |
| parent | 8429ddecf89bf0e78b2e0143e9a4a6e7ba88a0fb |
7 files changed, 36 insertions(+), 22 deletions(-)
CMakeLists.txt-1| ... | @@ -622,7 +622,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib" | ... | @@ -622,7 +622,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib" |
| 622 | --cache on | 622 | --cache on |
| 623 | --output-dir "${CMAKE_BINARY_DIR}" | 623 | --output-dir "${CMAKE_BINARY_DIR}" |
| 624 | ${LIBSTAGE2_RELEASE_ARG} | 624 | ${LIBSTAGE2_RELEASE_ARG} |
| 625 | --disable-gen-h | ||
| 626 | --bundle-compiler-rt | 625 | --bundle-compiler-rt |
| 627 | -fPIC | 626 | -fPIC |
| 628 | -lc | 627 | -lc |
build.zig+2-1| ... | @@ -134,7 +134,8 @@ pub fn build(b: *Builder) !void { | ... | @@ -134,7 +134,8 @@ pub fn build(b: *Builder) !void { |
| 134 | test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes)); | 134 | test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes)); |
| 135 | test_step.dependOn(tests.addTranslateCTests(b, test_filter)); | 135 | test_step.dependOn(tests.addTranslateCTests(b, test_filter)); |
| 136 | test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter)); | 136 | test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter)); |
| 137 | test_step.dependOn(tests.addGenHTests(b, test_filter)); | 137 | // tests for this feature are disabled until we have the self-hosted compiler available |
| 138 | //test_step.dependOn(tests.addGenHTests(b, test_filter)); | ||
| 138 | test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes)); | 139 | test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes)); |
| 139 | test_step.dependOn(docs_step); | 140 | test_step.dependOn(docs_step); |
| 140 | } | 141 | } |
lib/std/build.zig+8-10| ... | @@ -1121,7 +1121,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1121,7 +1121,7 @@ pub const LibExeObjStep = struct { |
| 1121 | emit_llvm_ir: bool = false, | 1121 | emit_llvm_ir: bool = false, |
| 1122 | emit_asm: bool = false, | 1122 | emit_asm: bool = false, |
| 1123 | emit_bin: bool = true, | 1123 | emit_bin: bool = true, |
| 1124 | disable_gen_h: bool, | 1124 | emit_h: bool = false, |
| 1125 | bundle_compiler_rt: bool, | 1125 | bundle_compiler_rt: bool, |
| 1126 | disable_stack_probing: bool, | 1126 | disable_stack_probing: bool, |
| 1127 | disable_sanitize_c: bool, | 1127 | disable_sanitize_c: bool, |
| ... | @@ -1281,7 +1281,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1281,7 +1281,6 @@ pub const LibExeObjStep = struct { |
| 1281 | .exec_cmd_args = null, | 1281 | .exec_cmd_args = null, |
| 1282 | .name_prefix = "", | 1282 | .name_prefix = "", |
| 1283 | .filter = null, | 1283 | .filter = null, |
| 1284 | .disable_gen_h = false, | ||
| 1285 | .bundle_compiler_rt = false, | 1284 | .bundle_compiler_rt = false, |
| 1286 | .disable_stack_probing = false, | 1285 | .disable_stack_probing = false, |
| 1287 | .disable_sanitize_c = false, | 1286 | .disable_sanitize_c = false, |
| ... | @@ -1600,8 +1599,9 @@ pub const LibExeObjStep = struct { | ... | @@ -1600,8 +1599,9 @@ pub const LibExeObjStep = struct { |
| 1600 | self.main_pkg_path = dir_path; | 1599 | self.main_pkg_path = dir_path; |
| 1601 | } | 1600 | } |
| 1602 | 1601 | ||
| 1603 | pub fn setDisableGenH(self: *LibExeObjStep, value: bool) void { | 1602 | /// Deprecated; just set the field directly. |
| 1604 | self.disable_gen_h = value; | 1603 | pub fn setDisableGenH(self: *LibExeObjStep, is_disabled: bool) void { |
| 1604 | self.emit_h = !is_disabled; | ||
| 1605 | } | 1605 | } |
| 1606 | 1606 | ||
| 1607 | pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void { | 1607 | pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void { |
| ... | @@ -1632,7 +1632,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1632,7 +1632,7 @@ pub const LibExeObjStep = struct { |
| 1632 | /// the make step, from a step that has declared a dependency on this one. | 1632 | /// the make step, from a step that has declared a dependency on this one. |
| 1633 | pub fn getOutputHPath(self: *LibExeObjStep) []const u8 { | 1633 | pub fn getOutputHPath(self: *LibExeObjStep) []const u8 { |
| 1634 | assert(self.kind != Kind.Exe); | 1634 | assert(self.kind != Kind.Exe); |
| 1635 | assert(!self.disable_gen_h); | 1635 | assert(self.emit_h); |
| 1636 | return fs.path.join( | 1636 | return fs.path.join( |
| 1637 | self.builder.allocator, | 1637 | self.builder.allocator, |
| 1638 | &[_][]const u8{ self.output_dir.?, self.out_h_filename }, | 1638 | &[_][]const u8{ self.output_dir.?, self.out_h_filename }, |
| ... | @@ -1884,6 +1884,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1884,6 +1884,7 @@ pub const LibExeObjStep = struct { |
| 1884 | if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir"); | 1884 | if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir"); |
| 1885 | if (self.emit_asm) try zig_args.append("-femit-asm"); | 1885 | if (self.emit_asm) try zig_args.append("-femit-asm"); |
| 1886 | if (!self.emit_bin) try zig_args.append("-fno-emit-bin"); | 1886 | if (!self.emit_bin) try zig_args.append("-fno-emit-bin"); |
| 1887 | if (self.emit_h) try zig_args.append("-femit-h"); | ||
| 1887 | 1888 | ||
| 1888 | if (self.strip) { | 1889 | if (self.strip) { |
| 1889 | try zig_args.append("--strip"); | 1890 | try zig_args.append("--strip"); |
| ... | @@ -1929,9 +1930,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1929,9 +1930,6 @@ pub const LibExeObjStep = struct { |
| 1929 | if (self.is_dynamic) { | 1930 | if (self.is_dynamic) { |
| 1930 | try zig_args.append("-dynamic"); | 1931 | try zig_args.append("-dynamic"); |
| 1931 | } | 1932 | } |
| 1932 | if (self.disable_gen_h) { | ||
| 1933 | try zig_args.append("--disable-gen-h"); | ||
| 1934 | } | ||
| 1935 | if (self.bundle_compiler_rt) { | 1933 | if (self.bundle_compiler_rt) { |
| 1936 | try zig_args.append("--bundle-compiler-rt"); | 1934 | try zig_args.append("--bundle-compiler-rt"); |
| 1937 | } | 1935 | } |
| ... | @@ -2069,7 +2067,7 @@ pub const LibExeObjStep = struct { | ... | @@ -2069,7 +2067,7 @@ pub const LibExeObjStep = struct { |
| 2069 | try zig_args.append("-isystem"); | 2067 | try zig_args.append("-isystem"); |
| 2070 | try zig_args.append(self.builder.pathFromRoot(include_path)); | 2068 | try zig_args.append(self.builder.pathFromRoot(include_path)); |
| 2071 | }, | 2069 | }, |
| 2072 | .OtherStep => |other| if (!other.disable_gen_h) { | 2070 | .OtherStep => |other| if (other.emit_h) { |
| 2073 | const h_path = other.getOutputHPath(); | 2071 | const h_path = other.getOutputHPath(); |
| 2074 | try zig_args.append("-isystem"); | 2072 | try zig_args.append("-isystem"); |
| 2075 | try zig_args.append(fs.path.dirname(h_path).?); | 2073 | try zig_args.append(fs.path.dirname(h_path).?); |
| ... | @@ -2209,7 +2207,7 @@ const InstallArtifactStep = struct { | ... | @@ -2209,7 +2207,7 @@ const InstallArtifactStep = struct { |
| 2209 | break :blk InstallDir.Lib; | 2207 | break :blk InstallDir.Lib; |
| 2210 | } | 2208 | } |
| 2211 | } else null, | 2209 | } else null, |
| 2212 | .h_dir = if (artifact.kind == .Lib and !artifact.disable_gen_h) .Header else null, | 2210 | .h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null, |
| 2213 | }; | 2211 | }; |
| 2214 | self.step.dependOn(&artifact.step); | 2212 | self.step.dependOn(&artifact.step); |
| 2215 | artifact.install_step = self; | 2213 | artifact.install_step = self; |
lib/std/start.zig+4| ... | @@ -41,6 +41,10 @@ fn _DllMainCRTStartup( | ... | @@ -41,6 +41,10 @@ fn _DllMainCRTStartup( |
| 41 | fdwReason: std.os.windows.DWORD, | 41 | fdwReason: std.os.windows.DWORD, |
| 42 | lpReserved: std.os.windows.LPVOID, | 42 | lpReserved: std.os.windows.LPVOID, |
| 43 | ) callconv(.Stdcall) std.os.windows.BOOL { | 43 | ) callconv(.Stdcall) std.os.windows.BOOL { |
| 44 | if (!builtin.single_threaded) { | ||
| 45 | _ = @import("start_windows_tls.zig"); | ||
| 46 | } | ||
| 47 | |||
| 44 | if (@hasDecl(root, "DllMain")) { | 48 | if (@hasDecl(root, "DllMain")) { |
| 45 | return root.DllMain(hinstDLL, fdwReason, lpReserved); | 49 | return root.DllMain(hinstDLL, fdwReason, lpReserved); |
| 46 | } | 50 | } |
src/main.cpp+10-6| ... | @@ -54,7 +54,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { | ... | @@ -54,7 +54,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { |
| 54 | " --cache-dir [path] override the local cache directory\n" | 54 | " --cache-dir [path] override the local cache directory\n" |
| 55 | " --cache [auto|off|on] build in cache, print output path to stdout\n" | 55 | " --cache [auto|off|on] build in cache, print output path to stdout\n" |
| 56 | " --color [auto|off|on] enable or disable colored error messages\n" | 56 | " --color [auto|off|on] enable or disable colored error messages\n" |
| 57 | " --disable-gen-h do not generate a C header file (.h)\n" | ||
| 58 | " --disable-valgrind omit valgrind client requests in debug builds\n" | 57 | " --disable-valgrind omit valgrind client requests in debug builds\n" |
| 59 | " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n" | 58 | " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n" |
| 60 | " --enable-valgrind include valgrind client requests release builds\n" | 59 | " --enable-valgrind include valgrind client requests release builds\n" |
| ... | @@ -77,6 +76,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { | ... | @@ -77,6 +76,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { |
| 77 | " -fno-emit-asm (default) do not output .s (assembly code)\n" | 76 | " -fno-emit-asm (default) do not output .s (assembly code)\n" |
| 78 | " -femit-llvm-ir produce a .ll file with LLVM IR\n" | 77 | " -femit-llvm-ir produce a .ll file with LLVM IR\n" |
| 79 | " -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n" | 78 | " -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n" |
| 79 | " -femit-h generate a C header file (.h)\n" | ||
| 80 | " -fno-emit-h (default) do not generate a C header file (.h)\n" | ||
| 80 | " --libc [file] Provide a file which specifies libc paths\n" | 81 | " --libc [file] Provide a file which specifies libc paths\n" |
| 81 | " --name [name] override output name\n" | 82 | " --name [name] override output name\n" |
| 82 | " --output-dir [dir] override output directory (defaults to cwd)\n" | 83 | " --output-dir [dir] override output directory (defaults to cwd)\n" |
| ... | @@ -431,6 +432,7 @@ static int main0(int argc, char **argv) { | ... | @@ -431,6 +432,7 @@ static int main0(int argc, char **argv) { |
| 431 | bool emit_bin = true; | 432 | bool emit_bin = true; |
| 432 | bool emit_asm = false; | 433 | bool emit_asm = false; |
| 433 | bool emit_llvm_ir = false; | 434 | bool emit_llvm_ir = false; |
| 435 | bool emit_h = false; | ||
| 434 | const char *cache_dir = nullptr; | 436 | const char *cache_dir = nullptr; |
| 435 | CliPkg *cur_pkg = heap::c_allocator.create<CliPkg>(); | 437 | CliPkg *cur_pkg = heap::c_allocator.create<CliPkg>(); |
| 436 | BuildMode build_mode = BuildModeDebug; | 438 | BuildMode build_mode = BuildModeDebug; |
| ... | @@ -439,7 +441,6 @@ static int main0(int argc, char **argv) { | ... | @@ -439,7 +441,6 @@ static int main0(int argc, char **argv) { |
| 439 | bool system_linker_hack = false; | 441 | bool system_linker_hack = false; |
| 440 | TargetSubsystem subsystem = TargetSubsystemAuto; | 442 | TargetSubsystem subsystem = TargetSubsystemAuto; |
| 441 | bool want_single_threaded = false; | 443 | bool want_single_threaded = false; |
| 442 | bool disable_gen_h = false; | ||
| 443 | bool bundle_compiler_rt = false; | 444 | bool bundle_compiler_rt = false; |
| 444 | Buf *override_lib_dir = nullptr; | 445 | Buf *override_lib_dir = nullptr; |
| 445 | Buf *main_pkg_path = nullptr; | 446 | Buf *main_pkg_path = nullptr; |
| ... | @@ -660,9 +661,7 @@ static int main0(int argc, char **argv) { | ... | @@ -660,9 +661,7 @@ static int main0(int argc, char **argv) { |
| 660 | } else if (strcmp(arg, "--system-linker-hack") == 0) { | 661 | } else if (strcmp(arg, "--system-linker-hack") == 0) { |
| 661 | system_linker_hack = true; | 662 | system_linker_hack = true; |
| 662 | } else if (strcmp(arg, "--single-threaded") == 0) { | 663 | } else if (strcmp(arg, "--single-threaded") == 0) { |
| 663 | want_single_threaded = true; | 664 | want_single_threaded = true;; |
| 664 | } else if (strcmp(arg, "--disable-gen-h") == 0) { | ||
| 665 | disable_gen_h = true; | ||
| 666 | } else if (strcmp(arg, "--bundle-compiler-rt") == 0) { | 665 | } else if (strcmp(arg, "--bundle-compiler-rt") == 0) { |
| 667 | bundle_compiler_rt = true; | 666 | bundle_compiler_rt = true; |
| 668 | } else if (strcmp(arg, "--test-cmd-bin") == 0) { | 667 | } else if (strcmp(arg, "--test-cmd-bin") == 0) { |
| ... | @@ -719,6 +718,11 @@ static int main0(int argc, char **argv) { | ... | @@ -719,6 +718,11 @@ static int main0(int argc, char **argv) { |
| 719 | emit_llvm_ir = true; | 718 | emit_llvm_ir = true; |
| 720 | } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) { | 719 | } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) { |
| 721 | emit_llvm_ir = false; | 720 | emit_llvm_ir = false; |
| 721 | } else if (strcmp(arg, "-femit-h") == 0) { | ||
| 722 | emit_h = true; | ||
| 723 | } else if (strcmp(arg, "-fno-emit-h") == 0 || strcmp(arg, "--disable-gen-h") == 0) { | ||
| 724 | // the --disable-gen-h is there to support godbolt. once they upgrade to -fno-emit-h then we can remove this | ||
| 725 | emit_h = false; | ||
| 722 | } else if (str_starts_with(arg, "-mcpu=")) { | 726 | } else if (str_starts_with(arg, "-mcpu=")) { |
| 723 | mcpu = arg + strlen("-mcpu="); | 727 | mcpu = arg + strlen("-mcpu="); |
| 724 | } else if (i + 1 >= argc) { | 728 | } else if (i + 1 >= argc) { |
| ... | @@ -1202,7 +1206,7 @@ static int main0(int argc, char **argv) { | ... | @@ -1202,7 +1206,7 @@ static int main0(int argc, char **argv) { |
| 1202 | g->verbose_cc = verbose_cc; | 1206 | g->verbose_cc = verbose_cc; |
| 1203 | g->verbose_llvm_cpu_features = verbose_llvm_cpu_features; | 1207 | g->verbose_llvm_cpu_features = verbose_llvm_cpu_features; |
| 1204 | g->output_dir = output_dir; | 1208 | g->output_dir = output_dir; |
| 1205 | g->disable_gen_h = disable_gen_h; | 1209 | g->disable_gen_h = !emit_h; |
| 1206 | g->bundle_compiler_rt = bundle_compiler_rt; | 1210 | g->bundle_compiler_rt = bundle_compiler_rt; |
| 1207 | codegen_set_errmsg_color(g, color); | 1211 | codegen_set_errmsg_color(g, color); |
| 1208 | g->system_linker_hack = system_linker_hack; | 1212 | g->system_linker_hack = system_linker_hack; |
test/standalone/mix_o_files/test.c+5-3| ... | @@ -1,10 +1,12 @@ | ... | @@ -1,10 +1,12 @@ |
| 1 | // This header is generated by zig from base64.zig | ||
| 2 | #include "base64.h" | ||
| 3 | |||
| 4 | #include <assert.h> | 1 | #include <assert.h> |
| 5 | #include <string.h> | 2 | #include <string.h> |
| 6 | #include <stdint.h> | 3 | #include <stdint.h> |
| 7 | 4 | ||
| 5 | // TODO we would like to #include "base64.h" here but this feature has been disabled in | ||
| 6 | // the stage1 compiler. Users will have to wait until self-hosted is available for | ||
| 7 | // the "generate .h file" feature. | ||
| 8 | size_t decode_base_64(uint8_t *dest_ptr, size_t dest_len, const uint8_t *source_ptr, size_t source_len); | ||
| 9 | |||
| 8 | extern int *x_ptr; | 10 | extern int *x_ptr; |
| 9 | 11 | ||
| 10 | int main(int argc, char **argv) { | 12 | int main(int argc, char **argv) { |
test/standalone/shared_library/test.c+7-1| ... | @@ -1,6 +1,12 @@ | ... | @@ -1,6 +1,12 @@ |
| 1 | #include "mathtest.h" | ||
| 2 | #include <assert.h> | 1 | #include <assert.h> |
| 3 | 2 | ||
| 3 | // TODO we would like to #include "mathtest.h" here but this feature has been disabled in | ||
| 4 | // the stage1 compiler. Users will have to wait until self-hosted is available for | ||
| 5 | // the "generate .h file" feature. | ||
| 6 | |||
| 7 | #include <stdint.h> | ||
| 8 | int32_t add(int32_t a, int32_t b); | ||
| 9 | |||
| 4 | int main(int argc, char **argv) { | 10 | int main(int argc, char **argv) { |
| 5 | assert(add(42, 1337) == 1379); | 11 | assert(add(42, 1337) == 1379); |
| 6 | return 0; | 12 | return 0; |