GNU bug report logs - #51241
[PATCH 0/1] gnu: ragel: Fix build of knot on aarch64-linux.

Previous Next

Package: guix-patches;

Reported by: Simon South <simon <at> simonsouth.net>

Date: Sat, 16 Oct 2021 17:05:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51241 in the body.
You can then email your comments to 51241 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 17:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon South <simon <at> simonsouth.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 16 Oct 2021 17:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Sat, 16 Oct 2021 13:04:19 -0400
This change fixes the build of Knot on AArch64 by patching Ragel to be
explicit in its use of signed "char" types and ranges rather than assuming
"char" is signed by default on all platforms, as it is not on aarch64-linux.

Presently Knot's test suite is failing on aarch64-linux due to the
src/libknot/ypbody.c file being improperly recreated in the package's
"update-parser" phase.  From Knot's runtests.log:

    ok 139 - set input string
    # wanted: 0
    #   seen: -999
    not ok 140 - parse key with a value in UTF-8
    not ok 141 - compare UTF-8 value
    1..141
    # Looks like you failed 2 tests of 141

With the patch applied, ypbody.c is generated as expected (including now the
explicit use of "signed char" where intended) and the tests pass.

I've tested these changes on AArch64 and x86-64.  On the latter I've
sucessfully re-built the output of "guix refresh --list-dependent ragel" with
the exception of ccextractor, which fails (even without this patch) for an
unrelated reason.  (On AArch64 this rebuild would be an unreasonably large
task, though the immediate dependents all build fine.)

--
Simon South
simon <at> simonsouth.net


Simon South (1):
  gnu: ragel: Fix build of knot on aarch64-linux.

 gnu/local.mk                                  |  1 +
 .../ragel-specify-char-signedness.patch       | 58 +++++++++++++++++++
 gnu/packages/ragel.scm                        |  4 +-
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-specify-char-signedness.patch


base-commit: 34b0aa16e77bdbb5b847267eb0f825a590e3d101
-- 
2.33.0





Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 17:08:03 GMT) Full text and rfc822 format available.

