From 66af41c2a4b324893354edd929f8d24010f496a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 20:22:07 +0200 Subject: [PATCH 01/14] see if I can mount /mnt on github actions too --- runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu | 2 ++ scripts/sandbox.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu index 18f56a95e2..70f377f820 100644 --- a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu +++ b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu @@ -13,6 +13,8 @@ WORKDIR /opt/app-root/bin # OS Packages needs to be installed as root USER 0 +RUN ls /mnt && false + # Inject the official UBI 9 repository configuration into the AIPCC base image. # The Quay-based AIPCC image is "repo-less" by default (https://gitlab.com/redhat/rhel-ai/core/base-images/app#repositories), so dnf cannot upgrade or install packages. # By copying ubi.repo from the public UBI 9 image, we enable package management for upgrades and installations. diff --git a/scripts/sandbox.py b/scripts/sandbox.py index a8592b09d9..b42d14aea4 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -47,7 +47,13 @@ def main() -> int: with tempfile.TemporaryDirectory(delete=True) as tmpdir: setup_sandbox(prereqs, pathlib.Path(tmpdir)) - command = [arg if arg != "{};" else tmpdir for arg in args.remaining[1:]] + additional_arguments = ["--volume=/usr:/mnt:ro", tmpdir] + command = [] + for arg in args.remaining[1:]: + if arg == "{};": + command.extend(additional_arguments) + else: + command.append(arg) print(f"running {command=}") try: subprocess.check_call(command) From 86902e31403f6b91271adb9fef6431634dcd6603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 21:47:14 +0200 Subject: [PATCH 02/14] install zig --- Makefile | 29 +++++++++++++++++++++++++++++ scripts/sandbox.py | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d5ee9bae98..7d54a51a70 100644 --- a/Makefile +++ b/Makefile @@ -481,6 +481,35 @@ refresh-pipfilelock-files: scan-image-vulnerabilities: python ci/security-scan/quay_security_analysis.py +ARCH := $(shell uname -m) +ifeq ($(ARCH),amd64) + ARCH := x86_64 +else ifeq ($(ARCH),arm64) + ARCH := aarch64 +endif + +ZIG_VERSION := 0.15.1 +ZIG_BINARY := zig-$(ZIG_VERSION) + +bin/zig-$(ZIG_VERSION): + @echo "Installing Zig $(ZIG_VERSION)..." + TMPDIR=$(shell mktemp -d) + wget https://ziglang.org/download/$(ZIG_VERSION)/zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz + tar -xJf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz -C $$TMPDIR --strip-components=1 + mv $$TMPDIR bin/zig-$(ZIG_VERSION) + rm -rf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz + @echo "Zig installed as bin/zig-$(ZIG_VERSION)" + +# This should be .PHONY because it's an alias/action +.PHONY: install-zig +install-zig: bin/zig-$(ZIG_VERSION) + @echo "Zig is ready to use!" + +# Another .PHONY target for cleanup +.PHONY: clean-zig +clean-zig: + rm -rf bin/zig-$(ZIG_VERSION) + # This is used primarily for gen_gha_matrix_jobs.py to we know the set of all possible images we may want to build .PHONY: all-images ifeq ($(RELEASE_PYTHON_VERSION), 3.11) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index b42d14aea4..cd1367fa0a 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -47,7 +47,7 @@ def main() -> int: with tempfile.TemporaryDirectory(delete=True) as tmpdir: setup_sandbox(prereqs, pathlib.Path(tmpdir)) - additional_arguments = ["--volume=/usr:/mnt:ro", tmpdir] + additional_arguments = [f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", tmpdir] command = [] for arg in args.remaining[1:]: if arg == "{};": @@ -69,6 +69,8 @@ def buildinputs( ) -> list[pathlib.Path]: if not (ROOT_DIR / "bin/buildinputs").exists(): subprocess.check_call([MAKE, "bin/buildinputs"], cwd=ROOT_DIR) + if not (ROOT_DIR / "bin/zig-0.15.1").exists(): + subprocess.check_call([MAKE, "bin/zig-0.15.1"], cwd=ROOT_DIR) stdout = subprocess.check_output([ROOT_DIR / "bin/buildinputs", str(dockerfile)], text=True, cwd=ROOT_DIR, env={"TARGETPLATFORM": platform, **os.environ}) From ef3c850d6f9e711f04da78992ba727f81d67f208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 21:54:44 +0200 Subject: [PATCH 03/14] Add progress display for wget in Zig installation --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7d54a51a70..4fe1e47f60 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ ZIG_BINARY := zig-$(ZIG_VERSION) bin/zig-$(ZIG_VERSION): @echo "Installing Zig $(ZIG_VERSION)..." TMPDIR=$(shell mktemp -d) - wget https://ziglang.org/download/$(ZIG_VERSION)/zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz + wget --progress=dot:giga https://ziglang.org/download/$(ZIG_VERSION)/zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz tar -xJf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz -C $$TMPDIR --strip-components=1 mv $$TMPDIR bin/zig-$(ZIG_VERSION) rm -rf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz From 8325e6340b7741cbe3fa075976f9c92df0556c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 21:58:13 +0200 Subject: [PATCH 04/14] Configure sandbox to support cross-compilation with Zig for s390x-linux-gnu target. --- scripts/sandbox.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index cd1367fa0a..d8ef8c7342 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -47,7 +47,13 @@ def main() -> int: with tempfile.TemporaryDirectory(delete=True) as tmpdir: setup_sandbox(prereqs, pathlib.Path(tmpdir)) - additional_arguments = [f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", tmpdir] + target = "s390x-linux-gnu" + additional_arguments = [ + f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", + f"--build-arg=CC=/mnt/zig-0.15.1/zig cc -target {target}", + f"--build-arg=CXX=/mnt/zig-0.15.1/zig c++ -target {target}", + tmpdir, + ] command = [] for arg in args.remaining[1:]: if arg == "{};": From e68d85debdf415f61c293695b47bc5db96a359d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 21:58:32 +0200 Subject: [PATCH 05/14] Fix Dockerfile.cpu mount check logic in `ubi9-python-3.12` runtime --- runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu index 70f377f820..ca5acf58d9 100644 --- a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu +++ b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu @@ -13,7 +13,7 @@ WORKDIR /opt/app-root/bin # OS Packages needs to be installed as root USER 0 -RUN ls /mnt && false +RUN ls /mnt && true # Inject the official UBI 9 repository configuration into the AIPCC base image. # The Quay-based AIPCC image is "repo-less" by default (https://gitlab.com/redhat/rhel-ai/core/base-images/app#repositories), so dnf cannot upgrade or install packages. From 40a29b0c8f26df7d4b8b847e2af3d7bba702cffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 22:19:09 +0200 Subject: [PATCH 06/14] Modify sandbox to set `CC` and `CXX` as environment variables for Zig cross-compilation and unset them afterward. --- scripts/sandbox.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index d8ef8c7342..a60e957bc1 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -50,8 +50,10 @@ def main() -> int: target = "s390x-linux-gnu" additional_arguments = [ f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", - f"--build-arg=CC=/mnt/zig-0.15.1/zig cc -target {target}", - f"--build-arg=CXX=/mnt/zig-0.15.1/zig c++ -target {target}", + f"--env=CC=/mnt/zig-0.15.1/zig cc -target {target}", + f"--env=CXX=/mnt/zig-0.15.1/zig c++ -target {target}", + f"--unsetenv=CC", + f"--unsetenv=CXX", tmpdir, ] command = [] From 21fc66d29616cb5293d35be84a134a3dc59c5dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 22:27:49 +0200 Subject: [PATCH 07/14] Simplify Zig paths in sandbox for cross-compilation environment variables `CC` and `CXX`. --- scripts/sandbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index a60e957bc1..c08a1a889a 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -50,8 +50,8 @@ def main() -> int: target = "s390x-linux-gnu" additional_arguments = [ f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", - f"--env=CC=/mnt/zig-0.15.1/zig cc -target {target}", - f"--env=CXX=/mnt/zig-0.15.1/zig c++ -target {target}", + f"--env=CC=/mnt/zig cc -target {target}", + f"--env=CXX=/mnt/zig c++ -target {target}", f"--unsetenv=CC", f"--unsetenv=CXX", tmpdir, From dec825a28a9a1fa39fb9352097bc672990b702f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 22:45:55 +0200 Subject: [PATCH 08/14] Update target in sandbox for s390x to specify glibc version (2.34). --- scripts/sandbox.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index c08a1a889a..db0198bcf4 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -47,7 +47,8 @@ def main() -> int: with tempfile.TemporaryDirectory(delete=True) as tmpdir: setup_sandbox(prereqs, pathlib.Path(tmpdir)) - target = "s390x-linux-gnu" + # target glibc 2.28 or newer (supports FORTIFY_SOURCE) + target = "s390x-linux-gnu.2.34" additional_arguments = [ f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", f"--env=CC=/mnt/zig cc -target {target}", @@ -70,6 +71,24 @@ def main() -> int: return err.returncode return 0 +""" +Downloading jedi + × Failed to build `pyzmq==27.1.0` + ├─▶ The build backend returned an error + ╰─▶ Call to `scikit_build_core.build.build_wheel` failed (exit status: 1) + [stdout] + *** scikit-build-core 0.11.6 using CMake 3.26.5 (wheel) + *** Configuring CMake... + loading initial cache file /tmp/tmpf9bnfh5o/build/CMakeInit.txt + -- Configuring incomplete, errors occurred! + [stderr] + CMake Error at /usr/share/cmake/Modules/CMakeDetermineCCompiler.cmake:49 + (message): + Could not find compiler set in environment variable CC: + /mnt/zig-0.15.1/zig cc -target s390x-linux-gnu. + Call Stack (most recent call first): + CMakeLists.txt:2 (project) +""" def buildinputs( dockerfile: pathlib.Path | str, From 6ef116854a0492d9a2b2b6c3150a9cc4aeef95eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Tue, 23 Sep 2025 22:46:22 +0200 Subject: [PATCH 09/14] Address deprecation warning and unsupported arg in s390x build process --- scripts/sandbox.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index db0198bcf4..923e98e7ac 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -90,6 +90,46 @@ def main() -> int: CMakeLists.txt:2 (project) """ +""" +creating build/temp.linux-s390x-cpython-312/psutil/arch/linux + /mnt/zig cc -target s390x-linux-gnu -fno-strict-overflow + -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG + -O2 -fexceptions -g -grecord-gcc-switches -pipe + -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 + -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong + -m64 -march=z14 -mtune=z15 -fasynchronous-unwind-tables + -fstack-clash-protection -O2 -fexceptions -g -grecord-gcc-switches + -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 + -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong + -m64 -march=z14 -mtune=z15 -fasynchronous-unwind-tables + -fstack-clash-protection -O2 -fexceptions -g -grecord-gcc-switches + -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 + -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong + -m64 -march=z14 -mtune=z15 -fasynchronous-unwind-tables + -fstack-clash-protection -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 + -DPSUTIL_VERSION=700 -DPy_LIMITED_API=0x03060000 + -DPSUTIL_LINUX=1 -I/tmp/.tmpWlL4ZP/builds-v0/.tmpOwAhw2/include + -I/usr/include/python3.12 -c psutil/_psutil_common.c -o + build/temp.linux-s390x-cpython-312/psutil/_psutil_common.o + [stderr] + /tmp/.tmpWlL4ZP/builds-v0/.tmpOwAhw2/lib64/python3.12/site-packages/setuptools/dist.py:759: + SetuptoolsDeprecationWarning: License classifiers are deprecated. + !! + + ******************************************************************************** + Please consider removing the following classifiers in favor of a + SPDX license expression: + License :: OSI Approved :: BSD License + See + https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license + for details. + + ******************************************************************************** + !! + self._finalize_license_expression() + error: unsupported preprocessor arg: -D_FORTIFY_SOURCE +""" + def buildinputs( dockerfile: pathlib.Path | str, platform: Literal["linux/amd64", "linux/arm64", "linux/s390x", "linux/ppc64le"] = "linux/amd64" From 5f07afd0be49727009b40df7021dd5f99e4b435d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Wed, 24 Sep 2025 00:35:36 +0200 Subject: [PATCH 10/14] Add wrapper scripts for Zig cross-compilation and adjust s390x sandbox configuration --- Makefile | 8 +++++++- scripts/sandbox.py | 11 +++++++++-- wrapper.py | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 wrapper.py diff --git a/Makefile b/Makefile index 4fe1e47f60..e74f66b309 100644 --- a/Makefile +++ b/Makefile @@ -496,8 +496,14 @@ bin/zig-$(ZIG_VERSION): TMPDIR=$(shell mktemp -d) wget --progress=dot:giga https://ziglang.org/download/$(ZIG_VERSION)/zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz tar -xJf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz -C $$TMPDIR --strip-components=1 - mv $$TMPDIR bin/zig-$(ZIG_VERSION) rm -rf zig-$(ARCH)-linux-$(ZIG_VERSION).tar.xz + + printf '%s\n' '#!/bin/sh' 'exec /mnt/zig cc -target s390x-linux-gnu.2.34 "$@"' > $$TMPDIR/zig-cc + printf '%s\n' '#!/bin/sh' 'exec /mnt/zig c++ -target s390x-linux-gnu.2.34 "$@"' > $$TMPDIR/zig-c++ + chmod +x $$TMPDIR/zig-cc + chmod +x $$TMPDIR/zig-c++ + + mv $$TMPDIR bin/zig-$(ZIG_VERSION) @echo "Zig installed as bin/zig-$(ZIG_VERSION)" # This should be .PHONY because it's an alias/action diff --git a/scripts/sandbox.py b/scripts/sandbox.py index 923e98e7ac..0dc640699b 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -51,8 +51,15 @@ def main() -> int: target = "s390x-linux-gnu.2.34" additional_arguments = [ f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", - f"--env=CC=/mnt/zig cc -target {target}", - f"--env=CXX=/mnt/zig c++ -target {target}", + # f"--env=CC=/mnt/zig cc -target {target}", + # f"--env=CXX=/mnt/zig c++ -target {target}", + # f"--env=CC=/mnt/zig-cc", + # f"--env=CXX=/mnt/zig-c++", + # -Wp,-D_FORTIFY_SOURCE=2 + # https://github.com/giampaolo/psutil/blob/master/setup.py#L254 + # defaults to using python's flags + # f"--env=CFLAGS=", + "--env=CXXFLAGS=-Dundefined=64", f"--unsetenv=CC", f"--unsetenv=CXX", tmpdir, diff --git a/wrapper.py b/wrapper.py new file mode 100644 index 0000000000..69d0201a28 --- /dev/null +++ b/wrapper.py @@ -0,0 +1,25 @@ +#! /usr/bin/env python3 +import os +import pathlib +import sys + +def main(): + arg0 = pathlib.Path(sys.argv[0]).name + args = [] + for arg in sys.argv[1:]: + if arg.startswith("-Wp,-D"): + args.append(arg.replace("-Wp,-D", "-D", 1)) + else: + args.append(arg) + + if arg0 == "zig-cc": + args = ["/mnt/zig", "cc", "-target", "s390x-linux-gnu.2.34"] + args + elif arg0 == "zig-c++": + args = ["/mnt/zig", "c++", "-target", "s390x-linux-gnu.2.34"] + args + else: + raise ValueError(f"Unknown argument {arg0}") + + os.execve(args[0], args, os.environ) + +if __name__ == "__main__": + sys.exit(main()) From 56ef7679315229da7ef7960cbc6e8056a37b9649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Wed, 24 Sep 2025 10:46:25 +0200 Subject: [PATCH 11/14] Add `zigcc` wrapper for s390x cross-compilation, including `Makefile`, tests, and Go module setup. --- scripts/zigcc/Makefile | 21 ++++++++++++++ scripts/zigcc/go.mod | 3 ++ scripts/zigcc/zigcc.go | 56 +++++++++++++++++++++++++++++++++++++ scripts/zigcc/zigcc_test.go | 35 +++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 scripts/zigcc/Makefile create mode 100644 scripts/zigcc/go.mod create mode 100644 scripts/zigcc/zigcc.go create mode 100644 scripts/zigcc/zigcc_test.go diff --git a/scripts/zigcc/Makefile b/scripts/zigcc/Makefile new file mode 100644 index 0000000000..23ff791e8a --- /dev/null +++ b/scripts/zigcc/Makefile @@ -0,0 +1,21 @@ +.PHONY: build test clean + +build: bin/zigcc + +# always build for linux and the machine's native architecture +bin/zigcc: *.go go.mod + GOOS=linux go build -o $@ -ldflags="-s -w" -v ./... + +test: + go test -v ./... + +fmt: + go fmt ./... + +vet: + go vet ./... + +clean: + go clean + rm -f bin/* + rmdir bin diff --git a/scripts/zigcc/go.mod b/scripts/zigcc/go.mod new file mode 100644 index 0000000000..e2b750b7bb --- /dev/null +++ b/scripts/zigcc/go.mod @@ -0,0 +1,3 @@ +module zigcc + +go 1.24 diff --git a/scripts/zigcc/zigcc.go b/scripts/zigcc/zigcc.go new file mode 100644 index 0000000000..cb7657570e --- /dev/null +++ b/scripts/zigcc/zigcc.go @@ -0,0 +1,56 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "syscall" +) + +func processArg0(arg0 string) (string, error) { + switch arg0 { + case "zig-cc": + return "cc", nil + case "zig-c++": + return "c++", nil + default: + return "", fmt.Errorf("unknown wrapper name: %s", arg0) + } +} + +func processArgs(args []string) []string { + newArgs := make([]string, 0, len(args)) + for _, arg := range args { + if strings.HasPrefix(arg, "-Wp,") { + newArgs = append(newArgs, strings.Split(arg, ",")[1:]...) + } else { + newArgs = append(newArgs, arg) + } + } + return newArgs +} + +func main() { + arg0 := filepath.Base(os.Args[0]) + subcommand, err := processArg0(arg0) + if err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } + + newArgs := make([]string, 0, len(os.Args)+4) + newArgs = append(newArgs, + "/mnt/zig", // Path to the real Zig executable. + subcommand, + "-target", + "s390x-linux-gnu.2.34", + ) + newArgs = append(newArgs, processArgs(os.Args[1:])...) + + env := os.Environ() + if err := syscall.Exec(newArgs[0], newArgs, env); err != nil { + fmt.Fprintf(os.Stderr, "Error executing zig: %v\n", err) + os.Exit(1) + } +} diff --git a/scripts/zigcc/zigcc_test.go b/scripts/zigcc/zigcc_test.go new file mode 100644 index 0000000000..1bea00d6e0 --- /dev/null +++ b/scripts/zigcc/zigcc_test.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "reflect" + "testing" +) + +func TestProcessWp(t *testing.T) { + args := []string{"-Wp,-D_FORTIFY_SOURCE=2"} + newArgs := processArgs(args) + if !reflect.DeepEqual(newArgs, []string{"-D_FORTIFY_SOURCE=2"}) { + t.Fatalf("expected -DFOO=bar, got %v", newArgs) + } + for _, tc := range []struct { + args []string + expected []string + }{ + { + args: []string{"-Wp,-D_FORTIFY_SOURCE=2"}, + expected: []string{"-D_FORTIFY_SOURCE=2"}, + }, + { + args: []string{"-Wp,-DNDEBUG,-D_FORTIFY_SOURCE=2"}, + expected: []string{"-DNDEBUG", "-D_FORTIFY_SOURCE=2"}, + }, + } { + t.Run(fmt.Sprint(tc.args), func(t *testing.T) { + newArgs := processArgs(tc.args) + if !reflect.DeepEqual(newArgs, tc.expected) { + t.Fatalf("expected %#v, got %#v", tc.expected, newArgs) + } + }) + } +} From ca7bcb29f1b9bc67d60cb32fe90f18bcf50882e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Wed, 24 Sep 2025 10:46:47 +0200 Subject: [PATCH 12/14] Update sandbox to correctly set `CC` and `CXX` for Zig, add cache busting, and ensure `zigcc` wrappers are built --- scripts/sandbox.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index 0dc640699b..217ba4ad22 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -53,12 +53,13 @@ def main() -> int: f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", # f"--env=CC=/mnt/zig cc -target {target}", # f"--env=CXX=/mnt/zig c++ -target {target}", - # f"--env=CC=/mnt/zig-cc", - # f"--env=CXX=/mnt/zig-c++", + f"--env=CC=/mnt/zig-cc", + f"--env=CXX=/mnt/zig-c++", # -Wp,-D_FORTIFY_SOURCE=2 # https://github.com/giampaolo/psutil/blob/master/setup.py#L254 # defaults to using python's flags # f"--env=CFLAGS=", + f"--env=bustcachez=", "--env=CXXFLAGS=-Dundefined=64", f"--unsetenv=CC", f"--unsetenv=CXX", @@ -145,6 +146,10 @@ def buildinputs( subprocess.check_call([MAKE, "bin/buildinputs"], cwd=ROOT_DIR) if not (ROOT_DIR / "bin/zig-0.15.1").exists(): subprocess.check_call([MAKE, "bin/zig-0.15.1"], cwd=ROOT_DIR) + if not (ROOT_DIR / "bin/zig-0.15.1/zigcc").exists(): + subprocess.check_call([MAKE, "build"], cwd=ROOT_DIR / "scripts/zigcc") + shutil.copy(ROOT_DIR / "scripts/zigcc/bin/zigcc", ROOT_DIR / "bin/zig-0.15.1/zig-cc") + shutil.copy(ROOT_DIR / "scripts/zigcc/bin/zigcc", ROOT_DIR / "bin/zig-0.15.1/zig-c++") stdout = subprocess.check_output([ROOT_DIR / "bin/buildinputs", str(dockerfile)], text=True, cwd=ROOT_DIR, env={"TARGETPLATFORM": platform, **os.environ}) From bf837dc820163d746fc292605d2e7ccdb3ce83c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Wed, 24 Sep 2025 10:47:14 +0200 Subject: [PATCH 13/14] Add `ninja-build` dependency for s390x and ppc64le in `ubi9-python-3.12` Dockerfile --- runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu index ca5acf58d9..c3a857c467 100644 --- a/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu +++ b/runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu @@ -33,7 +33,7 @@ RUN ARCH=$(uname -m) && \ echo "Detected architecture: $ARCH" && \ PACKAGES="perl mesa-libGL skopeo" && \ if [ "$ARCH" = "s390x" ] || [ "$ARCH" = "ppc64le" ]; then \ - PACKAGES="$PACKAGES gcc g++ make openssl-devel autoconf automake libtool cmake"; \ + PACKAGES="$PACKAGES gcc g++ ninja-build openssl-devel autoconf automake libtool cmake"; \ fi && \ dnf install -y $PACKAGES && \ dnf clean all && rm -rf /var/cache/yum From c6c9441649daa809cfcf5c882c5d1664d9d3e491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Wed, 24 Sep 2025 19:31:59 +0200 Subject: [PATCH 14/14] without zig, before 10 min https://github.com/opendatahub-io/notebooks/actions/runs/17971438786/job/51114822510?pr=2535 --- scripts/sandbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sandbox.py b/scripts/sandbox.py index 217ba4ad22..6df75c426a 100755 --- a/scripts/sandbox.py +++ b/scripts/sandbox.py @@ -53,8 +53,8 @@ def main() -> int: f"--volume={os.getcwd()}/bin/zig-0.15.1:/mnt", # f"--env=CC=/mnt/zig cc -target {target}", # f"--env=CXX=/mnt/zig c++ -target {target}", - f"--env=CC=/mnt/zig-cc", - f"--env=CXX=/mnt/zig-c++", + # f"--env=CC=/mnt/zig-cc", + # f"--env=CXX=/mnt/zig-c++", # -Wp,-D_FORTIFY_SOURCE=2 # https://github.com/giampaolo/psutil/blob/master/setup.py#L254 # defaults to using python's flags