Merge pull request 'enable x86_64-openbsd CI' (#30733) from alexrp/zig:openbsd-ci into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30733
This commit is contained in:
Alex Rønne Petersen 2026-01-08 12:35:11 +01:00
commit d1be8b138e
7 changed files with 157 additions and 0 deletions

View file

@ -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:

62
ci/x86_64-openbsd-debug.sh Executable file
View file

@ -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

68
ci/x86_64-openbsd-release.sh Executable file
View file

@ -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

View file

@ -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;

View file

@ -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 },

View file

@ -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(.{

View file

@ -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(.{