From 77e7d97725a07bc3eaa7e9c7f9ffd7698f357f1a Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 12 Nov 2022 18:11:35 -0700 Subject: [PATCH 1/2] C backend: improve ergonomics of zig.h a little bit Partially implements #13528. Enough to unblock the wasi-bootstrap branch. --- lib/{include => }/zig.h | 0 src/link/C.zig | 2 +- src/main.zig | 4 ++++ src/test.zig | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) rename lib/{include => }/zig.h (100%) diff --git a/lib/include/zig.h b/lib/zig.h similarity index 100% rename from lib/include/zig.h rename to lib/zig.h diff --git a/src/link/C.zig b/src/link/C.zig index a52ac63df5..4af69e6fcf 100644 --- a/src/link/C.zig +++ b/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 \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. diff --git a/src/main.zig b/src/main.zig index 71325b18d9..d7685af72f 100644 --- a/src/main.zig +++ b/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"); diff --git a/src/test.zig b/src/test.zig index 41e5f23025..c6d55b806e 100644 --- a/src/test.zig +++ b/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. From 20e8c2df4ee607d5630abb60aa2724e5f02374cf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 13 Nov 2022 16:50:20 -0700 Subject: [PATCH 2/2] zig.h: remove redundant definition of u16/i16 --- lib/zig.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/zig.h b/lib/zig.h index c6df066162..e8329494d4 100644 --- a/lib/zig.h +++ b/lib/zig.h @@ -220,8 +220,6 @@ typedef uint8_t zig_u8; typedef int8_t zig_i8; typedef uint16_t zig_u16; typedef int16_t zig_i16; -typedef uint16_t zig_u16; -typedef int16_t zig_i16; typedef uint32_t zig_u32; typedef int32_t zig_i32; typedef uint64_t zig_u64;