Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions ci/x86_64-freebsd-debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh

# Requires cmake ninja-build

set -x
set -e

ARCH="x86_64"
TARGET="$ARCH-freebsd-none"
MCPU="baseline"
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.312+164c598cd"
PREFIX="$HOME/deps/$CACHE_BASENAME"
ZIG="$PREFIX/bin/zig"

# Make the `zig version` number consistent.
# This will affect the cmake command below.
git fetch --unshallow || true
git fetch --tags

# 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 32212254720 \
-Dstatic-llvm \
-Dskip-linux \
-Dskip-netbsd \
-Dskip-windows \
-Dskip-macos \
-Dtarget=native-native-none \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib"

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
77 changes: 77 additions & 0 deletions ci/x86_64-freebsd-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh

# Requires cmake ninja-build

set -x
set -e

ARCH="x86_64"
TARGET="$ARCH-freebsd-none"
MCPU="baseline"
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.312+164c598cd"
PREFIX="$HOME/deps/$CACHE_BASENAME"
ZIG="$PREFIX/bin/zig"

# Make the `zig version` number consistent.
# This will affect the cmake command below.
git fetch --unshallow || true
git fetch --tags

# 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 32212254720 \
-Dstatic-llvm \
-Dskip-linux \
-Dskip-netbsd \
-Dskip-windows \
-Dskip-macos \
-Dtarget=native-native-none \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib"

# 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
1 change: 1 addition & 0 deletions ci/x86_64-linux-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ stage3-release/bin/zig build test docs \
-fqemu \
-fwasmtime \
-Dstatic-llvm \
-Dskip-freebsd \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
Expand Down
1 change: 0 additions & 1 deletion lib/std/posix/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ test "sigrtmin/max" {
try std.testing.expect(posix.sigrtmin() >= 32);
try std.testing.expect(posix.sigrtmin() >= posix.system.sigrtmin());
try std.testing.expect(posix.sigrtmin() < posix.system.sigrtmax());
try std.testing.expect(posix.sigrtmax() < posix.NSIG);
}

test "sigset empty/full" {
Expand Down
2 changes: 1 addition & 1 deletion src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub fn hasLldSupport(ofmt: std.Target.ObjectFormat) bool {
pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
if (target.cpu.arch.isSpirV()) return true;
if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {
if (target.os.tag == .netbsd or target.os.tag == .openbsd) {
if (target.os.tag.isBSD()) {
// Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions test/link/elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
_ = build_opts;
const elf_step = b.step("test-elf", "Run ELF tests");

// https://github.com/ziglang/zig/issues/25323
if (builtin.os.tag == .freebsd) return elf_step;

const default_target = b.resolveTargetQuery(.{
.cpu_arch = .x86_64, // TODO relax this once ELF linker is able to handle other archs
.os_tag = .linux,
Expand Down Expand Up @@ -4285,6 +4288,7 @@ const addStaticLibrary = link.addStaticLibrary;
const expectLinkErrors = link.expectLinkErrors;
const link = @import("link.zig");
const std = @import("std");
const builtin = @import("builtin");

const Build = std.Build;
const BuildOptions = link.BuildOptions;
Expand Down
2 changes: 1 addition & 1 deletion test/src/StackTrace.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn addCaseInner(self: *StackTrace, config: Config, use_llvm: bool) void {
fn shouldTestNonLlvm(target: *const std.Target) bool {
return switch (target.cpu.arch) {
.x86_64 => switch (target.ofmt) {
.elf => true,
.elf => !target.os.tag.isBSD(),
else => false,
},
else => false,
Expand Down
2 changes: 2 additions & 0 deletions test/stack_traces.zig
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
.s390x,
},
.exclude_os = &.{
.freebsd,
.openbsd, // integer overflow
.windows, // TODO intermittent failures
},
Expand Down Expand Up @@ -847,6 +848,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
},
.ReleaseSafe = .{
.exclude_os = &.{
.freebsd,
.windows, // TODO
.linux, // defeated by aggressive inlining
.macos, // Broken in LLVM 20.
Expand Down
8 changes: 6 additions & 2 deletions test/standalone/stack_iterator/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ pub fn build(b: *std.Build) void {
.use_llvm = true,
});

const run_cmd = b.addRunArtifact(exe);
test_step.dependOn(&run_cmd.step);
if (builtin.os.tag != .freebsd) {
const run_cmd = b.addRunArtifact(exe);
test_step.dependOn(&run_cmd.step);
} else {
test_step.dependOn(&exe.step);
}
}

// https://github.com/ziglang/zig/issues/24522
Expand Down
3 changes: 2 additions & 1 deletion test/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2451,8 +2451,9 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
else => return true,
}
const cpu_arch = query.cpu_arch orelse builtin.cpu.arch;
const os_tag = query.os_tag orelse builtin.os.tag;
switch (cpu_arch) {
.x86_64 => if (std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true,
.x86_64 => if (os_tag.isBSD() or std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true,
.spirv32, .spirv64 => return false,
else => return true,
}
Expand Down
Loading