Message #8 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: 51241 <at> debbugs.gnu.org
Subject: [PATCH 1/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Sat, 16 Oct 2021 13:06:39 -0400
Make explicit Ragel's assumption of the "char" type being signed on both its
build and target platforms, allowing the current version of Knot and perhaps
other dependent packages to build successfully on aarch64-linux where "char"
is unsigned by default.

* gnu/packages/patches/ragel-specify-char-signedness.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/ragel.scm (ragel)[source]: Apply it.
---
 gnu/local.mk                                  |  1 +
 .../ragel-specify-char-signedness.patch       | 58 +++++++++++++++++++
 gnu/packages/ragel.scm                        |  4 +-
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-specify-char-signedness.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d1803e7f59..a4dd01a40f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1716,6 +1716,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/quassel-qt-514-compat.patch		\
   %D%/packages/patches/quickswitch-fix-dmenu-check.patch	\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
+  %D%/packages/patches/ragel-specify-char-signedness.patch	\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
   %D%/packages/patches/rapidjson-gcc-compat.patch		\
diff --git a/gnu/packages/patches/ragel-specify-char-signedness.patch b/gnu/packages/patches/ragel-specify-char-signedness.patch
new file mode 100644
index 0000000000..fccb79d432
--- /dev/null
+++ b/gnu/packages/patches/ragel-specify-char-signedness.patch
@@ -0,0 +1,58 @@
+Ragel assumes C and C++'s "char" type is signed by default but this is not
+true for every architecture gcc supports.  Prevent build failures of dependent
+packages (on architectures such as AArch64 where "char" is normally unsigned)
+by making explicit Ragel's assumption of character signedness.
+
+This is functionally very similar to upstream commit e2650a7, "common: Fix
+ambiguous CHAR_MIN/MAX definition", which is also meant to address this issue.
+However this patch applies to Ragel version 6 and it removes altogether the
+ambiguous "char" type from generated C code, causing Ragel to instead specify
+"signed char" or "unsigned char" as appropriate.
+
+diff --git a/ragel/common.cpp b/ragel/common.cpp
+index 8e9f8ed0..649f388c 100644
+--- a/ragel/common.cpp
++++ b/ragel/common.cpp
+@@ -27,7 +27,7 @@
+ 
+ HostType hostTypesC[] =
+ {
+-	{ "char",     0,       "char",    true,   true,  false,  CHAR_MIN,  CHAR_MAX,   0, 0,              sizeof(char) },
++	{ "signed",   "char",  "char",    true,   true,  false,  SCHAR_MIN, SCHAR_MAX,  0, 0,              sizeof(signed char) },
+ 	{ "unsigned", "char",  "uchar",   false,  true,  false,  0, 0,                  0,     UCHAR_MAX,  sizeof(unsigned char) },
+ 	{ "short",    0,       "short",   true,   true,  false,  SHRT_MIN,  SHRT_MAX,   0, 0,              sizeof(short) },
+ 	{ "unsigned", "short", "ushort",  false,  true,  false,  0, 0,                  0,     USHRT_MAX,  sizeof(unsigned short) },
+@@ -66,7 +66,7 @@ HostType hostTypesC[] =
+ 
+ HostType hostTypesD[] =
+ {
+-	{ "byte",    0,  "byte",    true,   true,  false,  CHAR_MIN,  CHAR_MAX,    0, 0,                   1 },
++	{ "byte",    0,  "byte",    true,   true,  false,  SCHAR_MIN, SCHAR_MAX,   0, 0,                   1 },
+ 	{ "ubyte",   0,  "ubyte",   false,  true,  false,  0, 0,                   0,         UCHAR_MAX,   1 },
+ 	{ "char",    0,  "char",    false,  true,  false,  0, 0,                   0,         UCHAR_MAX,   1 },
+ 	{ "short",   0,  "short",   true,   true,  false,  SHRT_MIN,  SHRT_MAX,    0, 0,                   2 },
+@@ -93,7 +93,7 @@ HostType hostTypesGo[] =
+ 
+ HostType hostTypesJava[] = 
+ {
+-	{ "byte",    0,  "byte",   true,   true,  false,  CHAR_MIN,  CHAR_MAX,    0, 0,                   1 },
++	{ "byte",    0,  "byte",   true,   true,  false,  SCHAR_MIN, SCHAR_MAX,   0, 0,                   1 },
+ 	{ "short",   0,  "short",  true,   true,  false,  SHRT_MIN,  SHRT_MAX,    0, 0,                   2 },
+ 	{ "char",    0,  "char",   false,  true,  false,  0, 0,                   0,         USHRT_MAX,   2 },
+ 	{ "int",     0,  "int",    true,   true,  false,  INT_MIN,   INT_MAX,     0, 0,                   4 },
+@@ -102,13 +102,13 @@ HostType hostTypesJava[] =
+ /* What are the appropriate types for ruby? */
+ HostType hostTypesRuby[] = 
+ {
+-	{ "char",    0,  "char",   true,   true,  false,  CHAR_MIN,  CHAR_MAX,    0, 0, 1 },
++	{ "char",    0,  "char",   true,   true,  false,  SCHAR_MIN, SCHAR_MAX,   0, 0, 1 },
+ 	{ "int",     0,  "int",    true,   true,  false,  INT_MIN,   INT_MAX,     0, 0, 4 },
+ };
+ 
+ HostType hostTypesCSharp[] =
+ {
+-	{ "sbyte",   0,  "sbyte",   true,   true,  false,  CHAR_MIN,  CHAR_MAX,    0, 0,                   1 },
++	{ "sbyte",   0,  "sbyte",   true,   true,  false,  SCHAR_MIN, SCHAR_MAX,   0, 0,                   1 },
+ 	{ "byte",    0,  "byte",    false,  true,  false,  0, 0,                   0,         UCHAR_MAX,   1 },
+ 	{ "short",   0,  "short",   true,   true,  false,  SHRT_MIN,  SHRT_MAX,    0, 0,                   2 },
+ 	{ "ushort",  0,  "ushort",  false,  true,  false,  0, 0,                   0,         USHRT_MAX,   2 },
diff --git a/gnu/packages/ragel.scm b/gnu/packages/ragel.scm
index 1d9b67a6e0..e3fc980bd7 100644
--- a/gnu/packages/ragel.scm
+++ b/gnu/packages/ragel.scm
@@ -34,7 +34,9 @@ (define-public ragel
                                   version ".tar.gz"))
               (sha256
                (base32
-                "0gvcsl62gh6sg73nwaxav4a5ja23zcnyxncdcdnqa2yjcpdnw5az"))))
+                "0gvcsl62gh6sg73nwaxav4a5ja23zcnyxncdcdnqa2yjcpdnw5az"))
+              (patches
+               (search-patches "ragel-specify-char-signedness.patch"))))
     (build-system gnu-build-system)
     (home-page "https://www.colm.net/open-source/ragel/")
     (synopsis "State machine compiler")
