Skip to content

Commit 0cada92

Browse files
authored
Merge branch 'master' into m68k-archbits
2 parents d7c2417 + 0bdc0bb commit 0cada92

File tree

107 files changed

+8109
-7239
lines changed

Some content is hidden

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

107 files changed

+8109
-7239
lines changed

build.zig

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ pub fn build(b: *std.Build) !void {
214214

215215
test_step.dependOn(&exe.step);
216216

217-
if (target.result.os.tag == .windows and target.result.abi == .gnu) {
218-
// LTO is currently broken on mingw, this can be removed when it's fixed.
219-
exe.want_lto = false;
220-
}
221-
222217
const use_llvm = b.option(bool, "use-llvm", "Use the llvm backend");
223218
exe.use_llvm = use_llvm;
224219
exe.use_lld = use_llvm;
@@ -331,7 +326,12 @@ pub fn build(b: *std.Build) !void {
331326
try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
332327
} else {
333328
// Here we are -Denable-llvm but no cmake integration.
334-
try addStaticLlvmOptionsToModule(exe.root_module);
329+
try addStaticLlvmOptionsToModule(exe.root_module, .{
330+
.llvm_has_m68k = llvm_has_m68k,
331+
.llvm_has_csky = llvm_has_csky,
332+
.llvm_has_arc = llvm_has_arc,
333+
.llvm_has_xtensa = llvm_has_xtensa,
334+
});
335335
}
336336
if (target.result.os.tag == .windows) {
337337
// LLVM depends on networking as of version 18.
@@ -359,11 +359,7 @@ pub fn build(b: *std.Build) !void {
359359
&[_][]const u8{ tracy_path, "public", "TracyClient.cpp" },
360360
);
361361

362-
// On mingw, we need to opt into windows 7+ to get some features required by tracy.
363-
const tracy_c_flags: []const []const u8 = if (target.result.os.tag == .windows and target.result.abi == .gnu)
364-
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
365-
else
366-
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
362+
const tracy_c_flags: []const []const u8 = &.{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
367363

368364
exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path });
369365
exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });
@@ -510,8 +506,8 @@ pub fn build(b: *std.Build) !void {
510506
.skip_non_native = skip_non_native,
511507
.skip_libc = skip_libc,
512508
.use_llvm = use_llvm,
513-
// I observed a value of 5136793600 on the M2 CI.
514-
.max_rss = 5368709120,
509+
// I observed a value of 5605064704 on the M2 CI.
510+
.max_rss = 6165571174,
515511
}));
516512

517513
const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests");
@@ -818,7 +814,12 @@ fn addCmakeCfgOptionsToExe(
818814
}
819815
}
820816

