diff --git a/cross/pendulum/Makefile b/cross/pendulum/Makefile index d50d860c45f..90833b9fb72 100644 --- a/cross/pendulum/Makefile +++ b/cross/pendulum/Makefile @@ -8,12 +8,14 @@ PKG_DIR = $(PKG_NAME)-$(PKG_VERS) DEPENDS = HOMEPAGE = https://pendulum.eustace.io -COMMENT = Python datetimes made easy +COMMENT = Python datetimes made easy. LICENSE = MIT # toolchains lacking atomic support UNSUPPORTED_ARCHS = $(OLD_PPC_ARCHS) $(ARMv5_ARCHS) $(ARMv7L_ARCHS) +PATCHES_LEVEL = 1 + include ../../mk/spksrc.common.mk ifeq ($(call version_le, $(TC_GCC), 5),1) diff --git a/cross/pendulum/patches/001-fix-build-for-32bit.patch b/cross/pendulum/patches/001-rust-Use-i64-for-internal-unix-timestamps.patch similarity index 65% rename from cross/pendulum/patches/001-fix-build-for-32bit.patch rename to cross/pendulum/patches/001-rust-Use-i64-for-internal-unix-timestamps.patch index a80b3703acf..fa01779b7f3 100644 --- a/cross/pendulum/patches/001-fix-build-for-32bit.patch +++ b/cross/pendulum/patches/001-rust-Use-i64-for-internal-unix-timestamps.patch @@ -1,6 +1,39 @@ ---- rust/src/helpers-orig.rs 2023-12-16 17:04:29 -+++ rust/src/helpers.rs 2025-01-19 08:51:27 -@@ -49,57 +49,57 @@ +https://sources.debian.org/patches/pendulum/3.0.0-2/rust-Use-i64-for-internal-unix-timestamps.patch + +From: Benjamin Drung +Date: Thu, 5 Sep 2024 14:03:44 +0200 +Subject: rust: Use i64 for internal unix timestamps + +pendulum 3.0.0 fails to build on 32-bit armhf: + +``` +error: this arithmetic operation will overflow + --> src/helpers.rs:59:20 + | +59 | seconds += ((146_097 - 10957) * SECS_PER_DAY as usize) as isize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `135140_usize * 86400_usize`, which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default +``` + +`(146_097 - 10957) * SECS_PER_DAY` equals 11,676,096,000 which does not +fit into 32 bit integers. + +Use i64 for the seconds variable while handling with the timestamp. Only +convert in to `usize` once the timestamp is split into its components. + +Fixes https://github.com/sdispater/pendulum/issues/784 +Ubuntu-Bug: https://bugs.launchpad.net/ubuntu/+source/pendulum/+bug/2079029 +Forwarded: https://github.com/sdispater/pendulum/pull/842 +--- + rust/src/helpers.rs | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) + +diff --git a/rust/src/helpers.rs b/rust/src/helpers.rs +index 364075a..7927413 100644 +--- a/rust/src/helpers.rs ++++ b/rust/src/helpers.rs +@@ -49,57 +49,57 @@ pub fn local_time( microsecond: usize, ) -> (usize, usize, usize, usize, usize, usize, usize) { let mut year: usize = EPOCH_YEAR as usize; @@ -45,23 +78,23 @@ } - let mut sec_per_4years = SECS_PER_4_YEARS[leap_year] as isize; -+ let mut sec_per_4years = SECS_PER_4_YEARS[leap_year].into(); ++ let mut sec_per_4years = SECS_PER_4_YEARS[leap_year].try_into().unwrap(); while seconds >= sec_per_4years { seconds -= sec_per_4years; year += 4; leap_year = 1; // 4-year, non century aligned - sec_per_4years = SECS_PER_4_YEARS[leap_year] as isize; -+ sec_per_4years = SECS_PER_4_YEARS[leap_year].into(); ++ sec_per_4years = SECS_PER_4_YEARS[leap_year].try_into().unwrap(); } - let mut sec_per_year = SECS_PER_YEAR[leap_year] as isize; -+ let mut sec_per_year = SECS_PER_YEAR[leap_year].into(); ++ let mut sec_per_year = SECS_PER_YEAR[leap_year].try_into().unwrap(); while seconds >= sec_per_year { seconds -= sec_per_year; year += 1; leap_year = 0; // non 4-year aligned - sec_per_year = SECS_PER_YEAR[leap_year] as isize; -+ sec_per_year = SECS_PER_YEAR[leap_year].into(); ++ sec_per_year = SECS_PER_YEAR[leap_year].try_into().unwrap(); } // Handle months and days @@ -73,7 +106,7 @@ let mut month_offset: usize; while month != (TM_JANUARY + 1) { -@@ -113,10 +113,10 @@ +@@ -113,10 +113,10 @@ pub fn local_time( } // Handle hours, minutes and seconds