-- 
2.33.0





Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 17:47:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Simon South <simon <at> simonsouth.net>
Cc: 51241 <at> debbugs.gnu.org, guix-patches <at> gnu.org
Subject: Re: [bug#51241] [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Sat, 16 Oct 2021 19:42:30 +0200
[Message part 1 (text/plain, inline)]
Simon,

Thanks for taking care of Knot.  The changes themselves LGTM.

Simon South 写道:
> With the patch applied

Mmm, that's some very raw diff! :-)

Is this an (applied?) upstream patch?  Or did you write it, and if 
so, have you submitted it for upstream inclusion anywhere its 
progress can be tracked?

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 17:47:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 20:10:02 GMT) Full text and rfc822 format available.

Message #17 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 51241 <at> debbugs.gnu.org
Subject: Re: [bug#51241] [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Sat, 16 Oct 2021 16:09:26 -0400
Tobias Geerinckx-Rice <me <at> tobias.gr> writes:
> Or did you write it, and if so, have you submitted it for upstream
> inclusion anywhere its progress can be tracked?

Yes, the patch is of my own creation (borrowing heavily from the
upstream commit I mention) but I haven't tried submitting it upstream
yet.  I agree that is where it really belongs, though.

I'll give that a shot and see what response I get.

-- 
Simon South
simon <at> simonsouth.net




Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sat, 16 Oct 2021 21:40:02 GMT) Full text and rfc822 format available.