821-
fn addStaticLlvmOptionsToModule(mod: *std.Build.Module) !void {
817+
fn addStaticLlvmOptionsToModule(mod: *std.Build.Module, options: struct {
818+
llvm_has_m68k: bool,
819+
llvm_has_csky: bool,
820+
llvm_has_arc: bool,
821+
llvm_has_xtensa: bool,
822+
}) !void {
822823
// Adds the Zig C++ sources which both stage1 and stage2 need.
823824
//
824825
// We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
@@ -842,6 +843,22 @@ fn addStaticLlvmOptionsToModule(mod: *std.Build.Module) !void {
842843
mod.linkSystemLibrary(lib_name, .{});
843844
}
844845

846+
if (options.llvm_has_m68k) for (llvm_libs_m68k) |lib_name| {
847+
mod.linkSystemLibrary(lib_name, .{});
848+
};
849+
850+
if (options.llvm_has_csky) for (llvm_libs_csky) |lib_name| {
851+
mod.linkSystemLibrary(lib_name, .{});
852+
};
853+
854+
if (options.llvm_has_arc) for (llvm_libs_arc) |lib_name| {
855+
mod.linkSystemLibrary(lib_name, .{});
856+
};
857+
858+
if (options.llvm_has_xtensa) for (llvm_libs_xtensa) |lib_name| {
859+
mod.linkSystemLibrary(lib_name, .{});
860+
};
861+
845862
mod.linkSystemLibrary("z", .{});
846863
mod.linkSystemLibrary("zstd", .{});
847864

@@ -1330,6 +1347,33 @@ const llvm_libs = [_][]const u8{
13301347
"LLVMSupport",
13311348
"LLVMDemangle",
13321349
};
1350+
const llvm_libs_m68k = [_][]const u8{
1351+
"LLVMM68kDisassembler",
1352+
"LLVMM68kAsmParser",
1353+
"LLVMM68kCodeGen",
1354+
"LLVMM68kDesc",
1355+
"LLVMM68kInfo",
1356+
};
1357+
const llvm_libs_csky = [_][]const u8{
1358+
"LLVMCSKYDisassembler",
1359+
"LLVMCSKYAsmParser",
1360+
"LLVMCSKYCodeGen",
1361+
"LLVMCSKYDesc",
1362+
"LLVMCSKYInfo",
1363+
};
1364+
const llvm_libs_arc = [_][]const u8{
1365+
"LLVMARCDisassembler",
1366+
"LLVMARCCodeGen",
1367+
"LLVMARCDesc",
1368+
"LLVMARCInfo",
1369+
};
1370+
const llvm_libs_xtensa = [_][]const u8{
1371+
"LLVMXtensaDisassembler",
1372+
"LLVMXtensaAsmParser",
1373+
"LLVMXtensaCodeGen",
1374+
"LLVMXtensaDesc",
1375+
"LLVMXtensaInfo",
1376+
};
13331377

13341378
fn generateLangRef(b: *std.Build) std.Build.LazyPath {
13351379
const doctest_exe = b.addExecutable(.{

ci/aarch64-linux-debug.sh

100644100755
Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ unset CXX
4848

4949
ninja install
5050

51-
# simultaneously test building self-hosted without LLVM and with 32-bit arm
52-
stage3-debug/bin/zig build \
53-
-Dtarget=arm-linux-musleabihf \
54-
-Dno-lib
55-
5651
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
5752
stage3-debug/bin/zig build test docs \
5853
--maxrss 24696061952 \
@@ -62,34 +57,12 @@ stage3-debug/bin/zig build test docs \
6257
--zig-lib-dir "$PWD/../lib" \
6358
-Denable-superhtml
6459

65-
# Ensure that updating the wasm binary from this commit will result in a viable build.
66-
stage3-debug/bin/zig build update-zig1
67-
68-
mkdir ../build-new
69-
cd ../build-new
70-
71-
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
72-
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
73-
74-
cmake .. \
75-
-DCMAKE_PREFIX_PATH="$PREFIX" \
76-
-DCMAKE_BUILD_TYPE=Debug \
77-
-DZIG_TARGET_TRIPLE="$TARGET" \
78-
-DZIG_TARGET_MCPU="$MCPU" \
79-
-DZIG_STATIC=ON \
80-
-DZIG_NO_LIB=ON \
81-
-GNinja
82-
83-
unset CC
84-
unset CXX
85-
86-
ninja install
87-
88-
stage3/bin/zig test ../test/behavior.zig
89-
stage3/bin/zig build -p stage4 \
90-
-Dstatic-llvm \
91-
-Dtarget=native-native-musl \
60+
stage3-debug/bin/zig build \
61+
--prefix stage4-debug \
62+
-Denable-llvm \
9263
-Dno-lib \
93-
--search-prefix "$PREFIX" \
94-
--zig-lib-dir "$PWD/../lib"
95-
stage4/bin/zig test ../test/behavior.zig
64+
-Dtarget=$TARGET \
65+
-Duse-zig-libcxx \
66+
-Dversion-string="$(stage3-debug/bin/zig version)"
67+
68+
stage4-debug/bin/zig test ../test/behavior.zig

ci/aarch64-linux-release.sh

100644100755
Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ unset CXX
4848

4949
ninja install
5050

51-
# simultaneously test building self-hosted without LLVM and with 32-bit arm
52-
stage3-release/bin/zig build \
53-
-Dtarget=arm-linux-musleabihf \
54-
-Dno-lib
55-
5651
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
5752
stage3-release/bin/zig build test docs \
5853
--maxrss 24696061952 \
@@ -77,35 +72,3 @@ stage3-release/bin/zig build \
7772
echo "If the following command fails, it means nondeterminism has been"
7873
echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
7974
diff stage3-release/bin/zig stage4-release/bin/zig
80-
81-
# Ensure that updating the wasm binary from this commit will result in a viable build.
82-
stage3-release/bin/zig build update-zig1
83-
84-
mkdir ../build-new
85-
cd ../build-new
86-
87-
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
88-
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
89-
90-
cmake .. \
91-
-DCMAKE_PREFIX_PATH="$PREFIX" \
92-
-DCMAKE_BUILD_TYPE=Release \
93-
-DZIG_TARGET_TRIPLE="$TARGET" \
94-
-DZIG_TARGET_MCPU="$MCPU" \
95-
-DZIG_STATIC=ON \
96-
-DZIG_NO_LIB=ON \
97-
-GNinja
98-
99-
unset CC
100-
unset CXX
101-
102-
ninja install
103-
104-
stage3/bin/zig test ../test/behavior.zig
105-
stage3/bin/zig build -p stage4 \
106-
-Dstatic-llvm \
107-
-Dtarget=native-native-musl \
108-
-Dno-lib \
109-
--search-prefix "$PREFIX" \
110-
--zig-lib-dir "$PWD/../lib"
111-
stage4/bin/zig test ../test/behavior.zig

doc/langref.html.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,22 +3679,22 @@ void do_a_thing(struct Foo *foo) {
36793679
<tr>
36803680
<th scope="row">{#syntax#}.{x}{#endsyntax#}</th>
36813681
<td>{#syntax#}T{#endsyntax#}</td>
3682-
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.meta.FieldType(T, .@"0"){#endsyntax#}</td>
3682+
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}@FieldType(T, "0"){#endsyntax#}</td>
36833683
</tr>
36843684
<tr>
36853685
<th scope="row">{#syntax#}.{ .a = x }{#endsyntax#}</th>
36863686
<td>{#syntax#}T{#endsyntax#}</td>
3687-
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.meta.FieldType(T, .a){#endsyntax#}</td>
3687+
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}@FieldType(T, "a"){#endsyntax#}</td>
36883688
</tr>
36893689
<tr>
36903690
<th scope="row">{#syntax#}T{x}{#endsyntax#}</th>
36913691
<td>-</td>
3692-
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.meta.FieldType(T, .@"0"){#endsyntax#}</td>
3692+
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}@FieldType(T, "0"){#endsyntax#}</td>
36933693
</tr>
36943694
<tr>
36953695
<th scope="row">{#syntax#}T{ .a = x }{#endsyntax#}</th>
36963696
<td>-</td>
3697-
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.meta.FieldType(T, .a){#endsyntax#}</td>
3697+
<td>{#syntax#}x{#endsyntax#} is a {#syntax#}@FieldType(T, "a"){#endsyntax#}</td>
36983698
</tr>
36993699
<tr>
37003700
<th scope="row">{#syntax#}@Type(x){#endsyntax#}</th>

doc/langref/test_multidimensional_arrays.zig

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
const std = @import("std");
22
const expect = std.testing.expect;
3+
const expectEqual = std.testing.expectEqual;
34

4-
const mat4x4 = [4][4]f32{
5-
[_]f32{ 1.0, 0.0, 0.0, 0.0 },
6-
[_]f32{ 0.0, 1.0, 0.0, 1.0 },
7-
[_]f32{ 0.0, 0.0, 1.0, 0.0 },
8-
[_]f32{ 0.0, 0.0, 0.0, 1.0 },
5+
const mat4x5 = [4][5]f32{
6+
[_]f32{ 1.0, 0.0, 0.0, 0.0, 0.0 },
7+
[_]f32{ 0.0, 1.0, 0.0, 1.0, 0.0 },
8+
[_]f32{ 0.0, 0.0, 1.0, 0.0, 0.0 },
9+
[_]f32{ 0.0, 0.0, 0.0, 1.0, 9.9 },
910
};
1011
test "multidimensional arrays" {
12+
// mat4x5 itself is a one-dimensional array of arrays.
13+
try expectEqual(mat4x5[1], [_]f32{ 0.0, 1.0, 0.0, 1.0, 0.0 });
14+
1115
// Access the 2D array by indexing the outer array, and then the inner array.
12-
try expect(mat4x4[1][1] == 1.0);
16+
try expect(mat4x5[3][4] == 9.9);
1317

1418
// Here we iterate with for loops.
15-
for (mat4x4, 0..) |row, row_index| {
19+
for (mat4x5, 0..) |row, row_index| {
1620
for (row, 0..) |cell, column_index| {
1721
if (row_index == column_index) {
1822
try expect(cell == 1.0);
1923
}
2024
}
2125
}
2226

23-
// initialize a multidimensional array to zeros
24-
const all_zero: [4][4]f32 = .{.{0} ** 4} ** 4;
27+
// Initialize a multidimensional array to zeros.
28+
const all_zero: [4][5]f32 = .{.{0} ** 5} ** 4;
2529
try expect(all_zero[0][0] == 0);
2630
}
2731

lib/compiler/aro_translate_c.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
16201620
.root => null,
16211621
.block => ret: {
16221622
const block = @as(*Block, @fieldParentPtr("base", scope));
1623-
break :ret block.getLocalExternAlias(name);
1623+
const alias_name = block.getLocalExternAlias(name);
1624+
if (alias_name) |_alias_name| {
1625+
break :ret _alias_name;
1626+
}
1627+
break :ret scope.parent.?.getLocalExternAlias(name);
16241628
},
16251629
.loop, .do_loop, .condition => scope.parent.?.getLocalExternAlias(name),
16261630
};

lib/compiler/aro_translate_c/ast.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub const Node = extern union {
394394
}
395395

396396
pub fn Data(comptime t: Tag) type {
397-
return std.meta.fieldInfo(t.Type(), .data).type;
397+
return @FieldType(t.Type(), "data");
398398
}
399399
};
400400

lib/compiler/build_runner.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,9 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
12931293
\\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
12941294
\\ --maxrss <bytes> Limit memory usage (default is to use available memory)
12951295
\\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
1296-
\\ --fetch Exit after fetching dependency tree
1296+
\\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
1297+
\\ needed (Default) Lazy dependencies are fetched as needed
1298+
\\ all Lazy dependencies are always fetched
12971299
\\ --watch Continuously rebuild when source files are modified
12981300
\\ --fuzz Continuously search for unit test failures
12991301
\\ --debounce <ms> Delay before rebuilding after changed file detected
@@ -1494,6 +1496,7 @@ fn createModuleDependenciesForStep(step: *Step) Allocator.Error!void {
14941496
.path_after,
14951497
.framework_path,
14961498
.framework_path_system,
1499+
.embed_path,
14971500
=> |lp| lp.addStepDependencies(step),
14981501

14991502
.other_step => |other| {

lib/std/Build/Module.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub const IncludeDir = union(enum) {
164164
framework_path_system: LazyPath,
165165
other_step: *Step.Compile,
166166
config_header_step: *Step.ConfigHeader,
167+
embed_path: LazyPath,
167168

168169
pub fn appendZigProcessFlags(
169170
include_dir: IncludeDir,
@@ -200,6 +201,9 @@ pub const IncludeDir = union(enum) {
200201
const header_dir_path = full_file_path[0 .. full_file_path.len - config_header.include_path.len];
201202
try zig_args.appendSlice(&.{ "-I", header_dir_path });
202203
},
204+
.embed_path => |embed_path| {
205+
try zig_args.append(try std.mem.concat(b.allocator, u8, &.{ "--embed-dir=", embed_path.getPath2(b, asking_step) }));
206+
},
203207
}
204208
}
205209
};
@@ -511,6 +515,11 @@ pub fn addFrameworkPath(m: *Module, directory_path: LazyPath) void {
511515
@panic("OOM");
512516
}
513517

518+
pub fn addEmbedPath(m: *Module, lazy_path: LazyPath) void {
519+
const b = m.owner;
520+
m.include_dirs.append(b.allocator, .{ .embed_path = lazy_path.dupe(b) }) catch @panic("OOM");
521+
}
522+
514523
pub fn addLibraryPath(m: *Module, directory_path: LazyPath) void {
515524
const b = m.owner;
516525
m.lib_paths.append(b.allocator, directory_path.dupe(b)) catch @panic("OOM");

lib/std/Build/Step/Compile.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ const PkgConfigResult = struct {
693693
/// Run pkg-config for the given library name and parse the output, returning the arguments
694694
/// that should be passed to zig to link the given library.
695695
fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
696+
const wl_rpath_prefix = "-Wl,-rpath,";
697+
696698
const b = compile.step.owner;
697699
const pkg_name = match: {
698700
// First we have to map the library name to pkg config name. Unfortunately,
@@ -783,6 +785,8 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
783785
try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });
784786
} else if (mem.startsWith(u8, arg, "-D")) {
785787
try zig_cflags.append(arg);
788+
} else if (mem.startsWith(u8, arg, wl_rpath_prefix)) {
789+
try zig_cflags.appendSlice(&[_][]const u8{ "-rpath", arg[wl_rpath_prefix.len..] });
786790
} else if (b.debug_pkg_config) {
787791
return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});
788792
}
@@ -939,6 +943,10 @@ pub fn addConfigHeader(compile: *Compile, config_header: *Step.ConfigHeader) voi
939943
compile.root_module.addConfigHeader(config_header);
940944
}
941945

946+
pub fn addEmbedPath(compile: *Compile, lazy_path: LazyPath) void {
947+
compile.root_module.addEmbedPath(lazy_path);
948+
}
949+
942950
pub fn addLibraryPath(compile: *Compile, directory_path: LazyPath) void {
943951
compile.root_module.addLibraryPath(directory_path);
944952
}

0 commit comments

Comments
 (0)