Skip to content

Commit 7d0816d

Browse files
committed
zig v0.12.0 - final release
1 parent 11d53b0 commit 7d0816d

File tree

87 files changed

+6541
-3643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+6541
-3643
lines changed

zig/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ endif()
109109

110110
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
111111
set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
112+
set(ZIG_TARGET_DYNAMIC_LINKER "" CACHE STRING
113+
"Override the dynamic linker used by the Zig binary. Default is to auto-detect the dynamic linker.")
112114
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
113115
set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
114116

@@ -897,12 +899,16 @@ if(ZIG_STATIC AND NOT MSVC)
897899
else()
898900
set(ZIG_STATIC_ARG "")
899901
endif()
900-
901902
if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
902903
set(ZIG_PIE_ARG "-Dpie")
903904
else()
904905
set(ZIG_PIE_ARG "")
905906
endif()
907+
if("${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "")
908+
set(ZIG_DYNAMIC_LINKER_ARG "")
909+
else()
910+
set(ZIG_DYNAMIC_LINKER_ARG "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}")
911+
endif()
906912

907913
# -Dno-langref is currently hardcoded because building the langref takes too damn long
908914
# To obtain these two forms of documentation, run zig build against stage3 rather than stage2.
@@ -918,6 +924,7 @@ set(ZIG_BUILD_ARGS
918924
${ZIG_PIE_ARG}
919925
"-Dtarget=${ZIG_TARGET_TRIPLE}"
920926
"-Dcpu=${ZIG_TARGET_MCPU}"
927+
${ZIG_DYNAMIC_LINKER_ARG}
921928
"-Dversion-string=${RESOLVED_ZIG_VERSION}"
922929
)
923930

zig/doc/langref.html.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
<a href="https://ziglang.org/documentation/0.9.1/">0.9.1</a> |
315315
<a href="https://ziglang.org/documentation/0.10.1/">0.10.1</a> |
316316
<a href="https://ziglang.org/documentation/0.11.0/">0.11.0</a> |
317+
<a href="https://ziglang.org/documentation/0.12.0/">0.12.0</a> |
317318
master
318319
</nav>
319320
<nav aria-labelledby="table-of-contents">

zig/lib/compiler/build_runner.zig

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ pub fn main() !void {
7070
.zig_exe = zig_exe,
7171
.env_map = try process.getEnvMap(arena),
7272
.global_cache_root = global_cache_directory,
73+
.host = .{
74+
.query = .{},
75+
.result = try std.zig.system.resolveTargetQuery(.{}),
76+
},
7377
};
7478

7579
graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
@@ -142,12 +146,6 @@ pub fn main() !void {
142146
arg, text,
143147
});
144148
};
145-
} else if (mem.eql(u8, arg, "--host-target")) {
146-
graph.host_query_options.arch_os_abi = nextArgOrFatal(args, &arg_idx);
147-
} else if (mem.eql(u8, arg, "--host-cpu")) {
148-
graph.host_query_options.cpu_features = nextArgOrFatal(args, &arg_idx);
149-
} else if (mem.eql(u8, arg, "--host-dynamic-linker")) {
150-
graph.host_query_options.dynamic_linker = nextArgOrFatal(args, &arg_idx);
151149
} else if (mem.eql(u8, arg, "--prefix-lib-dir")) {
152150
dir_list.lib_dir = nextArgOrFatal(args, &arg_idx);
153151
} else if (mem.eql(u8, arg, "--prefix-exe-dir")) {
@@ -283,14 +281,6 @@ pub fn main() !void {
283281
}
284282
}
285283