Message #20 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Simon South <simon <at> simonsouth.net>
Cc: 51241 <at> debbugs.gnu.org
Subject: Re: [bug#51241] [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Sat, 16 Oct 2021 23:37:57 +0200
[Message part 1 (text/plain, inline)]
Simon South 写道:
> I'll give that a shot and see what response I get.

Thanks!  Let us know how it goes.

We don't have to wait for an upstream response to add it to Guix, 
but it's nice to be able to refer to the issue URL.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Fri, 12 Nov 2021 20:45:02 GMT) Full text and rfc822 format available.

Message #23 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: 51241 <at> debbugs.gnu.org
Subject: [PATCH v2 0/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Fri, 12 Nov 2021 15:44:39 -0500
After corresponding with Ragel's author, here's a patch that applies the
solution implemented upstream[0], backported from Ragel's "ragel-6" branch.
I've tested this on AArch64 and x86-64 and with these changes applied, Knot
builds fine again on both platforms.

On x86-64, I've once again rebuilt the output of "guix refresh
--list-dependent ragel" without issue, aside from ccextractor; on AArch64,
Ragel's immediate dependents[1] all build fine.

[0] https://github.com/adrian-thurston/ragel/commit/2e638fccd81e96ce09841adc4b295b5ce694ea73
[1] gpick, knot, rspamd, ruby-json-pure, ruby-parser and ruby-regexp-parser.

--
Simon South
simon <at> simonsouth.net


Simon South (1):
  gnu: ragel: Fix build of knot on aarch64-linux.

 gnu/local.mk                                  |  1 +
 .../ragel-decide-signedness-of-char.patch     | 42 +++++++++++++++++++
 gnu/packages/ragel.scm                        |  7 +++-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-decide-signedness-of-char.patch

-- 
2.33.1





Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Fri, 12 Nov 2021 20:45:02 GMT) Full text and rfc822 format available.

Message #26 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: 51241 <at> debbugs.gnu.org
Subject: [PATCH v2 1/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Fri, 12 Nov 2021 15:44:40 -0500
Apply a patch backported from Ragel's "ragel-6" branch that allows it to
reliably generate usable code on systems such as aarch64-linux where the C/C++
"char" type is unsigned by default, fixing the build of Knot on these systems.

* gnu/packages/patches/ragel-decide-signedness-of-char.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/ragel.scm (ragel)[source]: Apply it.
---
 gnu/local.mk                                  |  1 +
 .../ragel-decide-signedness-of-char.patch     | 42 +++++++++++++++++++
 gnu/packages/ragel.scm                        |  7 +++-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-decide-signedness-of-char.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 208875754b..2b66d7c07c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1717,6 +1717,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/quassel-qt-514-compat.patch		\
   %D%/packages/patches/quickswitch-fix-dmenu-check.patch	\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
+  %D%/packages/patches/ragel-decide-signedness-of-char.patch	\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
   %D%/packages/patches/rapidjson-gcc-compat.patch		\
diff --git a/gnu/packages/patches/ragel-decide-signedness-of-char.patch b/gnu/packages/patches/ragel-decide-signedness-of-char.patch
new file mode 100644
index 0000000000..b3b2bf958a
--- /dev/null
+++ b/gnu/packages/patches/ragel-decide-signedness-of-char.patch
@@ -0,0 +1,42 @@
+From 2e638fccd81e96ce09841adc4b295b5ce694ea73 Mon Sep 17 00:00:00 2001
+From: Adrian Thurston <thurston <at> colm.net>
+Date: Sat, 6 Nov 2021 12:20:05 -0700
+Subject: [PATCH] C char type: decide signedness of char based on CHAR_MIN
+
+Previously had char fixed to signed char, this is not useful on ARM as it does
+not align with the host type. Instead, decide at runtime (or probably compile
+time) if char is signed or not.
+---
+ ragel/common.cpp | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/ragel/common.cpp b/ragel/common.cpp
+index 8e9f8ed0..55875c06 100644
+--- a/ragel/common.cpp
++++ b/ragel/common.cpp
+@@ -27,14 +27,14 @@
+ 
+ HostType hostTypesC[] =
+ {
+-	{ "char",     0,       "char",    true,   true,  false,  CHAR_MIN,  CHAR_MAX,   0, 0,              sizeof(char) },
+-	{ "unsigned", "char",  "uchar",   false,  true,  false,  0, 0,                  0,     UCHAR_MAX,  sizeof(unsigned char) },
+-	{ "short",    0,       "short",   true,   true,  false,  SHRT_MIN,  SHRT_MAX,   0, 0,              sizeof(short) },
+-	{ "unsigned", "short", "ushort",  false,  true,  false,  0, 0,                  0,     USHRT_MAX,  sizeof(unsigned short) },
+-	{ "int",      0,       "int",     true,   true,  false,  INT_MIN,   INT_MAX,    0, 0,              sizeof(int) },
+-	{ "unsigned", "int",   "uint",    false,  true,  false,  0, 0,                  0,     UINT_MAX,   sizeof(unsigned int) },
+-	{ "long",     0,       "long",    true,   true,  false,  LONG_MIN,  LONG_MAX,   0, 0,              sizeof(long) },
+-	{ "unsigned", "long",  "ulong",   false,  true,  false,  0, 0,                  0,     ULONG_MAX,  sizeof(unsigned long) }
++	{ "char",     0,       "char",    (CHAR_MIN != 0), true,  false,  SCHAR_MIN, SCHAR_MAX,  0, UCHAR_MAX, sizeof(char) },
++	{ "unsigned", "char",  "uchar",   false,           true,  false,  0, 0,                  0, UCHAR_MAX, sizeof(unsigned char) },
++	{ "short",    0,       "short",   true,            true,  false,  SHRT_MIN,  SHRT_MAX,   0, 0,         sizeof(short) },
++	{ "unsigned", "short", "ushort",  false,           true,  false,  0, 0,                  0, USHRT_MAX, sizeof(unsigned short) },
++	{ "int",      0,       "int",     true,            true,  false,  INT_MIN,   INT_MAX,    0, 0,         sizeof(int) },
++	{ "unsigned", "int",   "uint",    false,           true,  false,  0, 0,                  0, UINT_MAX,  sizeof(unsigned int) },
++	{ "long",     0,       "long",    true,            true,  false,  LONG_MIN,  LONG_MAX,   0, 0,         sizeof(long) },
++	{ "unsigned", "long",  "ulong",   false,           true,  false,  0, 0,                  0, ULONG_MAX, sizeof(unsigned long) }
+ };
+ 
+ #define S8BIT_MIN  -128
+-- 
+2.33.1
+
diff --git a/gnu/packages/ragel.scm b/gnu/packages/ragel.scm
index 1d9b67a6e0..8b5100330a 100644
--- a/gnu/packages/ragel.scm
+++ b/gnu/packages/ragel.scm
@@ -34,7 +34,12 @@ (define-public ragel
                                   version ".tar.gz"))
               (sha256
                (base32
-                "0gvcsl62gh6sg73nwaxav4a5ja23zcnyxncdcdnqa2yjcpdnw5az"))))
+                "0gvcsl62gh6sg73nwaxav4a5ja23zcnyxncdcdnqa2yjcpdnw5az"))
+              (patches
+               (search-patches
+                ;; A backported fix for aarch64-linux, where the C/C++ "char"
+                ;; type is unsigned by default.
+                "ragel-decide-signedness-of-char.patch"))))
     (build-system gnu-build-system)
     (home-page "https://www.colm.net/open-source/ragel/")
     (synopsis "State machine compiler")
