public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/gdl] rawhide: Fix RISC-V build
Date: Tue, 22 Sep 2026 01:03:54 GMT	[thread overview]
Message-ID: <179003903490.1.14331043909008975494.rpms-gdl-85f7825a1b1b@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/gdl
            Branch : rawhide
            Commit : 85f7825a1b1bbde8b322418278d5bca4c608c404
            Author : Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
            Date   : 2026-09-02T19:45:48+02:00
            Stats  : +158/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/rpms/gdl/c/85f7825a1b1bbde8b322418278d5bca4c608c404?branch=rawhide

            Log:
            Fix RISC-V build

Several things around handling float/integer things needed handling.

Changes are sent upstream: https://github.com/gnudatalanguage/gdl/pull/2229

---
diff --git a/0001-Enable-float-to-unsigned-conversion-workaround-on-RI.patch b/0001-Enable-float-to-unsigned-conversion-workaround-on-RI.patch
new file mode 100644
index 0000000..628e38e
--- /dev/null
+++ b/0001-Enable-float-to-unsigned-conversion-workaround-on-RI.patch
@@ -0,0 +1,48 @@
+From 1f67aeaa5427843b343803d331c05238f27d7c39 Mon Sep 17 00:00:00 2001
+From: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+Date: Wed, 2 Sep 2026 18:09:05 +0200
+Subject: [PATCH 1/3] Enable float-to-unsigned conversion workaround on RISC-V
+
+The RISC-V ISA, like ARM64, saturates negative floating-point values
+to zero when converting to unsigned integer types (via fcvt.wu/fcvt.lu
+instructions). This differs from x86 which wraps through the signed
+type due to undefined behavior in C/C++.
+
+GDL already had a workaround for ARM64 that converts float to the
+corresponding signed type first, then to unsigned (well-defined
+wrapping). Extend this workaround to RISC-V by adding __riscv to the
+preprocessor conditions.
+
+Assisted-by: Claude (Anthropic)
+Signed-off-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+
+Sent upstream: https://github.com/gnudatalanguage/gdl/pull/2229
+---
+ src/convert2.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/convert2.cpp b/src/convert2.cpp
+index 39c6888..0ad8013 100644
+--- a/src/convert2.cpp
++++ b/src/convert2.cpp
+@@ -41,7 +41,7 @@ using namespace std;
+         if( nEl == 1) { (*dest)[0]=static_cast<unsigned>(static_cast<signed>((*this)[0])); if( (mode & BaseGDL::CONVERT) != 0) delete this; return dest;}\
+         if((GDL_NTHREADS=parallelize(nEl,  TP_ARRAY_INITIALISATION))==1) {for( SizeT i=0; i < nEl; ++i) (*dest)[i]=static_cast<unsigned>(static_cast<signed>((*this)[i])); if( (mode & BaseGDL::CONVERT) != 0) delete this; return dest; }
+ 
+-#ifdef __aarch64__
++#if defined(__aarch64__) || defined(__riscv)
+ #define DO_CONVERT_START_FLOAT_TO_UNSIGNED(tnew, unsigned, signed) DO_CONVERT_START_FLOAT_TO_UNSIGNED_ARM64(tnew, unsigned, signed)
+ #else
+ #define DO_CONVERT_START_FLOAT_TO_UNSIGNED(tnew, unsigned, signed) DO_CONVERT_START_FLOAT_TO_UNSIGNED_IA64(tnew, unsigned, signed)
+@@ -63,7 +63,7 @@ using namespace std;
+         Data_<tnew>* dest=new Data_<tnew>( dim, BaseGDL::NOZERO);\
+         if( nEl == 1) { (*dest)[0]=static_cast<unsigned>(static_cast<signed>((*this)[0].real())); if( (mode & BaseGDL::CONVERT) != 0) delete this; return dest;}\
+         if((GDL_NTHREADS=parallelize(nEl,  TP_ARRAY_INITIALISATION))==1) {for( SizeT i=0; i < nEl; ++i) (*dest)[i]=static_cast<unsigned>(static_cast<signed>((*this)[i].real())); if( (mode & BaseGDL::CONVERT) != 0) delete this; return dest; }
+-#ifdef __aarch64__
++#if defined(__aarch64__) || defined(__riscv)
+ #define DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX(tnew, unsigned, signed) DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX_ARM64(tnew, unsigned, signed)
+ #else
+ #define DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX(tnew, unsigned, signed) DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX_IA64(tnew, unsigned, signed)
+-- 
+2.55.0
+

