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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ jobs:
uses: actions/checkout@v4
- name: Build and Test
run: sh ci/x86_64-linux-debug.sh
x86_64-linux-debug-llvm:
timeout-minutes: 540
runs-on: [self-hosted, Linux, x86_64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and Test
run: sh ci/x86_64-linux-debug-llvm.sh
x86_64-linux-release:
timeout-minutes: 540
runs-on: [self-hosted, Linux, x86_64]
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ set(ZIG_STAGE2_SOURCES
src/Air/Legalize.zig
src/Air/Liveness.zig
src/Air/Liveness/Verify.zig
src/Air/print.zig
src/Air/types_resolved.zig
src/Builtin.zig
src/Compilation.zig
Expand Down Expand Up @@ -675,7 +676,6 @@ set(ZIG_STAGE2_SOURCES
src/libs/mingw.zig
src/libs/musl.zig
src/mutable_value.zig
src/print_air.zig
src/print_env.zig
src/print_targets.zig
src/print_value.zig
Expand Down
52 changes: 44 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ pub fn build(b: *std.Build) !void {
const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
const skip_translate_c = b.option(bool, "skip-translate-c", "Main test suite skips translate-c tests") orelse false;
const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") 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_windows = b.option(bool, "skip-windows", "Main test suite skips targets with windows OS") orelse false;
const skip_macos = b.option(bool, "skip-macos", "Main test suite skips targets with macos OS") orelse false;
const skip_linux = b.option(bool, "skip-linux", "Main test suite skips targets with linux OS") orelse false;
const skip_llvm = b.option(bool, "skip-llvm", "Main test suite skips targets that use LLVM backend") orelse false;

const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;

Expand Down Expand Up @@ -435,10 +441,15 @@ pub fn build(b: *std.Build) !void {
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = skip_libc,
.use_llvm = use_llvm,
// 2520100864 was observed on an x86_64-linux-gnu host.
.max_rss = 2772110950,
// 2923515904 was observed on an x86_64-linux-gnu host.
.max_rss = 3100000000,
}));

test_modules_step.dependOn(tests.addModuleTests(b, .{
Expand All @@ -452,8 +463,13 @@ pub fn build(b: *std.Build) !void {
.include_paths = &.{"test/c_import"},
.skip_single_threaded = true,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = skip_libc,
.use_llvm = use_llvm,
}));

test_modules_step.dependOn(tests.addModuleTests(b, .{
Expand All @@ -467,8 +483,13 @@ pub fn build(b: *std.Build) !void {
.include_paths = &.{},
.skip_single_threaded = true,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = true,
.use_llvm = use_llvm,
.no_builtin = true,
}));

Expand All @@ -483,8 +504,13 @@ pub fn build(b: *std.Build) !void {
.include_paths = &.{},
.skip_single_threaded = true,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = true,
.use_llvm = use_llvm,
.no_builtin = true,
}));

Expand All @@ -499,8 +525,13 @@ pub fn build(b: *std.Build) !void {
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = skip_libc,
.use_llvm = use_llvm,
// I observed a value of 5605064704 on the M2 CI.
.max_rss = 6165571174,
}));
Expand Down Expand Up @@ -536,6 +567,12 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addCAbiTests(b, .{
.test_target_filters = test_target_filters,
.skip_non_native = skip_non_native,
.skip_freebsd = skip_freebsd,
.skip_netbsd = skip_netbsd,
.skip_windows = skip_windows,
.skip_macos = skip_macos,
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_release = skip_release,
}));
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
Expand All @@ -549,7 +586,6 @@ pub fn build(b: *std.Build) !void {
.lldb = b.option([]const u8, "lldb", "path to lldb binary"),
.optimize_modes = optimization_modes,
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_libc = skip_libc,
})) |test_debugger_step| test_step.dependOn(test_debugger_step);
if (tests.addLlvmIrTests(b, .{
Expand Down
70 changes: 70 additions & 0 deletions ci/x86_64-linux-debug-llvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh

# Requires cmake ninja-build

set -x
set -e

ARCH="$(uname -m)"
TARGET="$ARCH-linux-musl"
MCPU="baseline"
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.15.0-dev.233+7c85dc460"
PREFIX="$HOME/deps/$CACHE_BASENAME"
ZIG="$PREFIX/bin/zig"

export PATH="$HOME/deps/wasmtime-v29.0.0-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-9.2.0-rc1/bin:$HOME/local/bin:$PATH"

# 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-llvm
cd build-debug-llvm

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 \
-DZIG_EXTRA_BUILD_ARGS="-Duse-llvm=true" \
-GNinja

# 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

# simultaneously test building self-hosted without LLVM and with 32-bit arm
stage3-debug/bin/zig build \
-Dtarget=arm-linux-musleabihf \
-Dno-lib

stage3-debug/bin/zig build test docs \
--maxrss 21000000000 \
-Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \
-fqemu \
-fwasmtime \
-Dstatic-llvm \
-Dskip-freebsd \
-Dskip-netbsd \
-Dskip-windows \
-Dskip-macos \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-superhtml
43 changes: 5 additions & 38 deletions ci/x86_64-linux-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ git fetch --tags
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"

# Test building from source without LLVM.
cc -o bootstrap bootstrap.c
./bootstrap
./zig2 build -Dno-lib
./zig-out/bin/zig test test/behavior.zig

mkdir build-debug
cd build-debug

Expand Down Expand Up @@ -65,39 +59,12 @@ stage3-debug/bin/zig build test docs \
-fqemu \
-fwasmtime \
-Dstatic-llvm \
-Dskip-freebsd \
-Dskip-netbsd \
-Dskip-windows \
-Dskip-macos \
-Dskip-llvm \
-Dtarget=native-native-musl \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib" \
-Denable-superhtml

# Ensure that updating the wasm binary from this commit will result in a viable build.
stage3-debug/bin/zig build update-zig1

mkdir ../build-new
cd ../build-new

export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"

cmake .. \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DCMAKE_BUILD_TYPE=Debug \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_STATIC=ON \
-DZIG_NO_LIB=ON \
-GNinja

unset CC
unset CXX

ninja install

stage3/bin/zig test ../test/behavior.zig
stage3/bin/zig build -p stage4 \
-Dstatic-llvm \
-Dtarget=native-native-musl \
-Dno-lib \
--search-prefix "$PREFIX" \
--zig-lib-dir "$PWD/../lib"
stage4/bin/zig test ../test/behavior.zig
1 change: 1 addition & 0 deletions doc/langref/test_global_assembly.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ test "global assembly" {

// test
// target=x86_64-linux
// llvm=true
6 changes: 5 additions & 1 deletion lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2581,12 +2581,16 @@ pub fn standardDynamicLinkerPath(target: Target) DynamicLinker {
}

pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
return ptrBitWidth_arch_abi(cpu.arch, abi);
}

pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
switch (abi) {
.gnux32, .muslx32, .gnuabin32, .muslabin32, .ilp32 => return 32,
.gnuabi64, .muslabi64 => return 64,
else => {},
}
return switch (cpu.arch) {
return switch (cpu_arch) {
.avr,
.msp430,
=> 16,
Expand Down
15 changes: 13 additions & 2 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub const StackTrace = struct {

/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const GlobalLinkage = enum {
pub const GlobalLinkage = enum(u2) {
internal,
strong,
weak,
Expand All @@ -70,7 +70,7 @@ pub const GlobalLinkage = enum {

/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const SymbolVisibility = enum {
pub const SymbolVisibility = enum(u2) {
default,
hidden,
protected,
Expand Down Expand Up @@ -1030,8 +1030,19 @@ pub const ExternOptions = struct {
name: []const u8,
library_name: ?[]const u8 = null,
linkage: GlobalLinkage = .strong,
visibility: SymbolVisibility = .default,
/// Setting this to `true` makes the `@extern` a runtime value.
is_thread_local: bool = false,
is_dll_import: bool = false,
relocation: Relocation = .any,

pub const Relocation = enum(u1) {
/// Any type of relocation is allowed.
any,
/// A program-counter-relative relocation is required.
/// Using this value makes the `@extern` a runtime value.
pcrel,
};
};

/// This data structure is used by the Zig language code generation and
Expand Down
13 changes: 8 additions & 5 deletions lib/std/dynamic_library.zig
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ const RDebug = extern struct {
r_ldbase: usize,
};

/// TODO make it possible to reference this same external symbol 2x so we don't need this
/// helper function.
pub fn get_DYNAMIC() ?[*]elf.Dyn {
return @extern([*]elf.Dyn, .{ .name = "_DYNAMIC", .linkage = .weak });
/// TODO fix comparisons of extern symbol pointers so we don't need this helper function.
pub fn get_DYNAMIC() ?[*]const elf.Dyn {
return @extern([*]const elf.Dyn, .{
.name = "_DYNAMIC",
.linkage = .weak,
.visibility = .hidden,
});
}

pub fn linkmap_iterator(phdrs: []elf.Phdr) error{InvalidExe}!LinkMap.Iterator {
pub fn linkmap_iterator(phdrs: []const elf.Phdr) error{InvalidExe}!LinkMap.Iterator {
_ = phdrs;
const _DYNAMIC = get_DYNAMIC() orelse {
// No PT_DYNAMIC means this is either a statically-linked program or a
Expand Down
Loading
Loading