-- 
2.33.1





Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Sun, 19 Dec 2021 22:31:01 GMT) Full text and rfc822 format available.

Message #29 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon South <simon <at> simonsouth.net>
Cc: 51241 <at> debbugs.gnu.org
Subject: Re: bug#51241: [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Sun, 19 Dec 2021 23:30:26 +0100
Hi,

Simon South <simon <at> simonsouth.net> skribis:

> Apply a patch backported from Ragel's "ragel-6" branch that allows it to
> reliably generate usable code on systems such as aarch64-linux where the C/C++
> "char" type is unsigned by default, fixing the build of Knot on these systems.
>
> * gnu/packages/patches/ragel-decide-signedness-of-char.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/ragel.scm (ragel)[source]: Apply it.

Could you check whether this is still needed on current master,
ca. 9b38d9b3b34edb55f7f42b72a611b39e5164cf9f?

‘guix refresh -l ragel’ reports 5K dependents, so we’d need to apply the
patch conditionally for aarch64 in a phase, or something along these
lines.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Mon, 20 Dec 2021 22:59:01 GMT) Full text and rfc822 format available.

Message #32 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 51241 <at> debbugs.gnu.org
Subject: Re: bug#51241: [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Mon, 20 Dec 2021 17:57:32 -0500
Ludovic Courtès <ludo <at> gnu.org> writes:
> Could you check whether this is still needed on current master,
> ca. 9b38d9b3b34edb55f7f42b72a611b39e5164cf9f?

Unfortunately yes; Knot is still failing two "yparser" tests in master
(2c469f04a3be) on AArch64.

> ‘guix refresh -l ragel’ reports 5K dependents, so we’d need to apply the
> patch conditionally for aarch64 in a phase, or something along these
> lines.

I can submit a new patch with this change.  Or would it make more sense
to apply the existing patch to the version-1.4.0 branch, since it's
fixing an issue in master?

-- 
Simon South
simon <at> simonsouth.net




Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Tue, 21 Dec 2021 09:13:01 GMT) Full text and rfc822 format available.

Message #35 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon South <simon <at> simonsouth.net>
Cc: 51241 <at> debbugs.gnu.org
Subject: Re: bug#51241: [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Tue, 21 Dec 2021 10:12:33 +0100
Hi,

Simon South <simon <at> simonsouth.net> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>> Could you check whether this is still needed on current master,
>> ca. 9b38d9b3b34edb55f7f42b72a611b39e5164cf9f?
>
> Unfortunately yes; Knot is still failing two "yparser" tests in master
> (2c469f04a3be) on AArch64.
>
>> ‘guix refresh -l ragel’ reports 5K dependents, so we’d need to apply the
>> patch conditionally for aarch64 in a phase, or something along these
>> lines.
>
> I can submit a new patch with this change.  Or would it make more sense
> to apply the existing patch to the version-1.4.0 branch, since it's
> fixing an issue in master?

Let’s apply a patch that minimizes rebuilds on ‘master’ and we’ll
cherry-pick in ‘version-1.4.0’.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Wed, 29 Dec 2021 17:47:02 GMT) Full text and rfc822 format available.

Message #38 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: 51241 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: Re: bug#51241: [PATCH 0/1] gnu: ragel: Fix build of knot on
 aarch64-linux.
Date: Wed, 29 Dec 2021 12:46:06 -0500
Ludovic Courtès <ludo <at> gnu.org> writes:
> Let’s apply a patch that minimizes rebuilds on ‘master’ and we’ll
> cherry-pick in ‘version-1.4.0’.

