Skip to content

Commit 2bbf6e1

Browse files
authored
Merge branch 'master' into iouring_bind
2 parents d6a7acc + cfcd669 commit 2bbf6e1

File tree

305 files changed

+13093
-8422
lines changed

Some content is hidden

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

305 files changed

+13093
-8422
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ set(ZIG_STAGE2_SOURCES
296296
"${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig"
297297
"${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig"
298298
"${CMAKE_SOURCE_DIR}/lib/std/os.zig"
299-
"${CMAKE_SOURCE_DIR}/lib/std/os/darwin.zig"
300299
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
301300
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig"
302301
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
@@ -506,7 +505,9 @@ set(ZIG_STAGE2_SOURCES
506505
"${CMAKE_SOURCE_DIR}/lib/std/Thread.zig"
507506
"${CMAKE_SOURCE_DIR}/lib/std/Thread/Futex.zig"
508507
"${CMAKE_SOURCE_DIR}/lib/std/Thread/Mutex.zig"
508+
"${CMAKE_SOURCE_DIR}/lib/std/Thread/Pool.zig"
509509
"${CMAKE_SOURCE_DIR}/lib/std/Thread/ResetEvent.zig"
510+
"${CMAKE_SOURCE_DIR}/lib/std/Thread/WaitGroup.zig"
510511
"${CMAKE_SOURCE_DIR}/lib/std/time.zig"
511512
"${CMAKE_SOURCE_DIR}/lib/std/treap.zig"
512513
"${CMAKE_SOURCE_DIR}/lib/std/unicode.zig"
@@ -516,6 +517,7 @@ set(ZIG_STAGE2_SOURCES
516517
"${CMAKE_SOURCE_DIR}/lib/std/zig/c_builtins.zig"
517518
"${CMAKE_SOURCE_DIR}/lib/std/zig/Parse.zig"
518519
"${CMAKE_SOURCE_DIR}/lib/std/zig/render.zig"
520+
"${CMAKE_SOURCE_DIR}/lib/std/zig/Server.zig"
519521
"${CMAKE_SOURCE_DIR}/lib/std/zig/string_literal.zig"
520522
"${CMAKE_SOURCE_DIR}/lib/std/zig/system.zig"
521523
"${CMAKE_SOURCE_DIR}/lib/std/zig/system/NativePaths.zig"
@@ -530,9 +532,7 @@ set(ZIG_STAGE2_SOURCES
530532
"${CMAKE_SOURCE_DIR}/src/Package.zig"
531533
"${CMAKE_SOURCE_DIR}/src/RangeSet.zig"
532534
"${CMAKE_SOURCE_DIR}/src/Sema.zig"
533-
"${CMAKE_SOURCE_DIR}/src/ThreadPool.zig"
534535
"${CMAKE_SOURCE_DIR}/src/TypedValue.zig"
535-
"${CMAKE_SOURCE_DIR}/src/WaitGroup.zig"
536536
"${CMAKE_SOURCE_DIR}/src/Zir.zig"
537537
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/CodeGen.zig"
538538
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/Emit.zig"

build.zig

Lines changed: 112 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub fn build(b: *std.Build) !void {
3131
const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
3232

3333
const test_step = b.step("test", "Run all the tests");
34+
const deprecated_skip_install_lib_files = b.option(bool, "skip-install-lib-files", "deprecated. see no-lib") orelse false;
35+
if (deprecated_skip_install_lib_files) {
36+
std.log.warn("-Dskip-install-lib-files is deprecated in favor of -Dno-lib", .{});
37+
}
38+
const skip_install_lib_files = b.option(bool, "no-lib", "skip copying of lib/ files and langref to installation prefix. Useful for development") orelse deprecated_skip_install_lib_files;
3439

3540
const docgen_exe = b.addExecutable(.{
3641
.name = "docgen",
@@ -40,28 +45,35 @@ pub fn build(b: *std.Build) !void {
4045
});
4146
docgen_exe.single_threaded = single_threaded;
4247

43-
const langref_out_path = try b.cache_root.join(b.allocator, &.{"langref.html"});
44-
const docgen_cmd = docgen_exe.run();
45-
docgen_cmd.addArgs(&[_][]const u8{
46-
"--zig",
47-
b.zig_exe,
48-
"doc" ++ fs.path.sep_str ++ "langref.html.in",
49-
langref_out_path,
50-
});
51-
docgen_cmd.step.dependOn(&docgen_exe.step);
48+
const docgen_cmd = b.addRunArtifact(docgen_exe);
49+
docgen_cmd.addArgs(&.{ "--zig", b.zig_exe });
50+
if (b.zig_lib_dir) |p| {
51+
docgen_cmd.addArgs(&.{ "--zig-lib-dir", p });
52+
}
53+
docgen_cmd.addFileSourceArg(.{ .path = "doc/langref.html.in" });
54+
const langref_file = docgen_cmd.addOutputFileArg("langref.html");
55+
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
56+
if (!skip_install_lib_files) {
57+
b.getInstallStep().dependOn(&install_langref.step);
58+
}
5259

5360
const docs_step = b.step("docs", "Build documentation");
5461
docs_step.dependOn(&docgen_cmd.step);
5562

56-
const test_cases = b.addTest(.{
57-
.root_source_file = .{ .path = "src/test.zig" },
63+
// This is for legacy reasons, to be removed after our CI scripts are upgraded to use
64+
// the file from the install prefix instead.
65+
const legacy_write_to_cache = b.addWriteFiles();
66+
legacy_write_to_cache.addCopyFileToSource(langref_file, "zig-cache/langref.html");
67+
docs_step.dependOn(&legacy_write_to_cache.step);
68+
69+
const check_case_exe = b.addExecutable(.{
70+
.name = "check-case",
71+
.root_source_file = .{ .path = "test/src/Cases.zig" },
5872
.optimize = optimize,
5973
});
60-
test_cases.main_pkg_path = ".";
61-
test_cases.stack_size = stack_size;
62-
test_cases.single_threaded = single_threaded;
63-
64-
const fmt_build_zig = b.addFmt(&[_][]const u8{"build.zig"});
74+
check_case_exe.main_pkg_path = ".";
75+
check_case_exe.stack_size = stack_size;
76+
check_case_exe.single_threaded = single_threaded;
6577

6678
const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
6779
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
@@ -74,11 +86,6 @@ pub fn build(b: *std.Build) !void {
7486
const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false;
7587
const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;
7688
const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false;
77-
const deprecated_skip_install_lib_files = b.option(bool, "skip-install-lib-files", "deprecated. see no-lib") orelse false;
78-
if (deprecated_skip_install_lib_files) {
79-
std.log.warn("-Dskip-install-lib-files is deprecated in favor of -Dno-lib", .{});
80-
}
81-
const skip_install_lib_files = b.option(bool, "no-lib", "skip copying of lib/ files to installation prefix. Useful for development") orelse deprecated_skip_install_lib_files;
8289

8390
const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
8491

@@ -175,13 +182,12 @@ pub fn build(b: *std.Build) !void {
175182
test_step.dependOn(&exe.step);
176183
}
177184

178-
b.default_step.dependOn(&exe.step);
179185
exe.single_threaded = single_threaded;
180186

181187
if (target.isWindows() and target.getAbi() == .gnu) {
182188
// LTO is currently broken on mingw, this can be removed when it's fixed.
183189
exe.want_lto = false;
184-
test_cases.want_lto = false;
190+
check_case_exe.want_lto = false;
185191
}
186192

187193
const exe_options = b.addOptions();
@@ -195,11 +201,11 @@ pub fn build(b: *std.Build) !void {
195201
exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
196202
exe_options.addOption(bool, "force_gpa", force_gpa);
197203
exe_options.addOption(bool, "only_c", only_c);
198-
exe_options.addOption(bool, "omit_pkg_fetching_code", false);
204+
exe_options.addOption(bool, "omit_pkg_fetching_code", only_c);
199205

200206
if (link_libc) {
201207
exe.linkLibC();
202-
test_cases.linkLibC();
208+
check_case_exe.linkLibC();
203209
}
204210

205211
const is_debug = optimize == .Debug;
@@ -285,14 +291,14 @@ pub fn build(b: *std.Build) !void {
285291
}
286292

287293
try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
288-
try addCmakeCfgOptionsToExe(b, cfg, test_cases, use_zig_libcxx);
294+
try addCmakeCfgOptionsToExe(b, cfg, check_case_exe, use_zig_libcxx);
289295
} else {
290296
// Here we are -Denable-llvm but no cmake integration.
291297
try addStaticLlvmOptionsToExe(exe);
292-
try addStaticLlvmOptionsToExe(test_cases);
298+
try addStaticLlvmOptionsToExe(check_case_exe);
293299
}
294300
if (target.isWindows()) {
295-
inline for (.{ exe, test_cases }) |artifact| {
301+
inline for (.{ exe, check_case_exe }) |artifact| {
296302
artifact.linkSystemLibrary("version");
297303
artifact.linkSystemLibrary("uuid");
298304
artifact.linkSystemLibrary("ole32");
@@ -337,8 +343,9 @@ pub fn build(b: *std.Build) !void {
337343
const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
338344

339345
const test_cases_options = b.addOptions();
340-
test_cases.addOptions("build_options", test_cases_options);
346+
check_case_exe.addOptions("build_options", test_cases_options);
341347

348+
test_cases_options.addOption(bool, "enable_tracy", false);
342349
test_cases_options.addOption(bool, "enable_logging", enable_logging);
343350
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
344351
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
@@ -361,12 +368,6 @@ pub fn build(b: *std.Build) !void {
361368
test_cases_options.addOption(std.SemanticVersion, "semver", semver);
362369
test_cases_options.addOption(?[]const u8, "test_filter", test_filter);
363370

364-
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
365-
test_cases_step.dependOn(&test_cases.step);
366-
if (!skip_stage2_tests) {
367-
test_step.dependOn(test_cases_step);
368-
}
369-
370371
var chosen_opt_modes_buf: [4]builtin.Mode = undefined;
371372
var chosen_mode_index: usize = 0;
372373
if (!skip_debug) {
@@ -387,96 +388,101 @@ pub fn build(b: *std.Build) !void {
387388
}
388389
const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
389390

390-
// run stage1 `zig fmt` on this build.zig file just to make sure it works
391-
test_step.dependOn(&fmt_build_zig.step);
392-
const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
393-
fmt_step.dependOn(&fmt_build_zig.step);
394-
395-
test_step.dependOn(tests.addPkgTests(
396-
b,
397-
test_filter,
398-
"test/behavior.zig",
399-
"behavior",
400-
"Run the behavior tests",
401-
optimization_modes,
402-
skip_single_threaded,
403-
skip_non_native,
404-
skip_libc,
405-
skip_stage1,
406-
skip_stage2_tests,
407-
));
391+
const fmt_include_paths = &.{ "doc", "lib", "src", "test", "tools", "build.zig" };
392+
const fmt_exclude_paths = &.{"test/cases"};
393+
const do_fmt = b.addFmt(.{
394+
.paths = fmt_include_paths,
395+
.exclude_paths = fmt_exclude_paths,
396+
});
408397

409-
test_step.dependOn(tests.addPkgTests(
410-
b,
411-
test_filter,
412-
"lib/compiler_rt.zig",
413-
"compiler-rt",
414-
"Run the compiler_rt tests",
415-
optimization_modes,
416-
true, // skip_single_threaded
417-
skip_non_native,
418-
true, // skip_libc
419-
skip_stage1,
420-
skip_stage2_tests or true, // TODO get these all passing
421-
));
398+
b.step("test-fmt", "Check source files having conforming formatting").dependOn(&b.addFmt(.{
399+
.paths = fmt_include_paths,
400+
.exclude_paths = fmt_exclude_paths,
401+
.check = true,
402+
}).step);
422403

423-
test_step.dependOn(tests.addPkgTests(
424-
b,
425-
test_filter,
426-
"lib/c.zig",
427-
"universal-libc",
428-
"Run the universal libc tests",
429-
optimization_modes,
430-
true, // skip_single_threaded
431-
skip_non_native,
432-
true, // skip_libc
433-
skip_stage1,
434-
skip_stage2_tests or true, // TODO get these all passing
435-
));
404+
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
405+
try tests.addCases(b, test_cases_step, test_filter, check_case_exe);
406+
if (!skip_stage2_tests) test_step.dependOn(test_cases_step);
407+
408+
test_step.dependOn(tests.addModuleTests(b, .{
409+
.test_filter = test_filter,
410+
.root_src = "test/behavior.zig",
411+
.name = "behavior",
412+
.desc = "Run the behavior tests",
413+
.optimize_modes = optimization_modes,
414+
.skip_single_threaded = skip_single_threaded,
415+
.skip_non_native = skip_non_native,
416+
.skip_libc = skip_libc,
417+
.skip_stage1 = skip_stage1,
418+
.skip_stage2 = skip_stage2_tests,
419+
.max_rss = 1 * 1024 * 1024 * 1024,
420+
}));
421+
422+
test_step.dependOn(tests.addModuleTests(b, .{
423+
.test_filter = test_filter,
424+
.root_src = "lib/compiler_rt.zig",
425+
.name = "compiler-rt",
426+
.desc = "Run the compiler_rt tests",
427+
.optimize_modes = optimization_modes,
428+
.skip_single_threaded = true,
429+
.skip_non_native = skip_non_native,
430+
.skip_libc = true,
431+
.skip_stage1 = skip_stage1,
432+
.skip_stage2 = true, // TODO get all these passing
433+
}));
434+
435+
test_step.dependOn(tests.addModuleTests(b, .{
436+
.test_filter = test_filter,
437+
.root_src = "lib/c.zig",
438+
.name = "universal-libc",
439+
.desc = "Run the universal libc tests",
440+
.optimize_modes = optimization_modes,
441+
.skip_single_threaded = true,
442+
.skip_non_native = skip_non_native,
443+
.skip_libc = true,
444+
.skip_stage1 = skip_stage1,
445+
.skip_stage2 = true, // TODO get all these passing
446+
}));
436447

437448
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
438449
test_step.dependOn(tests.addStandaloneTests(
439450
b,
440-
test_filter,
441451
optimization_modes,
442-
skip_non_native,
443452
enable_macos_sdk,
444-
target,
445453
skip_stage2_tests,
446-
b.enable_darling,
447-
b.enable_qemu,
448-
b.enable_rosetta,
449-
b.enable_wasmtime,
450-
b.enable_wine,
451454
enable_symlinks_windows,
452455
));
453456
test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
454-
test_step.dependOn(tests.addLinkTests(b, test_filter, optimization_modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
457+
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
455458
test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));
456-
test_step.dependOn(tests.addCliTests(b, test_filter, optimization_modes));
459+
test_step.dependOn(tests.addCliTests(b));
457460
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes));
458461
test_step.dependOn(tests.addTranslateCTests(b, test_filter));
459462
if (!skip_run_translated_c) {
460463
test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
461464
}
462-
// tests for this feature are disabled until we have the self-hosted compiler available
463-
// test_step.dependOn(tests.addGenHTests(b, test_filter));
464465

465-
test_step.dependOn(tests.addPkgTests(
466-
b,
467-
test_filter,
468-
"lib/std/std.zig",
469-
"std",
470-
"Run the standard library tests",
471-
optimization_modes,
472-
skip_single_threaded,
473-
skip_non_native,
474-
skip_libc,
475-
skip_stage1,
476-
true, // TODO get these all passing
477-
));
466+
test_step.dependOn(tests.addModuleTests(b, .{
467+
.test_filter = test_filter,
468+
.root_src = "lib/std/std.zig",
469+
.name = "std",
470+
.desc = "Run the standard library tests",
471+
.optimize_modes = optimization_modes,
472+
.skip_single_threaded = skip_single_threaded,
473+
.skip_non_native = skip_non_native,
474+
.skip_libc = skip_libc,
475+
.skip_stage1 = skip_stage1,
476+
.skip_stage2 = true, // TODO get all these passing
477+
// I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
478+
// get this amount:
479+
.max_rss = 3738102579,
480+
}));
478481

479482
try addWasiUpdateStep(b, version);
483+
484+
b.step("fmt", "Modify source files in place to have conforming formatting")
485+
.dependOn(&do_fmt.step);
480486
}
481487

482488
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
@@ -505,6 +511,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
505511
exe_options.addOption(bool, "enable_tracy_callstack", false);
506512
exe_options.addOption(bool, "enable_tracy_allocation", false);
507513
exe_options.addOption(bool, "value_tracing", false);
514+
exe_options.addOption(bool, "omit_pkg_fetching_code", true);
508515

509516
const run_opt = b.addSystemCommand(&.{ "wasm-opt", "-Oz", "--enable-bulk-memory" });
510517
run_opt.addArtifactArg(exe);
@@ -676,10 +683,7 @@ fn addCxxKnownPath(
676683
) !void {
677684
if (!std.process.can_spawn)
678685
return error.RequiredLibraryNotFound;
679-
const path_padded = try b.exec(&[_][]const u8{
680-
ctx.cxx_compiler,
681-
b.fmt("-print-file-name={s}", .{objname}),
682-
});
686+
const path_padded = b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
683687
var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
684688
const path_unpadded = tokenizer.next().?;
685689
if (mem.eql(u8, path_unpadded, objname)) {

ci/aarch64-linux-debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ stage3-debug/bin/zig build test docs \
6767
--zig-lib-dir "$(pwd)/../lib"
6868

6969
# Look for HTML errors.
70-
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
70+
tidy --drop-empty-elements no -qe "stage3-debug/doc/langref.html"
7171

7272
# Produce the experimental std lib documentation.
7373
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib

ci/aarch64-linux-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ stage3-release/bin/zig build test docs \
6767
--zig-lib-dir "$(pwd)/../lib"
6868

6969
# Look for HTML errors.
70-
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
70+
tidy --drop-empty-elements no -qe "stage3-release/doc/langref.html"
7171

7272
# Produce the experimental std lib documentation.
7373
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib

0 commit comments

Comments
 (0)