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