Here's an updated patch that should do the trick, tested on AArch64 and on
x86-64 (where it has no effect).

Note I've shortened the name of the patch file in addition to modifying the
commit message from the original.


Simon South (1):
  gnu: ragel: Fix build of knot on aarch64-linux.

 gnu/local.mk                                  |  1 +
 .../patches/ragel-char-signedness.patch       | 42 +++++++++++++++++++
 gnu/packages/ragel.scm                        | 29 ++++++++++++-
 3 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-char-signedness.patch


base-commit: 2be274915023cdc0f4b0f4a5ab3690f53c2156c4
-- 
2.34.0





Information forwarded to guix-patches <at> gnu.org:
bug#51241; Package guix-patches. (Wed, 29 Dec 2021 17:47:02 GMT) Full text and rfc822 format available.

Message #41 received at 51241 <at> debbugs.gnu.org (full text, mbox):

From: Simon South <simon <at> simonsouth.net>
To: 51241 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org
Subject: [PATCH 1/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Wed, 29 Dec 2021 12:46:07 -0500
Apply a patch backported from Ragel's "ragel-6" branch that allows it to
reliably generate usable code on aarch64-linux where the C/C++ "char" type is
unsigned by default, fixing the build of Knot on this platform.

* gnu/packages/patches/ragel-char-signedness.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/ragel.scm (ragel)[arguments]: Add custom phase for AArch64 that
applies the patch.
[native-inputs]: Add "patch" and patch file on AArch64.
---
 gnu/local.mk                                  |  1 +
 .../patches/ragel-char-signedness.patch       | 42 +++++++++++++++++++
 gnu/packages/ragel.scm                        | 29 ++++++++++++-
 3 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/ragel-char-signedness.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 21e536a635..ebc5426e81 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1726,6 +1726,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/qtwebkit-fix-building-with-python-3.9.patch	\
   %D%/packages/patches/qtwebkit-fix-building-with-icu-68.patch	\
   %D%/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch	\
+  %D%/packages/patches/ragel-char-signedness.patch		\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/range-v3-build-with-gcc10.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
diff --git a/gnu/packages/patches/ragel-char-signedness.patch b/gnu/packages/patches/ragel-char-signedness.patch
new file mode 100644
index 0000000000..b3b2bf958a
--- /dev/null
+++ b/gnu/packages/patches/ragel-char-signedness.patch
@@ -0,0 +1,42 @@
+From 2e638fccd81e96ce09841adc4b295b5ce694ea73 Mon Sep 17 00:00:00 2001
+From: Adrian Thurston <thurston <at> colm.net>
+Date: Sat, 6 Nov 2021 12:20:05 -0700
+Subject: [PATCH] C char type: decide signedness of char based on CHAR_MIN
+
+Previously had char fixed to signed char, this is not useful on ARM as it does
+not align with the host type. Instead, decide at runtime (or probably compile
+time) if char is signed or not.
+---
+ ragel/common.cpp | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/ragel/common.cpp b/ragel/common.cpp
+index 8e9f8ed0..55875c06 100644
+--- a/ragel/common.cpp
++++ b/ragel/common.cpp
+@@ -27,14 +27,14 @@
+ 
+ HostType hostTypesC[] =
+ {
+-	{ "char",     0,       "char",    true,   true,  false,  CHAR_MIN,  CHAR_MAX,   0, 0,              sizeof(char) },
+-	{ "unsigned", "char",  "uchar",   false,  true,  false,  0, 0,                  0,     UCHAR_MAX,  sizeof(unsigned char) },
+-	{ "short",    0,       "short",   true,   true,  false,  SHRT_MIN,  SHRT_MAX,   0, 0,              sizeof(short) },
+-	{ "unsigned", "short", "ushort",  false,  true,  false,  0, 0,                  0,     USHRT_MAX,  sizeof(unsigned short) },
+-	{ "int",      0,       "int",     true,   true,  false,  INT_MIN,   INT_MAX,    0, 0,              sizeof(int) },
+-	{ "unsigned", "int",   "uint",    false,  true,  false,  0, 0,                  0,     UINT_MAX,   sizeof(unsigned int) },
+-	{ "long",     0,       "long",    true,   true,  false,  LONG_MIN,  LONG_MAX,   0, 0,              sizeof(long) },
+-	{ "unsigned", "long",  "ulong",   false,  true,  false,  0, 0,                  0,     ULONG_MAX,  sizeof(unsigned long) }
++	{ "char",     0,       "char",    (CHAR_MIN != 0), true,  false,  SCHAR_MIN, SCHAR_MAX,  0, UCHAR_MAX, sizeof(char) },
++	{ "unsigned", "char",  "uchar",   false,           true,  false,  0, 0,                  0, UCHAR_MAX, sizeof(unsigned char) },
++	{ "short",    0,       "short",   true,            true,  false,  SHRT_MIN,  SHRT_MAX,   0, 0,         sizeof(short) },
++	{ "unsigned", "short", "ushort",  false,           true,  false,  0, 0,                  0, USHRT_MAX, sizeof(unsigned short) },
++	{ "int",      0,       "int",     true,            true,  false,  INT_MIN,   INT_MAX,    0, 0,         sizeof(int) },
++	{ "unsigned", "int",   "uint",    false,           true,  false,  0, 0,                  0, UINT_MAX,  sizeof(unsigned int) },
++	{ "long",     0,       "long",    true,            true,  false,  LONG_MIN,  LONG_MAX,   0, 0,         sizeof(long) },
++	{ "unsigned", "long",  "ulong",   false,           true,  false,  0, 0,                  0, ULONG_MAX, sizeof(unsigned long) }
+ };
+ 
+ #define S8BIT_MIN  -128
+-- 
+2.33.1
+
diff --git a/gnu/packages/ragel.scm b/gnu/packages/ragel.scm
index 1d9b67a6e0..d4016ed5ba 100644
--- a/gnu/packages/ragel.scm
+++ b/gnu/packages/ragel.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2021 Simon South <simon <at> simonsouth.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,7 +23,9 @@ (define-module (gnu packages ragel)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
-  #:use-module (gnu packages))
+  #:use-module (guix utils)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base))
 
 (define-public ragel
   (package
@@ -36,6 +39,30 @@ (define-public ragel
                (base32
                 "0gvcsl62gh6sg73nwaxav4a5ja23zcnyxncdcdnqa2yjcpdnw5az"))))
     (build-system gnu-build-system)
+    (arguments
+     (if (target-aarch64?)
+         '(#:phases
+           (modify-phases %standard-phases
+             (add-after 'unpack 'apply-char-signedness-fix
+               ;; Apply a backported fix for aarch64-linux, where the C/C++
+               ;; "char" type is unsigned by default.
+               ;;
+               ;; The patch is applied in this custom phase and not via the
+               ;; "origin" object above to avoid rebuilding a large number of
+               ;; packages on other platforms.
+               (lambda _
+                 (let ((patch
+                        (search-input-file %build-inputs "/bin/patch"))
+                       (char-signedness-patch
+                        (assoc-ref %build-inputs "char-signedness-patch")))
+                   (invoke patch "-p1" "-i" char-signedness-patch))))))
+         '()))
+    (native-inputs
+     (if (target-aarch64?)
+         `(("char-signedness-patch"
+            ,(search-patch "ragel-char-signedness.patch"))
+           ("patch" ,patch))
+         '()))
     (home-page "https://www.colm.net/open-source/ragel/")
     (synopsis "State machine compiler")
     (description
-- 
2.34.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 31 Dec 2021 17:30:03 GMT) Full text and rfc822 format available.

Notification sent to Simon South <simon <at> simonsouth.net>:
bug acknowledged by developer. (Fri, 31 Dec 2021 17:30:03 GMT) Full text and rfc822 format available.

Message #46 received at 51241-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon South <simon <at> simonsouth.net>
Cc: 51241-done <at> debbugs.gnu.org
Subject: Re: [PATCH 1/1] gnu: ragel: Fix build of knot on aarch64-linux.
Date: Fri, 31 Dec 2021 18:29:50 +0100
Hi,

Simon South <simon <at> simonsouth.net> skribis:

> Apply a patch backported from Ragel's "ragel-6" branch that allows it to
> reliably generate usable code on aarch64-linux where the C/C++ "char" type is
> unsigned by default, fixing the build of Knot on this platform.
>
> * gnu/packages/patches/ragel-char-signedness.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/ragel.scm (ragel)[arguments]: Add custom phase for AArch64 that
> applies the patch.
> [native-inputs]: Add "patch" and patch file on AArch64.

Applied, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Jan 2022 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.