diff --git a/0002-Use-signed-cast-for-float-to-BYTE-conversion-on-non-.patch b/0002-Use-signed-cast-for-float-to-BYTE-conversion-on-non-.patch
new file mode 100644
index 0000000..18d5283
--- /dev/null
+++ b/0002-Use-signed-cast-for-float-to-BYTE-conversion-on-non-.patch
@@ -0,0 +1,68 @@
+From f118d58249ba6fd1be47c5303f85b2c1705600c8 Mon Sep 17 00:00:00 2001
+From: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+Date: Wed, 2 Sep 2026 18:09:24 +0200
+Subject: [PATCH 2/3] Use signed cast for float-to-BYTE conversion on non-x86
+ architectures
+
+The float/double/complex-to-BYTE (unsigned char) conversion paths were
+using direct assignment, bypassing the signed-cast workaround already
+used for UINT, ULONG and ULONG64. On RISC-V (and potentially ARM64),
+this causes negative float values to saturate to zero instead of
+wrapping like on x86, breaking test_rounding for BYTE on the negative
+side.
+
+Switch these paths to use DO_CONVERT_START_FLOAT_TO_UNSIGNED (and the
+CPX variant) so BYTE gets the same float->signed->unsigned treatment as
+the other unsigned types.
+
+Assisted-by: Claude (Anthropic)
+Signed-off-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+
+Sent upstream: https://github.com/gnudatalanguage/gdl/pull/2229
+---
+ src/convert2.cpp | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/convert2.cpp b/src/convert2.cpp
+index 0ad8013..c6c9cee 100644
+--- a/src/convert2.cpp
++++ b/src/convert2.cpp
+@@ -693,7 +693,7 @@ template<> BaseGDL* Data_<SpDFloat>::Convert2(DType destTy, BaseGDL::Convert2Mod
+ 
+   switch (destTy) {
+   case GDL_BYTE:
+-    DO_CONVERT_START(SpDByte)
++    DO_CONVERT_START_FLOAT_TO_UNSIGNED(SpDByte, DByte, DInt)
+     TRACEOMP(__FILE__, __LINE__)
+ #pragma omp parallel for num_threads(GDL_NTHREADS)
+       DO_CONVERT_END
+@@ -779,7 +779,7 @@ template<> BaseGDL* Data_<SpDDouble>::Convert2(DType destTy, BaseGDL::Convert2Mo
+ 
+   switch (destTy) {
+   case GDL_BYTE:
+-    DO_CONVERT_START(SpDByte)
++    DO_CONVERT_START_FLOAT_TO_UNSIGNED(SpDByte, DByte, DInt)
+     TRACEOMP(__FILE__, __LINE__)
+ #pragma omp parallel for num_threads(GDL_NTHREADS)
+       DO_CONVERT_END
+@@ -1166,7 +1166,7 @@ template<> BaseGDL* Data_<SpDComplex>::Convert2(DType destTy, BaseGDL::Convert2M
+ 
+   switch (destTy) {
+   case GDL_BYTE:
+-    DO_CONVERT_START_CPX(SpDByte)
++    DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX(SpDByte, DByte, DInt)
+     TRACEOMP(__FILE__, __LINE__)
+ #pragma omp parallel for num_threads(GDL_NTHREADS)
+       DO_CONVERT_END_CPX
+@@ -1278,7 +1278,7 @@ template<> BaseGDL* Data_<SpDComplexDbl>::Convert2(DType destTy, BaseGDL::Conver
+ 
+   switch (destTy) {
+   case GDL_BYTE:
+-    DO_CONVERT_START_CPX(SpDByte)
++    DO_CONVERT_START_FLOAT_TO_UNSIGNED_CPX(SpDByte, DByte, DInt)
+     TRACEOMP(__FILE__, __LINE__)
+ #pragma omp parallel for num_threads(GDL_NTHREADS)
+       DO_CONVERT_END_CPX
+-- 
+2.55.0
+

diff --git a/0003-Remove-test_rounding-from-ARM_XFAIL_TESTS.patch b/0003-Remove-test_rounding-from-ARM_XFAIL_TESTS.patch
new file mode 100644
index 0000000..a6f6dad
--- /dev/null
+++ b/0003-Remove-test_rounding-from-ARM_XFAIL_TESTS.patch
@@ -0,0 +1,34 @@
+From 4289aa4630f824a9d3ef0d74f25515a9206e5bbb Mon Sep 17 00:00:00 2001
+From: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+Date: Wed, 2 Sep 2026 18:10:30 +0200
+Subject: [PATCH 3/3] Remove test_rounding from ARM_XFAIL_TESTS
+
+The test_rounding test was marked as expected-to-fail (WILL_FAIL) on
+aarch64 because float-to-unsigned-BYTE conversion produced incorrect
+results. The preceding patches fix the underlying conversion issue by
+using an intermediate signed cast, so the test now passes and should no
+longer be marked as expected failure.
+
+Assisted-by: Claude (Anthropic)
+Signed-off-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+
+Sent upstream: https://github.com/gnudatalanguage/gdl/pull/2229
+---
+ testsuite/CMakeLists.txt | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/testsuite/CMakeLists.txt b/testsuite/CMakeLists.txt
+index 4b5278f..6bf6b4d 100644
+--- a/testsuite/CMakeLists.txt
++++ b/testsuite/CMakeLists.txt
+@@ -41,7 +41,6 @@ set_tests_properties(${TESTS} PROPERTIES ENVIRONMENT "LC_COLLATE=C;GDL_PATH=${BA
+ set(ARM_XFAIL_TESTS
+     test_byte_conversion.pro
+     test_formats.pro
+-    test_rounding.pro
+ )
+ foreach(test ${ARM_XFAIL_TESTS})
+   set_tests_properties(${test} PROPERTIES WILL_FAIL $<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},aarch64>)
+-- 
+2.55.0
+

diff --git a/gdl.spec b/gdl.spec
index 3e8fc28..bb5be6e 100644
--- a/gdl.spec
+++ b/gdl.spec
@@ -41,6 +41,9 @@ Source1:        xorg.conf
 # Build with system antlr library.  Request for upstream change here:
 # https://sourceforge.net/tracker/index.php?func=detail&aid=2685215&group_id=97659&atid=618686
 Patch1:         gdl-antlr.patch
+Patch2:         0001-Enable-float-to-unsigned-conversion-workaround-on-RI.patch
+Patch3:         0002-Use-signed-cast-for-float-to-BYTE-conversion-on-non-.patch
+Patch4:         0003-Remove-test_rounding-from-ARM_XFAIL_TESTS.patch
 
 BuildRequires:  gcc-c++
 BuildRequires:  antlr-C++
@@ -136,7 +139,12 @@ Provides:       %{name}-runtime = %{version}-%{release}
 rm -rf src/antlr src/libdivide.h
 # Not yet possible to build with external dSFMT
 #rm -r src/dSFMT
+# Normalize CRLF line endings to LF so patches apply cleanly
+find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' | xargs sed -i 's/\r$//'
 %patch -P1 -p1 -b .antlr
+%patch -P2 -p1 -b .riscv-unsigned
+%patch -P3 -p1 -b .riscv-byte
+%patch -P4 -p1 -b .xfail-rounding
 
 pushd src
 for f in *.g

                 reply	other threads:[~2026-09-22  1:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179003903490.1.14331043909008975494.rpms-gdl-85f7825a1b1b@fedoraproject.org \
    --to=mjuszkiewicz@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox