git: 4455ec0722d4 - main - misc/outside: fix build on powerpc64
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 15 Oct 2026 10:45:42 UTC
The branch main has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/ports/commit/?id=4455ec0722d47019a9d8107e3e78009497e9275a
commit 4455ec0722d47019a9d8107e3e78009497e9275a
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-15 08:08:36 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-10-15 10:45:21 +0000
misc/outside: fix build on powerpc64
The savefile crate refuses to build on big-endian targets with its
bit-vec feature, and its raw-memory fast paths write native byte order
there while the data is read back as little-endian, corrupting the
cache on round-trip. Serialize the BitVec storage words as little-endian
and disable the fast paths on big-endian.
---
.../patch-cargo-crates_savefile-0.19.0_src_lib.rs | 93 ++++++++++++++++++++++
...-cargo-crates_savefile-derive-0.19.0_src_lib.rs | 11 +++
2 files changed, 104 insertions(+)
diff --git a/misc/outside/files/patch-cargo-crates_savefile-0.19.0_src_lib.rs b/misc/outside/files/patch-cargo-crates_savefile-0.19.0_src_lib.rs
new file mode 100644
index 000000000000..f58abe981876
--- /dev/null
+++ b/misc/outside/files/patch-cargo-crates_savefile-0.19.0_src_lib.rs
@@ -0,0 +1,93 @@
+--- cargo-crates/savefile-0.19.0/src/lib.rs.orig 2006-07-24 01:21:28 UTC
++++ cargo-crates/savefile-0.19.0/src/lib.rs
+@@ -1184,8 +1184,12 @@ impl IsPacked {
+ /// a repr_c_optimization_safe-implementation is forbidden.
+ ///
+ /// Also, see description of Packed trait and repr_c_optimization_safe.
++ ///
++ /// The savefile disk format is little endian, so on big-endian hosts
++ /// the in-memory representation of multi-byte types never matches it
++ /// and the optimization is never allowed: there this returns `no()`.
+ pub unsafe fn yes() -> IsPacked {
+- IsPacked(true)
++ IsPacked(cfg!(target_endian = "little"))
+ }
+ /// No, the type is not compatible with the "Packed"-optimization.
+ /// It cannot be just blitted.
+@@ -6144,10 +6148,6 @@ impl Deserialize for chrono::DateTime<chrono::Utc> {
+
+
+
+-#[cfg(any(feature = "bit-vec", feature = "bit-vec08"))]
+-#[cfg(target_endian = "big")]
+-compile_error!("savefile bit-vec feature does not support big-endian machines");
+-
+ #[cfg(feature = "bit-vec")]
+ impl WithSchema for bit_vec::BitVec {
+ fn schema(version: u32, context: &mut WithSchemaContext) -> Schema {
+@@ -6204,10 +6204,16 @@ impl Serialize for bit_vec::BitVec<u32> {
+ let l = self.len();
+ serializer.write_usize(l)?;
+ let storage = self.storage();
+- let rawbytes_ptr = storage.as_ptr() as *const u8;
+- let rawbytes: &[u8] = unsafe { std::slice::from_raw_parts(rawbytes_ptr, 4 * storage.len()) };
+- serializer.write_usize(rawbytes.len() | (1 << 63))?;
+- serializer.write_bytes(rawbytes)?;
++ serializer.write_usize((4 * storage.len()) | (1 << 63))?;
++ if cfg!(target_endian = "little") {
++ let rawbytes_ptr = storage.as_ptr() as *const u8;
++ let rawbytes: &[u8] = unsafe { std::slice::from_raw_parts(rawbytes_ptr, 4 * storage.len()) };
++ serializer.write_bytes(rawbytes)?;
++ } else {
++ for word in storage {
++ serializer.write_u32(*word)?;
++ }
++ }
+ Ok(())
+ }
+ }
+@@ -6231,6 +6237,11 @@ impl Deserialize for bit_vec::BitVec<u32> {
+ let storage_ptr = storage.as_ptr() as *mut u8;
+ let storage_bytes: &mut [u8] = std::slice::from_raw_parts_mut(storage_ptr, 4 * num_words);
+ deserializer.read_bytes_to_buf(storage_bytes)?;
++ if cfg!(target_endian = "big") {
++ for word in storage.iter_mut() {
++ *word = u32::from_le(*word);
++ }
++ }
+ ret.set_len(numbits);
+ }
+ Ok(ret)
+@@ -6370,10 +6381,16 @@ impl Serialize for bit_vec08::BitVec<u32> {
+ let l = self.len();
+ serializer.write_usize(l)?;
+ let storage = self.storage();
+- let rawbytes_ptr = storage.as_ptr() as *const u8;
+- let rawbytes: &[u8] = unsafe { std::slice::from_raw_parts(rawbytes_ptr, 4 * storage.len()) };
+- serializer.write_usize(rawbytes.len() | (1 << 63))?;
+- serializer.write_bytes(rawbytes)?;
++ serializer.write_usize((4 * storage.len()) | (1 << 63))?;
++ if cfg!(target_endian = "little") {
++ let rawbytes_ptr = storage.as_ptr() as *const u8;
++ let rawbytes: &[u8] = unsafe { std::slice::from_raw_parts(rawbytes_ptr, 4 * storage.len()) };
++ serializer.write_bytes(rawbytes)?;
++ } else {
++ for word in storage {
++ serializer.write_u32(*word)?;
++ }
++ }
+ Ok(())
+ }
+ }
+@@ -6397,6 +6414,11 @@ impl Deserialize for bit_vec08::BitVec<u32> {
+ let storage_ptr = storage.as_ptr() as *mut u8;
+ let storage_bytes: &mut [u8] = std::slice::from_raw_parts_mut(storage_ptr, 4 * num_words);
+ deserializer.read_bytes_to_buf(storage_bytes)?;
++ if cfg!(target_endian = "big") {
++ for word in storage.iter_mut() {
++ *word = u32::from_le(*word);
++ }
++ }
+ ret.set_len(numbits);
+ }
+ Ok(ret)
diff --git a/misc/outside/files/patch-cargo-crates_savefile-derive-0.19.0_src_lib.rs b/misc/outside/files/patch-cargo-crates_savefile-derive-0.19.0_src_lib.rs
new file mode 100644
index 000000000000..4295245f4d30
--- /dev/null
+++ b/misc/outside/files/patch-cargo-crates_savefile-derive-0.19.0_src_lib.rs
@@ -0,0 +1,11 @@
+--- cargo-crates/savefile-derive-0.19.0/src/lib.rs.orig 2026-10-15 08:32:14 UTC
++++ cargo-crates/savefile-derive-0.19.0/src/lib.rs
+@@ -96,7 +96,7 @@ fn implement_fields_serialize(
+ output.push(
+ quote!(
+ unsafe {
+- if #(#conditions)* {
++ if cfg!(target_endian = "little") && #(#conditions)* {
+ #local_serializer.raw_write_region(self,&#deferred_from,&#deferred_to, local_serializer.file_version)?;
+ } else {
+ #(#fallbacks)*