authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-06 21:16:47+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-06 21:16:47+01:00
logb5df5391aa46585a4b4773603c246abde1757a00
treed7fcfd85a5a2e8228ace377d06cb2176361ce83e
parent312b231da9a90e477c56801fb2056324edc50ea1
parent43a8e9ee80504a7dd93dc41869fb9a81c67ec625

Merge pull request 'enable `powerpc64le-linux` CI' (#30704) from alexrp/zig:powerpc64le into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30704

11 files changed, 184 insertions(+), 14 deletions(-)

.forgejo/workflows/ci.yaml+21
......@@ -78,6 +78,27 @@ jobs:
7878 run: sh ci/loongarch64-linux-release.sh
7979 timeout-minutes: 180
8080
81 powerpc64le-linux-debug:
82 runs-on: [self-hosted, powerpc64le-linux]
83 steps:
84 - name: Checkout
85 uses: https://codeberg.org/ziglang/checkout@19af6bac491e2534a4687a50ee84fa7f13258d28
86 with:
87 fetch-depth: 0
88 - name: Build and Test
89 run: sh ci/powerpc64le-linux-debug.sh
90 timeout-minutes: 360
91 powerpc64le-linux-release:
92 runs-on: [self-hosted, powerpc64le-linux]
93 steps:
94 - name: Checkout
95 uses: https://codeberg.org/ziglang/checkout@19af6bac491e2534a4687a50ee84fa7f13258d28
96 with:
97 fetch-depth: 0
98 - name: Build and Test
99 run: sh ci/powerpc64le-linux-release.sh
100 timeout-minutes: 240
101
81102 riscv64-linux-debug:
82103 if: github.event_name != 'pull_request'
83104 runs-on: [self-hosted, riscv64-linux]
CMakeLists.txt+5
......@@ -787,6 +787,11 @@ else()
787787 set(ZIG_WASM2C_COMPILE_FLAGS "-std=c99 -O2")
788788 set(ZIG1_COMPILE_FLAGS "-std=c99 -Os")
789789 set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector")
790 # Must match the condition in build.zig.
791 if(ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")
792 set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
793 set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
794 endif()
790795 if(APPLE)
791796 set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")
792797 elseif(MINGW)
build.zig+7-1
......@@ -477,7 +477,7 @@ pub fn build(b: *std.Build) !void {
477477 .linux => switch (b.graph.host.result.cpu.arch) {
478478 .aarch64 => 659_809_075,
479479 .loongarch64 => 598_902_374,
480 .powerpc64le => 550_656_409,
480 .powerpc64le => 627_431_833,
481481 .riscv64 => 827_043_430,
482482 .s390x => 580_596_121,
483483 .x86_64 => 3_290_894_745,
......@@ -838,6 +838,12 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste
838838 });
839839 exe.stack_size = stack_size;
840840
841 // Must match the condition in CMakeLists.txt.
842 const function_data_sections = options.target.result.cpu.arch.isPowerPC();
843
844 exe.link_function_sections = function_data_sections;
845 exe.link_data_sections = function_data_sections;
846
841847 return exe;
842848}
843849
ci/powerpc64le-linux-debug.sh created+66
......@@ -0,0 +1,66 @@
1#!/bin/sh
2
3# Requires cmake ninja-build
4
5set -x
6set -e
7
8TARGET="powerpc64le-linux-musl"
9MCPU="baseline"
10CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.1594+9fa433d71"
11PREFIX="$HOME/deps/$CACHE_BASENAME"
12ZIG="$PREFIX/bin/zig"
13
14# Override the cache directories because they won't actually help other CI runs
15# which will be testing alternate versions of zig, and ultimately would just
16# fill up space on the hard drive for no reason.
17export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
18export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
19
20mkdir build-debug
21cd build-debug
22
23export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
24export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
25
26cmake .. \
27 -DCMAKE_INSTALL_PREFIX="stage3-debug" \
28 -DCMAKE_PREFIX_PATH="$PREFIX" \
29 -DCMAKE_BUILD_TYPE=Debug \
30 -DZIG_TARGET_TRIPLE="$TARGET" \
31 -DZIG_TARGET_MCPU="$MCPU" \
32 -DZIG_STATIC=ON \
33 -DZIG_NO_LIB=ON \
34 -GNinja \
35 -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \
36 -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE
37# https://github.com/ziglang/zig/issues/22213
38
39# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
40# so that installation and testing do not get affected by them.
41unset CC
42unset CXX
43
44ninja install
45
46# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
47stage3-debug/bin/zig build test docs \
48 --maxrss ${ZSF_MAX_RSS:-0} \
49 -Dstatic-llvm \
50 -Dskip-non-native \
51 -Dtarget=native-native-musl \
52 -Dcpu=native+longcall \
53 --search-prefix "$PREFIX" \
54 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout 4m
56
57stage3-debug/bin/zig build \
58 --prefix stage4-debug \
59 -Denable-llvm \
60 -Dno-lib \
61 -Dtarget=$TARGET \
62 -Dcpu=$MCPU \
63 -Duse-zig-libcxx \
64 -Dversion-string="$(stage3-debug/bin/zig version)"
65
66stage4-debug/bin/zig test ../test/behavior.zig
ci/powerpc64le-linux-release.sh created+72
......@@ -0,0 +1,72 @@
1#!/bin/sh
2
3# Requires cmake ninja-build
4
5set -x
6set -e
7
8TARGET="powerpc64le-linux-musl"
9MCPU="baseline"
10CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.1594+9fa433d71"
11PREFIX="$HOME/deps/$CACHE_BASENAME"
12ZIG="$PREFIX/bin/zig"
13
14# Override the cache directories because they won't actually help other CI runs
15# which will be testing alternate versions of zig, and ultimately would just
16# fill up space on the hard drive for no reason.
17export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
18export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
19
20mkdir build-release
21cd build-release
22
23export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
24export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
25
26cmake .. \
27 -DCMAKE_INSTALL_PREFIX="stage3-release" \
28 -DCMAKE_PREFIX_PATH="$PREFIX" \
29 -DCMAKE_BUILD_TYPE=Release \
30 -DZIG_TARGET_TRIPLE="$TARGET" \
31 -DZIG_TARGET_MCPU="$MCPU" \
32 -DZIG_STATIC=ON \
33 -DZIG_NO_LIB=ON \
34 -GNinja \
35 -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \
36 -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE
37# https://github.com/ziglang/zig/issues/22213
38
39# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
40# so that installation and testing do not get affected by them.
41unset CC
42unset CXX
43
44ninja install
45
46# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
47stage3-release/bin/zig build test docs \
48 --maxrss ${ZSF_MAX_RSS:-0} \
49 -Dstatic-llvm \
50 -Dskip-non-native \
51 -Dtarget=native-native-musl \
52 -Dcpu=native+longcall \
53 --search-prefix "$PREFIX" \
54 --zig-lib-dir "$PWD/../lib" \
55 --test-timeout 4m
56
57# Ensure that stage3 and stage4 are byte-for-byte identical.
58stage3-release/bin/zig build \
59 --prefix stage4-release \
60 -Denable-llvm \
61 -Dno-lib \
62 -Doptimize=ReleaseFast \
63 -Dstrip \
64 -Dtarget=$TARGET \
65 -Dcpu=$MCPU \
66 -Duse-zig-libcxx \
67 -Dversion-string="$(stage3-release/bin/zig version)"
68
69# diff returns an error code if the files differ.
70echo "If the following command fails, it means nondeterminism has been"
71echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
72diff stage3-release/bin/zig stage4-release/bin/zig
src/Compilation.zig+4-4
......@@ -8084,8 +8084,8 @@ fn buildOutputFromZig(
80848084}
80858085
80868086pub const CrtFileOptions = struct {
8087 function_sections: ?bool = null,
8088 data_sections: ?bool = null,
8087 function_sections: bool = true,
8088 data_sections: bool = true,
80898089 omit_frame_pointer: ?bool = null,
80908090 unwind_tables: ?std.builtin.UnwindTables = null,
80918091 pic: ?bool = null,
......@@ -8188,8 +8188,8 @@ pub fn build_crt_file(
81888188 .root_name = root_name,
81898189 .libc_installation = comp.libc_installation,
81908190 .emit_bin = .yes_cache,
8191 .function_sections = options.function_sections orelse false,
8192 .data_sections = options.data_sections orelse false,
8191 .function_sections = options.function_sections,
8192 .data_sections = options.data_sections,
81938193 .c_source_files = c_source_files,
81948194 .verbose_cc = comp.verbose_cc,
81958195 .verbose_link = comp.verbose_link,
src/libs/libcxx.zig+4
......@@ -265,6 +265,8 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
265265 .root_name = root_name,
266266 .libc_installation = comp.libc_installation,
267267 .emit_bin = .yes_cache,
268 .function_sections = true,
269 .data_sections = true,
268270 .c_source_files = c_source_files.items,
269271 .verbose_cc = comp.verbose_cc,
270272 .verbose_link = comp.verbose_link,
......@@ -459,6 +461,8 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
459461 .root_name = root_name,
460462 .libc_installation = comp.libc_installation,
461463 .emit_bin = .yes_cache,
464 .function_sections = true,
465 .data_sections = true,
462466 .c_source_files = c_source_files.items,
463467 .verbose_cc = comp.verbose_cc,
464468 .verbose_link = comp.verbose_link,
src/libs/libtsan.zig+2
......@@ -288,6 +288,8 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
288288 .root_name = root_name,
289289 .libc_installation = comp.libc_installation,
290290 .emit_bin = .yes_cache,
291 .function_sections = true,
292 .data_sections = true,
291293 .c_source_files = c_source_files.items,
292294 .verbose_cc = comp.verbose_cc,
293295 .verbose_link = comp.verbose_link,
src/libs/libunwind.zig+2-1
......@@ -155,7 +155,8 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
155155 .main_mod = null,
156156 .libc_installation = comp.libc_installation,
157157 .emit_bin = .yes_cache,
158 .function_sections = comp.function_sections,
158 .function_sections = true,
159 .data_sections = true,
159160 .c_source_files = &c_source_files,
160161 .verbose_cc = comp.verbose_cc,
161162 .verbose_link = comp.verbose_link,
src/libs/mingw.zig+1
......@@ -56,6 +56,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
5656 },
5757 };
5858 return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files, .{
59 .function_sections = false, // https://codeberg.org/ziglang/zig/issues/30702
5960 .unwind_tables = unwind_tables,
6061 });
6162 },
src/libs/musl.zig-8
......@@ -43,8 +43,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
4343 },
4444 };
4545 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
46 .function_sections = true,
47 .data_sections = true,
4846 .omit_frame_pointer = true,
4947 .no_builtin = true,
5048 });
......@@ -63,8 +61,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
6361 },
6462 };
6563 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
66 .function_sections = true,
67 .data_sections = true,
6864 .omit_frame_pointer = true,
6965 .pic = true,
7066 .no_builtin = true,
......@@ -84,8 +80,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
8480 },
8581 };
8682 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
87 .function_sections = true,
88 .data_sections = true,
8983 .omit_frame_pointer = true,
9084 .pic = true,
9185 .no_builtin = true,
......@@ -172,8 +166,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
172166 };
173167 }
174168 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
175 .function_sections = true,
176 .data_sections = true,
177169 .omit_frame_pointer = true,
178170 .no_builtin = true,
179171 });