286-
const host_query = std.Build.parseTargetQuery(graph.host_query_options) catch |err| switch (err) {
287-
error.ParseFailed => process.exit(1),
288-
};
289-
builder.host = .{
290-
.query = .{},
291-
.result = try std.zig.system.resolveTargetQuery(host_query),
292-
};
293-
294284
const stderr = std.io.getStdErr();
295285
const ttyconf = get_tty_conf(color, stderr);
296286
switch (ttyconf) {
@@ -1171,10 +1161,6 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
11711161
\\ --sysroot [path] Set the system root directory (usually /)
11721162
\\ --libc [file] Provide a file which specifies libc paths
11731163
\\
1174-
\\ --host-target [triple] Use the provided target as the host
1175-
\\ --host-cpu [cpu] Use the provided CPU as the host
1176-
\\ --host-dynamic-linker [path] Use the provided dynamic linker as the host
1177-
\\
11781164
\\ --system [pkgdir] Disable package fetching; enable all integrations
11791165
\\ -fsys=[name] Enable a system integration
11801166
\\ -fno-sys=[name] Disable a system integration

zig/lib/compiler/resinator/ico.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ test "icon data size too small" {
232232
try std.testing.expectError(error.ImpossibleDataSize, read(std.testing.allocator, fbs.reader(), data.len));
233233
}
234234

235-
pub const ImageFormat = enum {
235+
pub const ImageFormat = enum(u2) {
236236
dib,
237237
png,
238238
riff,
@@ -272,7 +272,7 @@ pub const BitmapHeader = extern struct {
272272
}
273273

274274
/// https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_(bitmap_information_header)
275-
pub const Version = enum {
275+
pub const Version = enum(u3) {
276276
unknown,
277277
@"win2.0", // Windows 2.0 or later
278278
@"nt3.1", // Windows NT, 3.1x or later

zig/lib/docs/wasm/markdown/Document.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub const Node = struct {
131131
}
132132
};
133133

134-
pub const TableCellAlignment = enum {
134+
pub const TableCellAlignment = enum(u2) {
135135
unset,
136136
left,
137137
center,

zig/lib/init/build.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
1919
.name = "$",
2020
// In this case the main source file is merely a path, however, in more
2121
// complicated build scripts, this could be a generated file.
22-
.root_source_file = .{ .path = "src/root.zig" },
22+
.root_source_file = b.path("src/root.zig"),
2323
.target = target,
2424
.optimize = optimize,
2525
});
@@ -31,7 +31,7 @@ pub fn build(b: *std.Build) void {
3131

3232
const exe = b.addExecutable(.{
3333
.name = "$",
34-
.root_source_file = .{ .path = "src/main.zig" },
34+
.root_source_file = b.path("src/main.zig"),
3535
.target = target,
3636
.optimize = optimize,
3737
});
@@ -67,15 +67,15 @@ pub fn build(b: *std.Build) void {
6767
// Creates a step for unit testing. This only builds the test executable
6868
// but does not run it.
6969
const lib_unit_tests = b.addTest(.{
70-
.root_source_file = .{ .path = "src/root.zig" },
70+
.root_source_file = b.path("src/root.zig"),
7171
.target = target,
7272
.optimize = optimize,
7373
});
7474

7575
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
7676

7777
const exe_unit_tests = b.addTest(.{
78-
.root_source_file = .{ .path = "src/main.zig" },
78+
.root_source_file = b.path("src/main.zig"),
7979
.target = target,
8080
.optimize = optimize,
8181
});

zig/lib/std/Build.zig

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ enable_wine: bool = false,
8282
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
8383
glibc_runtimes_dir: ?[]const u8 = null,
8484

85-
/// Information about the native target. Computed before build() is invoked.
85+
/// Deprecated. Use `b.graph.host`.
8686
host: ResolvedTarget,
8787

8888
dep_prefix: []const u8 = "",
@@ -118,8 +118,9 @@ pub const Graph = struct {
118118
zig_exe: [:0]const u8,
119119
env_map: EnvMap,
120120
global_cache_root: Cache.Directory,
121-
host_query_options: std.Target.Query.ParseOptions = .{},
122121
needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .{},
122+
/// Information about the native target. Computed before build() is invoked.
123+
host: ResolvedTarget,
123124
};
124125

125126
const AvailableDeps = []const struct { []const u8, []const u8 };
@@ -297,7 +298,7 @@ pub fn create(
297298
.zig_lib_dir = null,
298299
.install_path = undefined,
299300
.args = null,
300-
.host = undefined,
301+
.host = graph.host,
301302
.modules = std.StringArrayHashMap(*Module).init(arena),
302303
.named_writefiles = std.StringArrayHashMap(*Step.WriteFile).init(arena),
303304
.initialized_deps = initialized_deps,
@@ -1974,7 +1975,7 @@ pub fn dependencyFromBuildZig(
19741975
const dep_name = for (b.available_deps) |dep| {
19751976
if (mem.eql(u8, dep[1], pkg_hash)) break dep[1];
19761977
} else break :find_dep;
1977-
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg.deps, args);
1978+
return dependencyInner(b, dep_name, pkg.build_root, pkg.build_zig, pkg_hash, pkg.deps, args);
19781979
}
19791980

19801981
const full_path = b.pathFromRoot("build.zig.zon");
@@ -2489,14 +2490,9 @@ pub const ResolvedTarget = struct {
24892490
/// various parts of the API.
24902491
pub fn resolveTargetQuery(b: *Build, query: Target.Query) ResolvedTarget {
24912492
if (query.isNative()) {
2492-
var adjusted = b.host;
2493-
if (query.ofmt) |ofmt| {
2494-
adjusted.query.ofmt = ofmt;
2495-
adjusted.result.ofmt = ofmt;
2496-
}
2497-
return adjusted;
2493+
// Hot path. This is faster than querying the native CPU and OS again.
2494+
return b.graph.host;
24982495
}
2499-
25002496
return .{
25012497
.query = query,
25022498
.result = std.zig.system.resolveTargetQuery(query) catch

0 commit comments

Comments
 (0)