mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Merge pull request #25324 from alexrp/freebsd
Some changes to prepare for FreeBSD CI
This commit is contained in:
commit
26825e9506
10 changed files with 165 additions and 6 deletions
71
ci/x86_64-freebsd-debug.sh
Executable file
71
ci/x86_64-freebsd-debug.sh
Executable file
|
|
@ -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
ci/x86_64-freebsd-release.sh
Executable file
77
ci/x86_64-freebsd-release.sh
Executable file
|
|
@ -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
|
||||
|
|
@ -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" \
|
||||
|
|
|
|||
|
|
@ -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" {
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ pub fn hasNewLinkerSupport(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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -803,6 +803,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
.s390x,
|
||||
},
|
||||
.exclude_os = &.{
|
||||
.freebsd,
|
||||
.openbsd, // integer overflow
|
||||
.windows, // TODO intermittent failures
|
||||
},
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -61,8 +61,12 @@ pub fn build(b: *std.Build) void {
|
|||
.use_llvm = true,
|
||||
});
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue