authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-20 18:33:36-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-20 18:33:36-04:00
log3a2c4908891cdc9f64f0e94eb570ce084f8bc57c
tree406893c5de91823ce9da9191d5723e6a0df68e1c
parent8429ddecf89bf0e78b2e0143e9a4a6e7ba88a0fb

"generate .h files" feature is no longer supported in stage1


7 files changed, 36 insertions(+), 22 deletions(-)

CMakeLists.txt-1
......@@ -622,7 +622,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"
622622 --cache on
623623 --output-dir "${CMAKE_BINARY_DIR}"
624624 ${LIBSTAGE2_RELEASE_ARG}
625 --disable-gen-h
626625 --bundle-compiler-rt
627626 -fPIC
628627 -lc
build.zig+2-1
......@@ -134,7 +134,8 @@ pub fn build(b: *Builder) !void {
134134 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
135135 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
136136 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));
138139 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
139140 test_step.dependOn(docs_step);
140141}
lib/std/build.zig+8-10
......@@ -1121,7 +1121,7 @@ pub const LibExeObjStep = struct {
11211121 emit_llvm_ir: bool = false,
11221122 emit_asm: bool = false,
11231123 emit_bin: bool = true,
1124 disable_gen_h: bool,
1124 emit_h: bool = false,
11251125 bundle_compiler_rt: bool,
11261126 disable_stack_probing: bool,
11271127 disable_sanitize_c: bool,
......@@ -1281,7 +1281,6 @@ pub const LibExeObjStep = struct {
12811281 .exec_cmd_args = null,
12821282 .name_prefix = "",
12831283 .filter = null,
1284 .disable_gen_h = false,
12851284 .bundle_compiler_rt = false,
12861285 .disable_stack_probing = false,
12871286 .disable_sanitize_c = false,
......@@ -1600,8 +1599,9 @@ pub const LibExeObjStep = struct {
16001599 self.main_pkg_path = dir_path;
16011600 }
16021601
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;
16051605 }
16061606
16071607 pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {
......@@ -1632,7 +1632,7 @@ pub const LibExeObjStep = struct {
16321632 /// the make step, from a step that has declared a dependency on this one.
16331633 pub fn getOutputHPath(self: *LibExeObjStep) []const u8 {
16341634 assert(self.kind != Kind.Exe);
1635 assert(!self.disable_gen_h);
1635 assert(self.emit_h);
16361636 return fs.path.join(
16371637 self.builder.allocator,
16381638 &[_][]const u8{ self.output_dir.?, self.out_h_filename },
......@@ -1884,6 +1884,7 @@ pub const LibExeObjStep = struct {
18841884 if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir");
18851885 if (self.emit_asm) try zig_args.append("-femit-asm");
18861886 if (!self.emit_bin) try zig_args.append("-fno-emit-bin");
1887 if (self.emit_h) try zig_args.append("-femit-h");
18871888
18881889 if (self.strip) {
18891890 try zig_args.append("--strip");
......@@ -1929,9 +1930,6 @@ pub const LibExeObjStep = struct {
19291930 if (self.is_dynamic) {
19301931 try zig_args.append("-dynamic");
19311932 }
1932 if (self.disable_gen_h) {
1933 try zig_args.append("--disable-gen-h");
1934 }
19351933 if (self.bundle_compiler_rt) {
19361934 try zig_args.append("--bundle-compiler-rt");
19371935 }
......@@ -2069,7 +2067,7 @@ pub const LibExeObjStep = struct {
20692067 try zig_args.append("-isystem");
20702068 try zig_args.append(self.builder.pathFromRoot(include_path));
20712069 },
2072 .OtherStep => |other| if (!other.disable_gen_h) {
2070 .OtherStep => |other| if (other.emit_h) {
20732071 const h_path = other.getOutputHPath();
20742072 try zig_args.append("-isystem");
20752073 try zig_args.append(fs.path.dirname(h_path).?);
......@@ -2209,7 +2207,7 @@ const InstallArtifactStep = struct {
22092207 break :blk InstallDir.Lib;
22102208 }
22112209 } 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,
22132211 };
22142212 self.step.dependOn(&artifact.step);
22152213 artifact.install_step = self;
lib/std/start.zig+4
......@@ -41,6 +41,10 @@ fn _DllMainCRTStartup(
4141 fdwReason: std.os.windows.DWORD,
4242 lpReserved: std.os.windows.LPVOID,
4343) callconv(.Stdcall) std.os.windows.BOOL {
44 if (!builtin.single_threaded) {
45 _ = @import("start_windows_tls.zig");
46 }
47
4448 if (@hasDecl(root, "DllMain")) {
4549 return root.DllMain(hinstDLL, fdwReason, lpReserved);
4650 }
src/main.cpp+10-6
......@@ -54,7 +54,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
5454 " --cache-dir [path] override the local cache directory\n"
5555 " --cache [auto|off|on] build in cache, print output path to stdout\n"
5656 " --color [auto|off|on] enable or disable colored error messages\n"
57 " --disable-gen-h do not generate a C header file (.h)\n"
5857 " --disable-valgrind omit valgrind client requests in debug builds\n"
5958 " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n"
6059 " --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) {
7776 " -fno-emit-asm (default) do not output .s (assembly code)\n"
7877 " -femit-llvm-ir produce a .ll file with LLVM IR\n"
7978 " -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"
8081 " --libc [file] Provide a file which specifies libc paths\n"
8182 " --name [name] override output name\n"
8283 " --output-dir [dir] override output directory (defaults to cwd)\n"
......@@ -431,6 +432,7 @@ static int main0(int argc, char **argv) {
431432 bool emit_bin = true;
432433 bool emit_asm = false;
433434 bool emit_llvm_ir = false;
435 bool emit_h = false;
434436 const char *cache_dir = nullptr;
435437 CliPkg *cur_pkg = heap::c_allocator.create<CliPkg>();
436438 BuildMode build_mode = BuildModeDebug;
......@@ -439,7 +441,6 @@ static int main0(int argc, char **argv) {
439441 bool system_linker_hack = false;
440442 TargetSubsystem subsystem = TargetSubsystemAuto;
441443 bool want_single_threaded = false;
442 bool disable_gen_h = false;
443444 bool bundle_compiler_rt = false;
444445 Buf *override_lib_dir = nullptr;
445446 Buf *main_pkg_path = nullptr;
......@@ -660,9 +661,7 @@ static int main0(int argc, char **argv) {
660661 } else if (strcmp(arg, "--system-linker-hack") == 0) {
661662 system_linker_hack = true;
662663 } 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;;
666665 } else if (strcmp(arg, "--bundle-compiler-rt") == 0) {
667666 bundle_compiler_rt = true;
668667 } else if (strcmp(arg, "--test-cmd-bin") == 0) {
......@@ -719,6 +718,11 @@ static int main0(int argc, char **argv) {
719718 emit_llvm_ir = true;
720719 } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) {
721720 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;
722726 } else if (str_starts_with(arg, "-mcpu=")) {
723727 mcpu = arg + strlen("-mcpu=");
724728 } else if (i + 1 >= argc) {
......@@ -1202,7 +1206,7 @@ static int main0(int argc, char **argv) {
12021206 g->verbose_cc = verbose_cc;
12031207 g->verbose_llvm_cpu_features = verbose_llvm_cpu_features;
12041208 g->output_dir = output_dir;
1205 g->disable_gen_h = disable_gen_h;
1209 g->disable_gen_h = !emit_h;
12061210 g->bundle_compiler_rt = bundle_compiler_rt;
12071211 codegen_set_errmsg_color(g, color);
12081212 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
41#include <assert.h>
52#include <string.h>
63#include <stdint.h>
74
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.
8size_t decode_base_64(uint8_t *dest_ptr, size_t dest_len, const uint8_t *source_ptr, size_t source_len);
9
810extern int *x_ptr;
911
1012int main(int argc, char **argv) {
test/standalone/shared_library/test.c+7-1
......@@ -1,6 +1,12 @@
1#include "mathtest.h"
21#include <assert.h>
32
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>
8int32_t add(int32_t a, int32_t b);
9
410int main(int argc, char **argv) {
511 assert(add(42, 1337) == 1379);
612 return 0;