Commit 77e7d97725

Andrew Kelley <andrew@ziglang.org>
2022-11-13 02:11:35
C backend: improve ergonomics of zig.h a little bit
Partially implements #13528. Enough to unblock the wasi-bootstrap branch.
1 parent 0184c8d
Changed files (4)
lib/include/zig.h → lib/zig.h
File renamed without changes
src/link/C.zig
@@ -15,7 +15,7 @@ const Air = @import("../Air.zig");
 const Liveness = @import("../Liveness.zig");
 
 pub const base_tag: link.File.Tag = .c;
-pub const zig_h = "#include <zig.h>\n";
+pub const zig_h = "#include \"zig.h\"\n";
 
 base: link.File,
 /// This linker backend does not try to incrementally link output C source code.
src/main.zig
@@ -3021,6 +3021,10 @@ fn buildOutputType(
         });
         try test_exec_args.append(self_exe_path);
         try test_exec_args.append("run");
+        if (zig_lib_directory.path) |p| {
+            try test_exec_args.appendSlice(&.{ "-I", p });
+        }
+
         if (link_libc) try test_exec_args.append("-lc");
         if (!mem.eql(u8, target_arch_os_abi, "native")) {
             try test_exec_args.append("-target");
src/test.zig
@@ -1812,6 +1812,9 @@ pub const TestContext = struct {
                                 "-lc",
                                 exe_path,
                             });
+                            if (zig_lib_directory.path) |p| {
+                                try argv.appendSlice(&.{ "-I", p });
+                            }
                         } else switch (host.getExternalExecutor(target_info, .{ .link_libc = case.link_libc })) {
                             .native => try argv.append(exe_path),
                             .bad_dl, .bad_os_or_cpu => continue :update, // Pass test.