Compare commits

...

13 commits

Author SHA1 Message Date
Alex Rønne Petersen
37796492bd
temporarily enable ci in this branch
Some checks failed
ci / aarch64-linux-debug (push) Has been cancelled
ci / aarch64-linux-release (push) Has been cancelled
ci / aarch64-macos-debug (push) Has been cancelled
ci / aarch64-macos-release (push) Has been cancelled
ci / loongarch64-linux-debug (push) Has been cancelled
ci / loongarch64-linux-release (push) Has been cancelled
ci / riscv64-linux-debug (push) Has been cancelled
ci / riscv64-linux-release (push) Has been cancelled
ci / s390x-linux-debug (push) Has been cancelled
ci / s390x-linux-release (push) Has been cancelled
ci / x86_64-freebsd-debug (push) Has been cancelled
ci / x86_64-freebsd-release (push) Has been cancelled
ci / x86_64-linux-debug (push) Has been cancelled
ci / x86_64-linux-debug-llvm (push) Has been cancelled
ci / x86_64-linux-release (push) Has been cancelled
ci / x86_64-windows-debug (push) Has been cancelled
ci / x86_64-windows-release (push) Has been cancelled
2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
52b2ac31e3
ci: set maxrss from $ZSF_MAX_RSS if provided by the runner
All of our runners now define this. When running a CI script locally, this will
not be set, so we default to 0, aka "all available system memory".
2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
2d53eab799
build: adjust max_rss on a per-CI-host basis
This avoids pessimizing concurrency on all machines due to e.g. the macOS
machine having high memory usage across the board due to 16K page size.
2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
44543800a5
std.process.Child: enable rusage collection for dragonfly, netbsd, openbsd 2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
2659fadb95
std.c: add rusage for dragonfly, netbsd, openbsd 2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
9eed87f93e
std.process.Child: enable rusage collection for freebsd, illumos, serenity 2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
e270c97ed1
ci: don't skip release mode tests on x86_64-windows-debug
pulsar is much faster than george so we don't need to do this anymore.
2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
c21ce53494
ci: skip spirv and wasm tests on x86_64-freebsd
These are already built and run on x86_64-linux.
2025-12-04 03:46:36 +01:00
Alex Rønne Petersen
e2a9e568b4
build: add -Dskip-spirv and -Dskip-wasm options 2025-12-04 03:46:35 +01:00
Alex Rønne Petersen
ad9a5187ac
build: add some missing darwin tags 2025-12-04 03:46:35 +01:00
jedisct1
d73fbcc3ae Merge pull request 'Argon2: use the std.Io interface' (#30084) from jedisct1/zig:argon2 into master
Some checks failed
ci / aarch64-linux-debug (push) Has been cancelled
ci / aarch64-linux-release (push) Has been cancelled
ci / aarch64-macos-debug (push) Has been cancelled
ci / aarch64-macos-release (push) Has been cancelled
ci / loongarch64-linux-debug (push) Has been cancelled
ci / loongarch64-linux-release (push) Has been cancelled
ci / riscv64-linux-debug (push) Has been cancelled
ci / riscv64-linux-release (push) Has been cancelled
ci / s390x-linux-debug (push) Has been cancelled
ci / s390x-linux-release (push) Has been cancelled
ci / x86_64-freebsd-debug (push) Has been cancelled
ci / x86_64-freebsd-release (push) Has been cancelled
ci / x86_64-linux-debug (push) Has been cancelled
ci / x86_64-linux-debug-llvm (push) Has been cancelled
ci / x86_64-linux-release (push) Has been cancelled
ci / x86_64-windows-debug (push) Has been cancelled
ci / x86_64-windows-release (push) Has been cancelled
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30084
2025-12-03 12:18:09 +01:00
Zihad
cb115cf73a std.process.ArgIteratorWasi: fix no-args deinit 2025-12-03 08:35:24 +01:00
Frank Denis
6fe95c28cf Argon2: use the std.Io interface
Also reduce the memory required by tests.

4GB for every test is way too much and doesn't provide much benefits
in testing the algorithms.
2025-12-02 23:03:52 +01:00
28 changed files with 344 additions and 74 deletions

View file

@ -5,6 +5,7 @@ on:
push: push:
branches: branches:
- master - master
- max-rss-tuning
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:

182
build.zig
View file

@ -91,6 +91,8 @@ pub fn build(b: *std.Build) !void {
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false; const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false; const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
const skip_compile_errors = b.option(bool, "skip-compile-errors", "Main test suite skips compile error tests") orelse false; const skip_compile_errors = b.option(bool, "skip-compile-errors", "Main test suite skips compile error tests") orelse false;
const skip_spirv = b.option(bool, "skip-spirv", "Main test suite skips targets with spirv32/spirv64 architecture") orelse false;
const skip_wasm = b.option(bool, "skip-wasm", "Main test suite skips targets with wasm32/wasm64 architecture") orelse false;
const skip_freebsd = b.option(bool, "skip-freebsd", "Main test suite skips targets with freebsd OS") orelse false; const skip_freebsd = b.option(bool, "skip-freebsd", "Main test suite skips targets with freebsd OS") orelse false;
const skip_netbsd = b.option(bool, "skip-netbsd", "Main test suite skips targets with netbsd OS") orelse false; const skip_netbsd = b.option(bool, "skip-netbsd", "Main test suite skips targets with netbsd OS") orelse false;
const skip_windows = b.option(bool, "skip-windows", "Main test suite skips targets with windows OS") orelse false; const skip_windows = b.option(bool, "skip-windows", "Main test suite skips targets with windows OS") orelse false;
@ -421,6 +423,8 @@ pub fn build(b: *std.Build) !void {
.test_target_filters = test_target_filters, .test_target_filters = test_target_filters,
.skip_compile_errors = skip_compile_errors, .skip_compile_errors = skip_compile_errors,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.skip_spirv = skip_spirv,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -452,6 +456,8 @@ pub fn build(b: *std.Build) !void {
.skip_single_threaded = skip_single_threaded, .skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.test_default_only = no_matrix, .test_default_only = no_matrix,
.skip_spirv = skip_spirv,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -459,8 +465,29 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux, .skip_linux = skip_linux,
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = skip_libc, .skip_libc = skip_libc,
// 3888779264 was observed on an x86_64-linux-gnu host. .max_rss = switch (b.graph.host.result.os.tag) {
.max_rss = 4000000000, .freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1_060_217_241,
else => 1_100_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 659_809_075,
.loongarch64 => 598_902_374,
.riscv64 => 731_258_880,
.s390x => 580_596_121,
.x86_64 => 3_290_894_745,
else => 3_300_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 767_736_217,
else => 800_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 603_070_054,
else => 700_000_000,
},
else => 3_300_000_000,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -475,6 +502,8 @@ pub fn build(b: *std.Build) !void {
.skip_single_threaded = true, .skip_single_threaded = true,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.test_default_only = no_matrix, .test_default_only = no_matrix,
.skip_spirv = skip_spirv,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -483,6 +512,29 @@ pub fn build(b: *std.Build) !void {
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = true, .skip_libc = true,
.no_builtin = true, .no_builtin = true,
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 743_802_470,
else => 800_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 639_565_414,
.loongarch64 => 598_884_352,
.riscv64 => 636_429_516,
.s390x => 574_166_630,
.x86_64 => 764_861_644,
else => 800_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 701_413_785,
else => 800_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 536_414_208,
else => 600_000_000,
},
else => 1_100_000_000,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -497,6 +549,8 @@ pub fn build(b: *std.Build) !void {
.skip_single_threaded = true, .skip_single_threaded = true,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.test_default_only = no_matrix, .test_default_only = no_matrix,
.skip_spirv = skip_spirv,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -505,6 +559,29 @@ pub fn build(b: *std.Build) !void {
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = true, .skip_libc = true,
.no_builtin = true, .no_builtin = true,
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 557_892_403,
else => 600_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 615_302_758,
.loongarch64 => 598_974_464,
.riscv64 => 382_786_764,
.s390x => 395_555_635,
.x86_64 => 692_348_518,
else => 700_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 451_389_030,
else => 500_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 367_747_072,
else => 400_000_000,
},
else => 700_000_000,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -519,6 +596,8 @@ pub fn build(b: *std.Build) !void {
.skip_single_threaded = skip_single_threaded, .skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.test_default_only = no_matrix, .test_default_only = no_matrix,
.skip_spirv = skip_spirv,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -526,8 +605,29 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux, .skip_linux = skip_linux,
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = skip_libc, .skip_libc = skip_libc,
// I observed a value of 5605064704 on the M2 CI. .max_rss = switch (b.graph.host.result.os.tag) {
.max_rss = 6165571174, .freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 3_756_422_348,
else => 3_800_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6_732_817_203,
.loongarch64 => 3_216_349_593,
.riscv64 => 3_570_899_763,
.s390x => 3_652_514_201,
.x86_64 => 3_249_546_854,
else => 6_800_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 8_273_795_481,
else => 8_300_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 3_750_236_160,
else => 3_800_000_000,
},
else => 8_300_000_000,
},
})); }));
const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests"); const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests");
@ -543,6 +643,29 @@ pub fn build(b: *std.Build) !void {
.use_llvm = use_llvm, .use_llvm = use_llvm,
.use_lld = use_llvm, .use_lld = use_llvm,
.zig_lib_dir = b.path("lib"), .zig_lib_dir = b.path("lib"),
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 2_188_099_584,
else => 2_200_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 1_991_934_771,
.loongarch64 => 1_844_538_572,
.riscv64 => 2_459_003_289,
.s390x => 1_781_248_409,
.x86_64 => 977_192_550,
else => 2_500_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 2_062_393_344,
else => 2_100_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1_953_087_488,
else => 2_000_000_000,
},
else => 2_200_000_000,
},
}); });
if (link_libc) { if (link_libc) {
unit_tests.root_module.link_libc = true; unit_tests.root_module.link_libc = true;
@ -560,6 +683,7 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addCAbiTests(b, .{ test_step.dependOn(tests.addCAbiTests(b, .{
.test_target_filters = test_target_filters, .test_target_filters = test_target_filters,
.skip_non_native = skip_non_native, .skip_non_native = skip_non_native,
.skip_wasm = skip_wasm,
.skip_freebsd = skip_freebsd, .skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd, .skip_netbsd = skip_netbsd,
.skip_windows = skip_windows, .skip_windows = skip_windows,
@ -567,6 +691,29 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux, .skip_linux = skip_linux,
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_release = skip_release, .skip_release = skip_release,
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 566_218_752,
else => 600_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 1_318_185_369,
.loongarch64 => 1_422_904_524,
.riscv64 => 449_924_710,
.s390x => 1_946_743_603,
.x86_64 => 2_139_993_292,
else => 2_200_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 1_813_612_134,
else => 1_900_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 386_287_616,
else => 400_000_000,
},
else => 2_200_000_000,
},
})); }));
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows)); test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native)); test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));
@ -616,6 +763,7 @@ pub fn build(b: *std.Build) !void {
.optimize_modes = optimization_modes, .optimize_modes = optimization_modes,
.test_filters = test_filters, .test_filters = test_filters,
.test_target_filters = test_target_filters, .test_target_filters = test_target_filters,
.skip_wasm = skip_wasm,
// Highest RSS observed in any test case was exactly 1802878976 on x86_64-linux. // Highest RSS observed in any test case was exactly 1802878976 on x86_64-linux.
.max_rss = 2253598720, .max_rss = 2253598720,
})) |test_libc_step| test_step.dependOn(test_libc_step); })) |test_libc_step| test_step.dependOn(test_libc_step);
@ -721,7 +869,29 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu
fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile { fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "zig", .name = "zig",
.max_rss = 7_800_000_000, .max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 6_044_158_771,
else => 6_100_000_000,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6_240_805_683,
.loongarch64 => 5_024_158_515,
.riscv64 => 6_996_309_196,
.s390x => 4_997_174_476,
.x86_64 => 5_486_090_649,
else => 7_000_000_000,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6_639_145_779,
else => 6_700_000_000,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 5_770_394_009,
else => 5_800_000_000,
},
else => 7_000_000_000,
},
.root_module = addCompilerMod(b, options), .root_module = addCompilerMod(b, options),
}); });
exe.stack_size = stack_size; exe.stack_size = stack_size;
@ -798,7 +968,7 @@ fn addCmakeCfgOptionsToExe(
}; };
mod.linkSystemLibrary("unwind", .{}); mod.linkSystemLibrary("unwind", .{});
}, },
.ios, .macos, .watchos, .tvos, .visionos => { .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
mod.link_libcpp = true; mod.link_libcpp = true;
}, },
.windows => { .windows => {

View file

@ -44,7 +44,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 44918199637 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -44,7 +44,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-release/bin/zig build test docs \ stage3-release/bin/zig build test docs \
--maxrss 44918199637 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -42,6 +42,7 @@ cmake .. \
ninja install ninja install
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss ${ZSF_MAX_RSS:-0} \
--zig-lib-dir "$PWD/../lib" \ --zig-lib-dir "$PWD/../lib" \
-Denable-macos-sdk \ -Denable-macos-sdk \
-Dstatic-llvm \ -Dstatic-llvm \

View file

@ -51,6 +51,7 @@ stage3-release/bin/zig build test docs \
# Ensure that stage3 and stage4 are byte-for-byte identical. # Ensure that stage3 and stage4 are byte-for-byte identical.
stage3-release/bin/zig build \ stage3-release/bin/zig build \
--maxrss ${ZSF_MAX_RSS:-0} \
--prefix stage4-release \ --prefix stage4-release \
-Denable-llvm \ -Denable-llvm \
-Dno-lib \ -Dno-lib \

View file

@ -5,6 +5,7 @@ $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip
$PREFIX_PATH = "$(Get-Location)\..\$ZIG_LLVM_CLANG_LLD_NAME" $PREFIX_PATH = "$(Get-Location)\..\$ZIG_LLVM_CLANG_LLD_NAME"
$ZIG = "$PREFIX_PATH\bin\zig.exe" $ZIG = "$PREFIX_PATH\bin\zig.exe"
$ZIG_LIB_DIR = "$(Get-Location)\lib" $ZIG_LIB_DIR = "$(Get-Location)\lib"
$ZSF_MAX_RSS = if ($Env:ZSF_MAX_RSS) { $Env:ZSF_MAX_RSS } else { 0 }
if (!(Test-Path "..\$ZIG_LLVM_CLANG_LLD_NAME.zip")) { if (!(Test-Path "..\$ZIG_LLVM_CLANG_LLD_NAME.zip")) {
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
@ -54,6 +55,7 @@ CheckLastExitCode
Write-Output "Main test suite..." Write-Output "Main test suite..."
& "stage3-release\bin\zig.exe" build test docs ` & "stage3-release\bin\zig.exe" build test docs `
--maxrss $ZSF_MAX_RSS `
--zig-lib-dir "$ZIG_LIB_DIR" ` --zig-lib-dir "$ZIG_LIB_DIR" `
--search-prefix "$PREFIX_PATH" ` --search-prefix "$PREFIX_PATH" `
-Dstatic-llvm ` -Dstatic-llvm `

View file

@ -45,7 +45,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 60129542144 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -45,7 +45,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-release/bin/zig build test docs \ stage3-release/bin/zig build test docs \
--maxrss 60129542144 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -44,7 +44,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-debug/bin/zig build test-cases test-modules test-unit test-c-abi test-stack-traces test-error-traces test-llvm-ir \ stage3-debug/bin/zig build test-cases test-modules test-unit test-c-abi test-stack-traces test-error-traces test-llvm-ir \
--maxrss 68719476736 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dskip-single-threaded \ -Dskip-single-threaded \

View file

@ -44,7 +44,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-release/bin/zig build test-cases test-modules test-unit test-c-abi test-stack-traces test-error-traces test-llvm-ir \ stage3-release/bin/zig build test-cases test-modules test-unit test-c-abi test-stack-traces test-error-traces test-llvm-ir \
--maxrss 68719476736 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dskip-single-threaded \ -Dskip-single-threaded \

View file

@ -45,7 +45,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 30064771072 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -45,7 +45,7 @@ ninja install
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts. # No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
stage3-release/bin/zig build test docs \ stage3-release/bin/zig build test docs \
--maxrss 30064771072 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-non-native \ -Dskip-non-native \
-Dtarget=native-native-musl \ -Dtarget=native-native-musl \

View file

@ -44,8 +44,10 @@ unset CXX
ninja install ninja install
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 42949672960 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-spirv \
-Dskip-wasm \
-Dskip-linux \ -Dskip-linux \
-Dskip-netbsd \ -Dskip-netbsd \
-Dskip-windows \ -Dskip-windows \

View file

@ -44,8 +44,10 @@ unset CXX
ninja install ninja install
stage3-release/bin/zig build test docs \ stage3-release/bin/zig build test docs \
--maxrss 42949672960 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dstatic-llvm \ -Dstatic-llvm \
-Dskip-spirv \
-Dskip-wasm \
-Dskip-linux \ -Dskip-linux \
-Dskip-netbsd \ -Dskip-netbsd \
-Dskip-windows \ -Dskip-windows \

View file

@ -49,7 +49,7 @@ stage3-debug/bin/zig build \
-Dno-lib -Dno-lib
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 21000000000 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \ -Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \
-fqemu \ -fqemu \
-fwasmtime \ -fwasmtime \

View file

@ -48,7 +48,7 @@ stage3-debug/bin/zig build \
-Dno-lib -Dno-lib
stage3-debug/bin/zig build test docs \ stage3-debug/bin/zig build test docs \
--maxrss 21000000000 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \ -Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \
-fqemu \ -fqemu \
-fwasmtime \ -fwasmtime \

View file

@ -54,7 +54,7 @@ stage3-release/bin/zig build \
-Dno-lib -Dno-lib
stage3-release/bin/zig build test docs \ stage3-release/bin/zig build test docs \
--maxrss 21000000000 \ --maxrss ${ZSF_MAX_RSS:-0} \
-Dlldb=$HOME/deps/lldb-zig/Release-e0a42bb34/bin/lldb \ -Dlldb=$HOME/deps/lldb-zig/Release-e0a42bb34/bin/lldb \
-fqemu \ -fqemu \
-fwasmtime \ -fwasmtime \

View file

@ -5,6 +5,7 @@ $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip
$PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME" $PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
$ZIG = "$PREFIX_PATH\bin\zig.exe" $ZIG = "$PREFIX_PATH\bin\zig.exe"
$ZIG_LIB_DIR = "$(Get-Location)\lib" $ZIG_LIB_DIR = "$(Get-Location)\lib"
$ZSF_MAX_RSS = if ($Env:ZSF_MAX_RSS) { $Env:ZSF_MAX_RSS } else { 0 }
if (!(Test-Path "$PREFIX_PATH.zip")) { if (!(Test-Path "$PREFIX_PATH.zip")) {
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
@ -54,12 +55,11 @@ CheckLastExitCode
Write-Output "Main test suite..." Write-Output "Main test suite..."
& "stage3-debug\bin\zig.exe" build test docs ` & "stage3-debug\bin\zig.exe" build test docs `
--maxrss 32212254720 ` --maxrss $ZSF_MAX_RSS `
--zig-lib-dir "$ZIG_LIB_DIR" ` --zig-lib-dir "$ZIG_LIB_DIR" `
--search-prefix "$PREFIX_PATH" ` --search-prefix "$PREFIX_PATH" `
-Dstatic-llvm ` -Dstatic-llvm `
-Dskip-non-native ` -Dskip-non-native `
-Dskip-release `
-Dskip-test-incremental ` -Dskip-test-incremental `
-Denable-symlinks-windows ` -Denable-symlinks-windows `
--test-timeout 30m --test-timeout 30m

View file

@ -5,6 +5,7 @@ $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip
$PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME" $PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
$ZIG = "$PREFIX_PATH\bin\zig.exe" $ZIG = "$PREFIX_PATH\bin\zig.exe"
$ZIG_LIB_DIR = "$(Get-Location)\lib" $ZIG_LIB_DIR = "$(Get-Location)\lib"
$ZSF_MAX_RSS = if ($Env:ZSF_MAX_RSS) { $Env:ZSF_MAX_RSS } else { 0 }
if (!(Test-Path "$PREFIX_PATH.zip")) { if (!(Test-Path "$PREFIX_PATH.zip")) {
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
@ -54,7 +55,7 @@ CheckLastExitCode
Write-Output "Main test suite..." Write-Output "Main test suite..."
& "stage3-release\bin\zig.exe" build test docs ` & "stage3-release\bin\zig.exe" build test docs `
--maxrss 32212254720 ` --maxrss $ZSF_MAX_RSS `
--zig-lib-dir "$ZIG_LIB_DIR" ` --zig-lib-dir "$ZIG_LIB_DIR" `
--search-prefix "$PREFIX_PATH" ` --search-prefix "$PREFIX_PATH" `
-Dstatic-llvm ` -Dstatic-llvm `

View file

@ -4471,7 +4471,7 @@ pub const rusage = switch (native_os) {
pub const SELF = 1; pub const SELF = 1;
pub const CHILDREN = 2; pub const CHILDREN = 2;
}, },
.freebsd => extern struct { .freebsd, .openbsd => extern struct {
utime: timeval, utime: timeval,
stime: timeval, stime: timeval,
maxrss: c_long, maxrss: c_long,
@ -4493,6 +4493,27 @@ pub const rusage = switch (native_os) {
pub const CHILDREN = -1; pub const CHILDREN = -1;
pub const THREAD = 1; pub const THREAD = 1;
}, },
.dragonfly, .netbsd => extern struct {
utime: timeval,
stime: timeval,
maxrss: c_long,
ixrss: c_long,
idrss: c_long,
isrss: c_long,
minflt: c_long,
majflt: c_long,
nswap: c_long,
inblock: c_long,
oublock: c_long,
msgsnd: c_long,
msgrcv: c_long,
nsignals: c_long,
nvcsw: c_long,
nivcsw: c_long,
pub const SELF = 0;
pub const CHILDREN = -1;
},
else => void, else => void,
}; };

View file

@ -7,12 +7,11 @@ const builtin = @import("builtin");
const blake2 = crypto.hash.blake2; const blake2 = crypto.hash.blake2;
const crypto = std.crypto; const crypto = std.crypto;
const Io = std.Io;
const math = std.math; const math = std.math;
const mem = std.mem; const mem = std.mem;
const phc_format = pwhash.phc_format; const phc_format = pwhash.phc_format;
const pwhash = crypto.pwhash; const pwhash = crypto.pwhash;
const Thread = std.Thread;
const Blake2b512 = blake2.Blake2b512; const Blake2b512 = blake2.Blake2b512;
const Blocks = std.array_list.AlignedManaged([block_length]u64, .@"16"); const Blocks = std.array_list.AlignedManaged([block_length]u64, .@"16");
const H0 = [Blake2b512.digest_length + 8]u8; const H0 = [Blake2b512.digest_length + 8]u8;
@ -204,20 +203,20 @@ fn initBlocks(
} }
fn processBlocks( fn processBlocks(
allocator: mem.Allocator,
blocks: *Blocks, blocks: *Blocks,
time: u32, time: u32,
memory: u32, memory: u32,
threads: u24, threads: u24,
mode: Mode, mode: Mode,
) KdfError!void { io: Io,
) void {
const lanes = memory / threads; const lanes = memory / threads;
const segments = lanes / sync_points; const segments = lanes / sync_points;
if (builtin.single_threaded or threads == 1) { if (builtin.single_threaded or threads == 1) {
processBlocksSt(blocks, time, memory, threads, mode, lanes, segments); processBlocksSt(blocks, time, memory, threads, mode, lanes, segments);
} else { } else {
try processBlocksMt(allocator, blocks, time, memory, threads, mode, lanes, segments); processBlocksMt(blocks, time, memory, threads, mode, lanes, segments, io);
} }
} }
@ -243,7 +242,6 @@ fn processBlocksSt(
} }
fn processBlocksMt( fn processBlocksMt(
allocator: mem.Allocator,
blocks: *Blocks, blocks: *Blocks,
time: u32, time: u32,
memory: u32, memory: u32,
@ -251,26 +249,20 @@ fn processBlocksMt(
mode: Mode, mode: Mode,
lanes: u32, lanes: u32,
segments: u32, segments: u32,
) KdfError!void { io: Io,
var threads_list = try std.array_list.Managed(Thread).initCapacity(allocator, threads); ) void {
defer threads_list.deinit();
var n: u32 = 0; var n: u32 = 0;
while (n < time) : (n += 1) { while (n < time) : (n += 1) {
var slice: u32 = 0; var slice: u32 = 0;
while (slice < sync_points) : (slice += 1) { while (slice < sync_points) : (slice += 1) {
var group: Io.Group = .init;
var lane: u24 = 0; var lane: u24 = 0;
while (lane < threads) : (lane += 1) { while (lane < threads) : (lane += 1) {
const thread = try Thread.spawn(.{}, processSegment, .{ group.async(io, processSegment, .{
blocks, time, memory, threads, mode, lanes, segments, n, slice, lane, blocks, time, memory, threads, mode, lanes, segments, n, slice, lane,
}); });
threads_list.appendAssumeCapacity(thread);
} }
lane = 0; group.wait(io);
while (lane < threads) : (lane += 1) {
threads_list.items[lane].join();
}
threads_list.clearRetainingCapacity();
} }
} }
} }
@ -489,6 +481,7 @@ pub fn kdf(
salt: []const u8, salt: []const u8,
params: Params, params: Params,
mode: Mode, mode: Mode,
io: Io,
) KdfError!void { ) KdfError!void {
if (derived_key.len < 4) return KdfError.WeakParameters; if (derived_key.len < 4) return KdfError.WeakParameters;
if (derived_key.len > max_int) return KdfError.OutputTooLong; if (derived_key.len > max_int) return KdfError.OutputTooLong;
@ -510,7 +503,7 @@ pub fn kdf(
blocks.appendNTimesAssumeCapacity(@splat(0), memory); blocks.appendNTimesAssumeCapacity(@splat(0), memory);
initBlocks(&blocks, &h0, memory, params.p); initBlocks(&blocks, &h0, memory, params.p);
try processBlocks(allocator, &blocks, params.t, memory, params.p, mode); processBlocks(&blocks, params.t, memory, params.p, mode, io);
finalize(&blocks, memory, params.p, derived_key); finalize(&blocks, memory, params.p, derived_key);
} }
@ -533,6 +526,7 @@ const PhcFormatHasher = struct {
params: Params, params: Params,
mode: Mode, mode: Mode,
buf: []u8, buf: []u8,
io: Io,
) HasherError![]const u8 { ) HasherError![]const u8 {
if (params.secret != null or params.ad != null) return HasherError.InvalidEncoding; if (params.secret != null or params.ad != null) return HasherError.InvalidEncoding;
@ -540,7 +534,7 @@ const PhcFormatHasher = struct {
crypto.random.bytes(&salt); crypto.random.bytes(&salt);
var hash: [default_hash_len]u8 = undefined; var hash: [default_hash_len]u8 = undefined;
try kdf(allocator, &hash, password, &salt, params, mode); try kdf(allocator, &hash, password, &salt, params, mode, io);
return phc_format.serialize(HashResult{ return phc_format.serialize(HashResult{
.alg_id = @tagName(mode), .alg_id = @tagName(mode),
@ -557,6 +551,7 @@ const PhcFormatHasher = struct {
allocator: mem.Allocator, allocator: mem.Allocator,
str: []const u8, str: []const u8,
password: []const u8, password: []const u8,
io: Io,
) HasherError!void { ) HasherError!void {
const hash_result = try phc_format.deserialize(HashResult, str); const hash_result = try phc_format.deserialize(HashResult, str);
@ -572,7 +567,7 @@ const PhcFormatHasher = struct {
if (expected_hash.len > hash_buf.len) return HasherError.InvalidEncoding; if (expected_hash.len > hash_buf.len) return HasherError.InvalidEncoding;
const hash = hash_buf[0..expected_hash.len]; const hash = hash_buf[0..expected_hash.len];
try kdf(allocator, hash, password, hash_result.salt.constSlice(), params, mode); try kdf(allocator, hash, password, hash_result.salt.constSlice(), params, mode, io);
if (!mem.eql(u8, hash, expected_hash)) return HasherError.PasswordVerificationFailed; if (!mem.eql(u8, hash, expected_hash)) return HasherError.PasswordVerificationFailed;
} }
}; };
@ -595,6 +590,7 @@ pub fn strHash(
password: []const u8, password: []const u8,
options: HashOptions, options: HashOptions,
out: []u8, out: []u8,
io: Io,
) Error![]const u8 { ) Error![]const u8 {
const allocator = options.allocator orelse return Error.AllocatorRequired; const allocator = options.allocator orelse return Error.AllocatorRequired;
switch (options.encoding) { switch (options.encoding) {
@ -604,6 +600,7 @@ pub fn strHash(
options.params, options.params,
options.mode, options.mode,
out, out,
io,
), ),
.crypt => return Error.InvalidEncoding, .crypt => return Error.InvalidEncoding,
} }
@ -621,9 +618,10 @@ pub fn strVerify(
str: []const u8, str: []const u8,
password: []const u8, password: []const u8,
options: VerifyOptions, options: VerifyOptions,
io: Io,
) Error!void { ) Error!void {
const allocator = options.allocator orelse return Error.AllocatorRequired; const allocator = options.allocator orelse return Error.AllocatorRequired;
return PhcFormatHasher.verify(allocator, str, password); return PhcFormatHasher.verify(allocator, str, password, io);
} }
test "argon2d" { test "argon2d" {
@ -640,6 +638,7 @@ test "argon2d" {
&salt, &salt,
.{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad }, .{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad },
.argon2d, .argon2d,
std.testing.io,
); );
const want = [_]u8{ const want = [_]u8{
@ -665,6 +664,7 @@ test "argon2i" {
&salt, &salt,
.{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad }, .{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad },
.argon2i, .argon2i,
std.testing.io,
); );
const want = [_]u8{ const want = [_]u8{
@ -690,6 +690,7 @@ test "argon2id" {
&salt, &salt,
.{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad }, .{ .t = 3, .m = 32, .p = 4, .secret = &secret, .ad = &ad },
.argon2id, .argon2id,
std.testing.io,
); );
const want = [_]u8{ const want = [_]u8{
@ -800,44 +801,44 @@ test "kdf" {
.{ .{
.mode = .argon2i, .mode = .argon2i,
.time = 4, .time = 4,
.memory = 4096, .memory = 256,
.threads = 4, .threads = 4,
.hash = "a11f7b7f3f93f02ad4bddb59ab62d121e278369288a0d0e7", .hash = "f7dbbacbf16999e3700817a7e06f65a8db2e9fa9504ede4c",
}, },
.{ .{
.mode = .argon2d, .mode = .argon2d,
.time = 4, .time = 4,
.memory = 4096, .memory = 256,
.threads = 4, .threads = 4,
.hash = "935598181aa8dc2b720914aa6435ac8d3e3a4210c5b0fb2d", .hash = "ea2970501cf49faa5ba1d2e6370204e9b57ca90a8fea937b",
}, },
.{ .{
.mode = .argon2id, .mode = .argon2id,
.time = 4, .time = 4,
.memory = 4096, .memory = 256,
.threads = 4, .threads = 4,
.hash = "145db9733a9f4ee43edf33c509be96b934d505a4efb33c5a", .hash = "fbd40d5a8cb92f88c20bda4b3cdb1f9d5af1efa937032410",
}, },
.{ .{
.mode = .argon2i, .mode = .argon2i,
.time = 4, .time = 4,
.memory = 1024, .memory = 256,
.threads = 8, .threads = 8,
.hash = "0cdd3956aa35e6b475a7b0c63488822f774f15b43f6e6e17", .hash = "15d3c398364e53f68fd12d19baf3f21432d964254fe27467",
}, },
.{ .{
.mode = .argon2d, .mode = .argon2d,
.time = 4, .time = 4,
.memory = 1024, .memory = 256,
.threads = 8, .threads = 8,
.hash = "83604fc2ad0589b9d055578f4d3cc55bc616df3578a896e9", .hash = "23c9adc06f06e21e4612c1466a1be02627690932b02c0df0",
}, },
.{ .{
.mode = .argon2id, .mode = .argon2id,
.time = 4, .time = 4,
.memory = 1024, .memory = 256,
.threads = 8, .threads = 8,
.hash = "8dafa8e004f8ea96bf7c0f93eecf67a6047476143d15577f", .hash = "f22802f8ca47be93f9954e4ce20c1e944e938fbd4a125d9d",
}, },
.{ .{
.mode = .argon2i, .mode = .argon2i,
@ -863,23 +864,23 @@ test "kdf" {
.{ .{
.mode = .argon2i, .mode = .argon2i,
.time = 3, .time = 3,
.memory = 1024, .memory = 256,
.threads = 6, .threads = 6,
.hash = "d236b29c2b2a09babee842b0dec6aa1e83ccbdea8023dced", .hash = "ebc8f91964abd8ceab49a12963b0a9e57d635bfa2aad2884",
}, },
.{ .{
.mode = .argon2d, .mode = .argon2d,
.time = 3, .time = 3,
.memory = 1024, .memory = 256,
.threads = 6, .threads = 6,
.hash = "a3351b0319a53229152023d9206902f4ef59661cdca89481", .hash = "1dd7202fd68da6675f769f4034b7a1db30d8785331954117",
}, },
.{ .{
.mode = .argon2id, .mode = .argon2id,
.time = 3, .time = 3,
.memory = 1024, .memory = 256,
.threads = 6, .threads = 6,
.hash = "1640b932f4b60e272f5d2207b9a9c626ffa1bd88d2349016", .hash = "424436b6ee22a66b04b9d0cf78f190305c5c166bae8baa09",
}, },
}; };
for (test_vectors) |v| { for (test_vectors) |v| {
@ -894,6 +895,7 @@ test "kdf" {
salt, salt,
.{ .t = v.time, .m = v.memory, .p = v.threads }, .{ .t = v.time, .m = v.memory, .p = v.threads },
v.mode, v.mode,
std.testing.io,
); );
try std.testing.expectEqualSlices(u8, &dk, &want); try std.testing.expectEqualSlices(u8, &dk, &want);
@ -903,6 +905,7 @@ test "kdf" {
test "phc format hasher" { test "phc format hasher" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const password = "testpass"; const password = "testpass";
const io = std.testing.io;
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
const hash = try PhcFormatHasher.create( const hash = try PhcFormatHasher.create(
@ -911,25 +914,29 @@ test "phc format hasher" {
.{ .t = 3, .m = 32, .p = 4 }, .{ .t = 3, .m = 32, .p = 4 },
.argon2id, .argon2id,
&buf, &buf,
io,
); );
try PhcFormatHasher.verify(allocator, hash, password); try PhcFormatHasher.verify(allocator, hash, password, io);
} }
test "password hash and password verify" { test "password hash and password verify" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const password = "testpass"; const password = "testpass";
const io = std.testing.io;
var buf: [128]u8 = undefined; var buf: [128]u8 = undefined;
const hash = try strHash( const hash = try strHash(
password, password,
.{ .allocator = allocator, .params = .{ .t = 3, .m = 32, .p = 4 } }, .{ .allocator = allocator, .params = .{ .t = 3, .m = 32, .p = 4 } },
&buf, &buf,
io,
); );
try strVerify(hash, password, .{ .allocator = allocator }); try strVerify(hash, password, .{ .allocator = allocator }, io);
} }
test "kdf derived key length" { test "kdf derived key length" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const io = std.testing.io;
const password = "testpass"; const password = "testpass";
const salt = "saltsalt"; const salt = "saltsalt";
@ -937,11 +944,11 @@ test "kdf derived key length" {
const mode = Mode.argon2id; const mode = Mode.argon2id;
var dk1: [11]u8 = undefined; var dk1: [11]u8 = undefined;
try kdf(allocator, &dk1, password, salt, params, mode); try kdf(allocator, &dk1, password, salt, params, mode, io);
var dk2: [77]u8 = undefined; var dk2: [77]u8 = undefined;
try kdf(allocator, &dk2, password, salt, params, mode); try kdf(allocator, &dk2, password, salt, params, mode, io);
var dk3: [111]u8 = undefined; var dk3: [111]u8 = undefined;
try kdf(allocator, &dk3, password, salt, params, mode); try kdf(allocator, &dk3, password, salt, params, mode, io);
} }

View file

@ -450,6 +450,7 @@ fn benchmarkPwhash(
comptime ty: anytype, comptime ty: anytype,
comptime params: *const anyopaque, comptime params: *const anyopaque,
comptime count: comptime_int, comptime count: comptime_int,
io: std.Io,
) !f64 { ) !f64 {
const password = "testpass" ** 2; const password = "testpass" ** 2;
const opts = ty.HashOptions{ const opts = ty.HashOptions{
@ -459,12 +460,20 @@ fn benchmarkPwhash(
}; };
var buf: [256]u8 = undefined; var buf: [256]u8 = undefined;
const strHash = ty.strHash;
const strHashFnInfo = @typeInfo(@TypeOf(strHash)).@"fn";
const needs_io = strHashFnInfo.params.len == 4;
var timer = try Timer.start(); var timer = try Timer.start();
const start = timer.lap(); const start = timer.lap();
{ {
var i: usize = 0; var i: usize = 0;
while (i < count) : (i += 1) { while (i < count) : (i += 1) {
_ = try ty.strHash(password, opts, &buf); if (needs_io) {
_ = try strHash(password, opts, &buf, io);
} else {
_ = try strHash(password, opts, &buf);
}
mem.doNotOptimizeAway(&buf); mem.doNotOptimizeAway(&buf);
} }
} }
@ -623,7 +632,7 @@ pub fn main() !void {
inline for (pwhashes) |H| { inline for (pwhashes) |H| {
if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
const throughput = try benchmarkPwhash(arena_allocator, H.ty, H.params, mode(64)); const throughput = try benchmarkPwhash(arena_allocator, H.ty, H.params, mode(64), io);
try stdout.print("{s:>17}: {d:10.3} s/ops\n", .{ H.name, throughput }); try stdout.print("{s:>17}: {d:10.3} s/ops\n", .{ H.name, throughput });
try stdout.flush(); try stdout.flush();
} }

View file

@ -690,6 +690,9 @@ pub const ArgIteratorWasi = struct {
/// Call to free the internal buffer of the iterator. /// Call to free the internal buffer of the iterator.
pub fn deinit(self: *ArgIteratorWasi) void { pub fn deinit(self: *ArgIteratorWasi) void {
// Nothing is allocated when there are no args
if (self.args.len == 0) return;
const last_item = self.args[self.args.len - 1]; const last_item = self.args[self.args.len - 1];
const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated const last_byte_addr = @intFromPtr(last_item.ptr) + last_item.len + 1; // null terminated
const first_item_ptr = self.args[0].ptr; const first_item_ptr = self.args[0].ptr;

View file

@ -122,7 +122,7 @@ pub const ResourceUsageStatistics = struct {
/// if available. /// if available.
pub inline fn getMaxRss(rus: ResourceUsageStatistics) ?usize { pub inline fn getMaxRss(rus: ResourceUsageStatistics) ?usize {
switch (native_os) { switch (native_os) {
.linux => { .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .linux, .serenity => {
if (rus.rusage) |ru| { if (rus.rusage) |ru| {
return @as(usize, @intCast(ru.maxrss)) * 1024; return @as(usize, @intCast(ru.maxrss)) * 1024;
} else { } else {
@ -149,7 +149,21 @@ pub const ResourceUsageStatistics = struct {
} }
const rusage_init = switch (native_os) { const rusage_init = switch (native_os) {
.linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => @as(?posix.rusage, null), .dragonfly,
.freebsd,
.netbsd,
.openbsd,
.illumos,
.linux,
.serenity,
.driverkit,
.ios,
.maccatalyst,
.macos,
.tvos,
.visionos,
.watchos,
=> @as(?posix.rusage, null),
.windows => @as(?windows.VM_COUNTERS, null), .windows => @as(?windows.VM_COUNTERS, null),
else => {}, else => {},
}; };
@ -486,7 +500,21 @@ fn waitUnwrappedPosix(self: *ChildProcess) void {
const res: posix.WaitPidResult = res: { const res: posix.WaitPidResult = res: {
if (self.request_resource_usage_statistics) { if (self.request_resource_usage_statistics) {
switch (native_os) { switch (native_os) {
.linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => { .dragonfly,
.freebsd,
.netbsd,
.openbsd,
.illumos,
.linux,
.serenity,
.driverkit,
.ios,
.maccatalyst,
.macos,
.tvos,
.visionos,
.watchos,
=> {
var ru: posix.rusage = undefined; var ru: posix.rusage = undefined;
const res = posix.wait4(self.id, 0, &ru); const res = posix.wait4(self.id, 0, &ru);
self.resource_usage_statistics.rusage = ru; self.resource_usage_statistics.rusage = ru;

View file

@ -444,6 +444,8 @@ pub const CaseTestOptions = struct {
test_target_filters: []const []const u8, test_target_filters: []const []const u8,
skip_compile_errors: bool, skip_compile_errors: bool,
skip_non_native: bool, skip_non_native: bool,
skip_spirv: bool,
skip_wasm: bool,
skip_freebsd: bool, skip_freebsd: bool,
skip_netbsd: bool, skip_netbsd: bool,
skip_windows: bool, skip_windows: bool,
@ -472,6 +474,9 @@ pub fn lowerToBuildSteps(
if (options.skip_non_native and !case.target.query.isNative()) if (options.skip_non_native and !case.target.query.isNative())
continue; continue;
if (options.skip_spirv and case.target.query.cpu_arch != null and case.target.query.cpu_arch.?.isSpirV()) continue;
if (options.skip_wasm and case.target.query.cpu_arch != null and case.target.query.cpu_arch.?.isWasm()) continue;
if (options.skip_freebsd and case.target.query.os_tag == .freebsd) continue; if (options.skip_freebsd and case.target.query.os_tag == .freebsd) continue;
if (options.skip_netbsd and case.target.query.os_tag == .netbsd) continue; if (options.skip_netbsd and case.target.query.os_tag == .netbsd) continue;
if (options.skip_windows and case.target.query.os_tag == .windows) continue; if (options.skip_windows and case.target.query.os_tag == .windows) continue;

View file

@ -10,6 +10,7 @@ pub const Options = struct {
optimize_modes: []const std.builtin.OptimizeMode, optimize_modes: []const std.builtin.OptimizeMode,
test_filters: []const []const u8, test_filters: []const []const u8,
test_target_filters: []const []const u8, test_target_filters: []const []const u8,
skip_wasm: bool,
max_rss: usize, max_rss: usize,
}; };
@ -41,6 +42,8 @@ pub fn addLibcTestCase(
} }
pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void { pub fn addTarget(libc: *const Libc, target: std.Build.ResolvedTarget) void {
if (libc.options.skip_wasm and target.query.cpu_arch != null and target.query.cpu_arch.?.isWasm()) return;
if (libc.options.test_target_filters.len > 0) { if (libc.options.test_target_filters.len > 0) {
const triple_txt = target.query.zigTriple(libc.b.allocator) catch @panic("OOM"); const triple_txt = target.query.zigTriple(libc.b.allocator) catch @panic("OOM");
for (libc.options.test_target_filters) |filter| { for (libc.options.test_target_filters) |filter| {

View file

@ -2246,6 +2246,8 @@ const ModuleTestOptions = struct {
test_default_only: bool, test_default_only: bool,
skip_single_threaded: bool, skip_single_threaded: bool,
skip_non_native: bool, skip_non_native: bool,
skip_spirv: bool,
skip_wasm: bool,
skip_freebsd: bool, skip_freebsd: bool,
skip_netbsd: bool, skip_netbsd: bool,
skip_windows: bool, skip_windows: bool,
@ -2281,6 +2283,9 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
if (options.skip_non_native and !test_target.target.isNative()) if (options.skip_non_native and !test_target.target.isNative())
continue; continue;
if (options.skip_spirv and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isSpirV()) continue;
if (options.skip_wasm and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isWasm()) continue;
if (options.skip_freebsd and test_target.target.os_tag == .freebsd) continue; if (options.skip_freebsd and test_target.target.os_tag == .freebsd) continue;
if (options.skip_netbsd and test_target.target.os_tag == .netbsd) continue; if (options.skip_netbsd and test_target.target.os_tag == .netbsd) continue;
if (options.skip_windows and test_target.target.os_tag == .windows) continue; if (options.skip_windows and test_target.target.os_tag == .windows) continue;
@ -2339,8 +2344,11 @@ fn addOneModuleTest(
const libc_suffix = if (test_target.link_libc == true) "-libc" else ""; const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
const model_txt = target.cpu.model.name; const model_txt = target.cpu.model.name;
// wasm32-wasi builds need more RAM, idk why // These emulated targets need a lot more RAM for unknown reasons.
const max_rss = if (target.os.tag == .wasi) const max_rss = if (mem.eql(u8, options.name, "std") and
(target.cpu.arch == .hexagon or
(target.cpu.arch.isRISCV() and !resolved_target.query.isNative()) or
target.cpu.arch.isWasm()))
options.max_rss * 2 options.max_rss * 2
else else
options.max_rss; options.max_rss;
@ -2519,6 +2527,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
const CAbiTestOptions = struct { const CAbiTestOptions = struct {
test_target_filters: []const []const u8, test_target_filters: []const []const u8,
skip_non_native: bool, skip_non_native: bool,
skip_wasm: bool,
skip_freebsd: bool, skip_freebsd: bool,
skip_netbsd: bool, skip_netbsd: bool,
skip_windows: bool, skip_windows: bool,
@ -2526,6 +2535,7 @@ const CAbiTestOptions = struct {
skip_linux: bool, skip_linux: bool,
skip_llvm: bool, skip_llvm: bool,
skip_release: bool, skip_release: bool,
max_rss: usize = 0,
}; };
pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
@ -2538,6 +2548,9 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
for (c_abi_targets) |c_abi_target| { for (c_abi_targets) |c_abi_target| {
if (options.skip_non_native and !c_abi_target.target.isNative()) continue; if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue; if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue; if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;
if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue; if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;
@ -2595,6 +2608,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
.root_module = test_mod, .root_module = test_mod,
.use_llvm = c_abi_target.use_llvm, .use_llvm = c_abi_target.use_llvm,
.use_lld = c_abi_target.use_lld, .use_lld = c_abi_target.use_lld,
.max_rss = options.max_rss,
}); });
// This test is intentionally trying to check if the external ABI is // This test is intentionally trying to check if the external ABI is