git: e77ee66128b6 - main - misc/codex: fix build on powerpc64*
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 23 Oct 2026 11:48:59 UTC
The branch main has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/ports/commit/?id=e77ee66128b6a3c2bba7a4863ad98571c9c8e3b5
commit e77ee66128b6a3c2bba7a4863ad98571c9c8e3b5
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-20 13:02:05 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-10-23 11:48:15 +0000
misc/codex: fix build on powerpc64*
Build V8 without the sandbox and Maglev on powerpc64, which its PPC64
backend does not support, let clang use its own target on FreeBSD
instead of the Linux triple, add the ppc64 clang toolchain, require
POWER8 vectors for simdutf's PPC64 kernel as upstream does and carry
node's big-endian byte order, ELFv2 and sampler fixes.
---
.../files/patch-cargo-crates_v8-150.4.0_build.rs | 38 ++++++++++++++++++----
...s_v8-150.4.0_build_config_compiler__cpu__abi.gn | 9 +++++
...tes_v8-150.4.0_build_toolchain_freebsd_BUILD.gn | 9 ++++-
...rates_v8-150.4.0_third__party_simdutf_simdutf.h | 11 +++++++
...h-cargo-crates_v8-150.4.0_v8_include_v8config.h | 17 +++++++---
...s_v8-150.4.0_v8_src_codegen_ppc_constants-ppc.h | 20 ++++++++++++
...-crates_v8-150.4.0_v8_src_libsampler_sampler.cc | 6 +++-
7 files changed, 98 insertions(+), 12 deletions(-)
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build.rs b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build.rs
index 5f189151c651..0fc8b39b3901 100644
--- a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build.rs
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build.rs
@@ -1,15 +1,28 @@
--- cargo-crates/v8-150.4.0/build.rs.orig 2026-08-22 00:08:58 UTC
+++ cargo-crates/v8-150.4.0/build.rs
-@@ -289,8 +289,6 @@ fn build_v8(is_asan: bool) {
+@@ -288,8 +288,6 @@
+ if need_gn_ninja_download() {
download_ninja_gn_binaries();
}
-
-- download_rust_toolchain();
-
+- download_rust_toolchain();
+
// `#[cfg(...)]` attributes don't work as expected from build.rs -- they refer to the configuration
// of the host system which the build.rs script will be running on. In short, `cfg!(target_<os/arch>)`
- // is actually the host os/arch instead of target os/arch while cross compiling. Instead, Environment variables
-@@ -420,8 +418,10 @@ fn build_v8(is_asan: bool) {
+@@ -313,7 +311,11 @@
+ ));
+
+ let extra_args = {
+- if env::var("CARGO_FEATURE_V8_ENABLE_SANDBOX").is_ok() {
++ // The PPC64 backend does not support the sandbox (Liftoff and the macro
++ // assembler static_assert on it), so build without it there.
++ if env::var("CARGO_FEATURE_V8_ENABLE_SANDBOX").is_ok()
++ && target_arch != "powerpc64"
++ {
+ vec![
+ // Enable pointer compression (along with its dependencies)
+ "v8_enable_sandbox=true",
+@@ -420,8 +422,10 @@
gn_args.push(r#"target_cpu="arm""#.to_string());
gn_args.push(r#"v8_target_cpu="arm""#.to_string());
gn_args.push("use_sysroot=true".to_string());
@@ -22,7 +35,20 @@
}
if target_arch == "riscv64" {
gn_args.push(r#"target_cpu="riscv64""#.to_string());
-@@ -504,7 +504,9 @@ fn build_v8(is_asan: bool) {
+@@ -433,6 +437,12 @@
+ maybe_install_sysroot("amd64");
+ }
+ }
++ if target_arch == "powerpc64" {
++ // The PPC64 Maglev backend is incomplete (the shared Maglev code still
++ // expects sandbox support from it); Node.js does not build Maglev on
++ // PPC64 either.
++ gn_args.push("v8_enable_maglev=false".to_string());
++ }
+
+ // musl libc. V8's build targets glibc by default; the vendored build config
+ // grows a target-scoped `use_musl` arg (see //build/config/rust.gni,
+@@ -504,7 +514,9 @@
gn_args.push(format!(r#"target_cpu="{arch}""#).to_string());
gn_args.push(r#"target_os="android""#.to_string());
gn_args.push("treat_warnings_as_errors=false".to_string());
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_config_compiler__cpu__abi.gn b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_config_compiler__cpu__abi.gn
index 160b6d79f574..1bef5db16a4a 100644
--- a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_config_compiler__cpu__abi.gn
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_config_compiler__cpu__abi.gn
@@ -36,3 +36,12 @@
cpu_abi_cflags += [ "--target=aarch64-linux-gnu" ]
cpu_abi_ldflags += [ "--target=aarch64-linux-gnu" ]
}
+@@ -333,7 +333,7 @@ if ((is_posix && !is_apple) || is_fuchsia) {
+ cpu_abi_cflags += [ "-maix64" ]
+ cpu_abi_ldflags += [ "-maix64" ]
+ }
+- } else if (is_clang) {
++ } else if (is_clang && !is_bsd) {
+ cpu_abi_cflags += [ "--target=powerpc64le-unknown-linux-gnu" ]
+ cpu_abi_ldflags += [ "--target=powerpc64le-unknown-linux-gnu" ]
+ } else {
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_toolchain_freebsd_BUILD.gn b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_toolchain_freebsd_BUILD.gn
index ba599a1eaf48..b02c4921be9f 100644
--- a/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_toolchain_freebsd_BUILD.gn
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_build_toolchain_freebsd_BUILD.gn
@@ -1,6 +1,6 @@
--- cargo-crates/v8-150.4.0/build/toolchain/freebsd/BUILD.gn.orig 2026-08-21 23:59:36 UTC
+++ cargo-crates/v8-150.4.0/build/toolchain/freebsd/BUILD.gn
-@@ -0,0 +1,66 @@
+@@ -0,0 +1,73 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
@@ -67,3 +67,10 @@
+ current_os = "freebsd"
+ }
+}
++
++clang_toolchain("clang_ppc64") {
++ toolchain_args = {
++ current_cpu = "ppc64"
++ current_os = "freebsd"
++ }
++}
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_third__party_simdutf_simdutf.h b/misc/codex/files/patch-cargo-crates_v8-150.4.0_third__party_simdutf_simdutf.h
new file mode 100644
index 000000000000..1c5201396b93
--- /dev/null
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_third__party_simdutf_simdutf.h
@@ -0,0 +1,11 @@
+--- cargo-crates/v8-150.4.0/third_party/simdutf/simdutf.h.orig 2026-10-20 01:13:45 UTC
++++ cargo-crates/v8-150.4.0/third_party/simdutf/simdutf.h
+@@ -166,7 +166,7 @@
+ #elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
+ #define SIMDUTF_IS_ARM64 1
+ #elif defined(__PPC64__) || defined(_M_PPC64)
+- #if defined(__VEC__) && defined(__ALTIVEC__)
++ #if defined(__VEC__) && defined(__ALTIVEC__) && defined(__POWER8_VECTOR__)
+ #define SIMDUTF_IS_PPC64 1
+ #endif
+ #elif defined(__s390__)
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_include_v8config.h b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_include_v8config.h
index 2f17e7c00244..b1a7fda81efd 100644
--- a/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_include_v8config.h
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_include_v8config.h
@@ -1,6 +1,6 @@
--- cargo-crates/v8-150.4.0/v8/include/v8config.h.orig 2006-07-24 01:21:28 UTC
+++ cargo-crates/v8-150.4.0/v8/include/v8config.h
-@@ -207,6 +207,8 @@ path. Add it with -I<path> to the command line
+@@ -207,6 +207,8 @@
&& !defined(V8_TARGET_OS_IOS) \
&& !defined(V8_TARGET_OS_TVOS) \
&& !defined(V8_TARGET_OS_LINUX) \
@@ -9,7 +9,7 @@
&& !defined(V8_TARGET_OS_MACOS) \
&& !defined(V8_TARGET_OS_WIN) \
&& !defined(V8_TARGET_OS_CHROMEOS)
-@@ -220,6 +222,8 @@ path. Add it with -I<path> to the command line
+@@ -220,6 +222,8 @@
|| defined(V8_TARGET_OS_IOS) \
|| defined(V8_TARGET_OS_TVOS) \
|| defined(V8_TARGET_OS_LINUX) \
@@ -18,7 +18,7 @@
|| defined(V8_TARGET_OS_MACOS) \
|| defined(V8_TARGET_OS_WIN) \
|| defined(V8_TARGET_OS_CHROMEOS)
-@@ -247,6 +251,16 @@ path. Add it with -I<path> to the command line
+@@ -247,6 +251,16 @@
# define V8_TARGET_OS_LINUX
#endif
@@ -35,7 +35,7 @@
#ifdef V8_OS_MACOS
# define V8_TARGET_OS_MACOS
#endif
-@@ -394,6 +408,7 @@ path. Add it with -I<path> to the command line
+@@ -394,6 +408,7 @@
#if (defined(_M_X64) || defined(__x86_64__) /* x64 (everywhere) */ \
|| ((defined(__AARCH64EL__) || defined(_M_ARM64)) /* arm64, but ... */ \
&& !defined(_WIN32))) /* not on windows */ \
@@ -43,3 +43,12 @@
&& !defined(COMPONENT_BUILD) /* no component build */\
&& __clang_major__ >= 17 /* clang >= 17 */
# define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
+@@ -1028,7 +1043,7 @@
+ #define V8_TARGET_LITTLE_ENDIAN 1
+ #endif
+ #elif V8_TARGET_ARCH_PPC64
+-#if V8_OS_AIX
++#if defined(__BIG_ENDIAN__) || defined(V8_OS_AIX)
+ #define V8_TARGET_BIG_ENDIAN 1
+ #else
+ #define V8_TARGET_LITTLE_ENDIAN 1
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_codegen_ppc_constants-ppc.h b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_codegen_ppc_constants-ppc.h
new file mode 100644
index 000000000000..ade4eea405ce
--- /dev/null
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_codegen_ppc_constants-ppc.h
@@ -0,0 +1,20 @@
+--- cargo-crates/v8-150.4.0/v8/src/codegen/ppc/constants-ppc.h.orig 2006-07-24 01:21:28 UTC
++++ cargo-crates/v8-150.4.0/v8/src/codegen/ppc/constants-ppc.h
+@@ -35,7 +35,7 @@
+ #define ABI_PASSES_HANDLES_IN_REGS 0
+ #endif
+
+-#if !V8_HOST_ARCH_PPC64 || !V8_TARGET_ARCH_PPC64 || V8_TARGET_LITTLE_ENDIAN || \
++#if !V8_HOST_ARCH_PPC64 || !V8_TARGET_ARCH_PPC64 || \
+ (defined(_CALL_ELF) && _CALL_ELF == 2)
+ #define ABI_RETURNS_OBJECT_PAIRS_IN_REGS 1
+ #else
+@@ -44,7 +44,7 @@
+
+ #if !V8_HOST_ARCH_PPC64 || \
+ (V8_TARGET_ARCH_PPC64 && \
+- (V8_TARGET_LITTLE_ENDIAN || (defined(_CALL_ELF) && _CALL_ELF == 2)))
++ (defined(_CALL_ELF) && _CALL_ELF == 2))
+ #define ABI_CALL_VIA_IP 1
+ #else
+ #define ABI_CALL_VIA_IP 0
diff --git a/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_libsampler_sampler.cc b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_libsampler_sampler.cc
index 6ceed7fd3344..a1f959133501 100644
--- a/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_libsampler_sampler.cc
+++ b/misc/codex/files/patch-cargo-crates_v8-150.4.0_v8_src_libsampler_sampler.cc
@@ -1,6 +1,6 @@
--- cargo-crates/v8-150.4.0/v8/src/libsampler/sampler.cc.orig 2006-07-24 01:21:28 UTC
+++ cargo-crates/v8-150.4.0/v8/src/libsampler/sampler.cc
-@@ -529,6 +529,16 @@ void SignalHandler::FillRegisterState(void* context, R
+@@ -529,6 +529,20 @@ void SignalHandler::FillRegisterState(void* context, R
state->pc = reinterpret_cast<void*>(mcontext.__gregs[_REG_PC]);
state->sp = reinterpret_cast<void*>(mcontext.__gregs[_REG_SP]);
state->fp = reinterpret_cast<void*>(mcontext.__gregs[_REG_FP]);
@@ -14,6 +14,10 @@
+ state->sp = reinterpret_cast<void*>(mcontext.mc_gpregs.gp_sp);
+ state->fp = reinterpret_cast<void*>(mcontext.mc_gpregs.gp_x[29]);
+#endif // __CHERI_PURE_CAPABILITY__
++#elif V8_HOST_ARCH_PPC64
++ state->pc = reinterpret_cast<void*>(mcontext.mc_srr0);
++ state->sp = reinterpret_cast<void*>(mcontext.mc_frame[1]);
++ state->fp = reinterpret_cast<void*>(mcontext.mc_frame[31]);
#endif // V8_HOST_ARCH_*
#elif V8_OS_NETBSD
#if V8_HOST_ARCH_IA32