diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index ff3d6bbb5b..59893e1e95 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -195,6 +195,27 @@ jobs: run: sh ci/x86_64-linux-release.sh timeout-minutes: 360 + x86_64-openbsd-debug: + runs-on: [self-hosted, x86_64-openbsd] + steps: + - name: Checkout + uses: https://codeberg.org/ziglang/checkout@19af6bac491e2534a4687a50ee84fa7f13258d28 + with: + fetch-depth: 0 + - name: Build and Test + run: sh ci/x86_64-openbsd-debug.sh + timeout-minutes: 120 + x86_64-openbsd-release: + runs-on: [self-hosted, x86_64-openbsd] + steps: + - name: Checkout + uses: https://codeberg.org/ziglang/checkout@19af6bac491e2534a4687a50ee84fa7f13258d28 + with: + fetch-depth: 0 + - name: Build and Test + run: sh ci/x86_64-openbsd-release.sh + timeout-minutes: 120 + x86_64-windows-debug: runs-on: [self-hosted, x86_64-windows] steps: diff --git a/ci/x86_64-openbsd-debug.sh b/ci/x86_64-openbsd-debug.sh new file mode 100755 index 0000000000..133c8dd4d6 --- /dev/null +++ b/ci/x86_64-openbsd-debug.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +TARGET="x86_64-openbsd-none" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.2051+28b83e3b0" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +# Override the cache directories because they won't actually help other CI runs +# which will be testing alternate versions of zig, and ultimately would just +# fill up space on the hard drive for no reason. +export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" +export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" + +mkdir build-debug +cd build-debug + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-debug" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -DZIG_NO_LIB=ON \ + -GNinja \ + -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ + -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE +# https://github.com/ziglang/zig/issues/22213 + +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX + +ninja install + +stage3-debug/bin/zig build test docs \ + --maxrss ${ZSF_MAX_RSS:-0} \ + -Dstatic-llvm \ + -Dskip-non-native \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$PWD/../lib" \ + --test-timeout 2m + +stage3-debug/bin/zig build \ + --prefix stage4-debug \ + -Denable-llvm \ + -Dno-lib \ + -Dtarget=$TARGET \ + -Duse-zig-libcxx \ + -Dversion-string="$(stage3-debug/bin/zig version)" + +stage4-debug/bin/zig test ../test/behavior.zig diff --git a/ci/x86_64-openbsd-release.sh b/ci/x86_64-openbsd-release.sh new file mode 100755 index 0000000000..535b1a1471 --- /dev/null +++ b/ci/x86_64-openbsd-release.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +TARGET="x86_64-openbsd-none" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.2051+28b83e3b0" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +# Override the cache directories because they won't actually help other CI runs +# which will be testing alternate versions of zig, and ultimately would just +# fill up space on the hard drive for no reason. +export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" +export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" + +mkdir build-release +cd build-release + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -DZIG_NO_LIB=ON \ + -GNinja \ + -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ + -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE +# https://github.com/ziglang/zig/issues/22213 + +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX + +ninja install + +stage3-release/bin/zig build test docs \ + --maxrss ${ZSF_MAX_RSS:-0} \ + -Dstatic-llvm \ + -Dskip-non-native \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$PWD/../lib" \ + --test-timeout 2m + +# Ensure that stage3 and stage4 are byte-for-byte identical. +stage3-release/bin/zig build \ + --prefix stage4-release \ + -Denable-llvm \ + -Dno-lib \ + -Doptimize=ReleaseFast \ + -Dstrip \ + -Dtarget=$TARGET \ + -Duse-zig-libcxx \ + -Dversion-string="$(stage3-release/bin/zig version)" + +# diff returns an error code if the files differ. +echo "If the following command fails, it means nondeterminism has been" +echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." +diff stage3-release/bin/zig stage4-release/bin/zig diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index a9fdab1ae0..63c51e6ed5 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1130,6 +1130,7 @@ test "renameAbsolute" { test "openExecutable" { if (native_os == .wasi) return error.SkipZigTest; + if (native_os == .openbsd) return error.SkipZigTest; const io = testing.io; @@ -1139,6 +1140,7 @@ test "openExecutable" { test "executablePath" { if (native_os == .wasi) return error.SkipZigTest; + if (native_os == .openbsd) return error.SkipZigTest; const io = testing.io; var buf: [Dir.max_path_bytes]u8 = undefined; diff --git a/test/error_traces.zig b/test/error_traces.zig index 9f1bcd027b..ef33a458c6 100644 --- a/test/error_traces.zig +++ b/test/error_traces.zig @@ -439,6 +439,7 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void { .{ .powerpc64le, .linux }, .{ .riscv64, .linux }, .{ .s390x, .linux }, + .{ .x86_64, .openbsd }, .{ .x86_64, .windows }, .{ .x86, .windows }, .{ .x86_64, .macos }, diff --git a/test/standalone/libfuzzer/build.zig b/test/standalone/libfuzzer/build.zig index 54cc977abe..ea3ae12e45 100644 --- a/test/standalone/libfuzzer/build.zig +++ b/test/standalone/libfuzzer/build.zig @@ -6,6 +6,7 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); if (builtin.os.tag == .windows) return; // TODO: libfuzzer support for windows + if (builtin.os.tag == .openbsd) return; // https://codeberg.org/ziglang/zig/issues/30728 const run_step = b.step("run", "Run executables"); const exe = b.addExecutable(.{ diff --git a/test/standalone/self_exe_symlink/build.zig b/test/standalone/self_exe_symlink/build.zig index 137848b953..061dd69f34 100644 --- a/test/standalone/self_exe_symlink/build.zig +++ b/test/standalone/self_exe_symlink/build.zig @@ -9,6 +9,8 @@ pub fn build(b: *std.Build) void { const optimize: std.builtin.OptimizeMode = .Debug; const target = b.graph.host; + if (target.result.os.tag == .openbsd) return; // realpath not supported + const main = b.addExecutable(.{ .name = "main", .root_module = b.createModule(.{