[bug#39675] fix Desmume on newer GCC
diff mbox series

Message ID 1582363891.3461.0@riseup.net
State Accepted
Headers show
Series
  • [bug#39675] fix Desmume on newer GCC
Related show

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

raingloom Feb. 22, 2020, 9:31 a.m. UTC
Ah, I forgot to leave a blank line in the commit message.

Here is a patch for the current master as of a few minutes ago.

On Thu, Feb 20, 2020 at 17:04, Jakub Kądziołka <kuba@kadziolka.net> 
wrote:
> On Wed, Feb 19, 2020 at 02:41:21PM +0100, raingloom wrote:
>>  The project has not seen much development in some time, so it 
>> needed a few
>>  patches. I found them in the Arch package, but they seem to be from 
>> the
>>  upstream SourceForge project and mailing list.
>> 
> 
> Hi,
> 
> the bullet points in your commit message are at the end of the lines 
> for
> some reason. Also, the added .patch files don't apply when I `guix 
> build
> desmume'. I think you'll need to resend the patch. Also, when you add
> .patch files, you need to add them to a list in gnu/local.mk.
> 
> Regards,
> Jakub Kądziołka

Comments

Jakub Kądziołka Feb. 22, 2020, 3:39 p.m. UTC | #1
On Sat, Feb 22, 2020 at 10:31:31AM +0100, raingloom wrote:
> Ah, I forgot to leave a blank line in the commit message.
> 
> Here is a patch for the current master as of a few minutes ago.

Something is still off:

patching file src/MMU_timing.h
Hunk #1 FAILED at 155 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file src/MMU_timing.h.rej
patching file src/ctrlssdl.cpp
patching file src/wifi.cpp
Hunk #1 succeeded at 314 (offset -6 lines).
source is under 'desmume-0.9.11'
applying '/gnu/store/yc9991nl8vgkyszbb77ywr9idikyi5lj-desmume-gcc6-fixes.patch'...
Backtrace:
           3 (primitive-load "/gnu/store/zxjsjnfbzqqz2zgks5xgkh63m30…")
In ice-9/eval.scm:
    619:8  2 (_ #(#<directory (guile-user) 7ffff5c70140> "desmume-…"))
In srfi/srfi-1.scm:
    640:9  1 (for-each #<procedure apply-patch (a)> ("/gnu/store/…" …))
In guix/build/utils.scm:
    652:6  0 (invoke _ . _)

guix/build/utils.scm:652:6: In procedure invoke:
Throw to key `srfi-34' with args `(#<condition &invoke-error [program: "/gnu/store/v76scv4n63ip08g119rczh2mrw31zwpd-patch-2.7.6/bin/patch" arguments: ("--force" "--no-backup-if-mismatch" "-p1" "--input" "/gnu/store/yc9991nl8vgkyszbb77ywr9idikyi5lj-desmume-gcc6-fixes.patch") exit-status: 1 term-signal: #f stop-signal: #f] 7ffff6022d00>)'.

`file src/MMU_timing.h` in the build directory suggests that the header
file is shipped with CRLF line endings. Could `git format-patch` be
converting \r\n in your files into plain \n?

I tried to work around this with some combinations of
(origin (patch-flags '("--ignore-whitespace" "-p1"))), but no results.
raingloom Feb. 22, 2020, 11:19 p.m. UTC | #2
It could for all I know. What if you just pulled it from my gitlab?

https://gitlab.com/raingloom/guix-source/-/tree/raingloom/desmume

I have no idea how to preserve mixed line endings in git format-patch 
and the docs didn't help.

On Sat, Feb 22, 2020 at 16:39, Jakub Kądziołka <kuba@kadziolka.net> 
wrote:
> On Sat, Feb 22, 2020 at 10:31:31AM +0100, raingloom wrote:
>>  Ah, I forgot to leave a blank line in the commit message.
>> 
>>  Here is a patch for the current master as of a few minutes ago.
> 
> Something is still off:
> 
> patching file src/MMU_timing.h
> Hunk #1 FAILED at 155 (different line endings).
> 1 out of 1 hunk FAILED -- saving rejects to file src/MMU_timing.h.rej
> patching file src/ctrlssdl.cpp
> patching file src/wifi.cpp
> Hunk #1 succeeded at 314 (offset -6 lines).
> source is under 'desmume-0.9.11'
> applying 
> '/gnu/store/yc9991nl8vgkyszbb77ywr9idikyi5lj-desmume-gcc6-fixes.patch'...
> Backtrace:
>            3 (primitive-load 
> "/gnu/store/zxjsjnfbzqqz2zgks5xgkh63m30…")
> In ice-9/eval.scm:
>     619:8  2 (_ #(#<directory (guile-user) 7ffff5c70140> 
> "desmume-…"))
> In srfi/srfi-1.scm:
>     640:9  1 (for-each #<procedure apply-patch (a)> ("/gnu/store/…" 
> …))
> In guix/build/utils.scm:
>     652:6  0 (invoke _ . _)
> 
> guix/build/utils.scm:652:6: In procedure invoke:
> Throw to key `srfi-34' with args `(#<condition &invoke-error 
> [program: 
> "/gnu/store/v76scv4n63ip08g119rczh2mrw31zwpd-patch-2.7.6/bin/patch" 
> arguments: ("--force" "--no-backup-if-mismatch" "-p1" "--input" 
> "/gnu/store/yc9991nl8vgkyszbb77ywr9idikyi5lj-desmume-gcc6-fixes.patch") 
> exit-status: 1 term-signal: #f stop-signal: #f] 7ffff6022d00>)'.
> 
> `file src/MMU_timing.h` in the build directory suggests that the 
> header
> file is shipped with CRLF line endings. Could `git format-patch` be
> converting \r\n in your files into plain \n?
> 
> I tried to work around this with some combinations of
> (origin (patch-flags '("--ignore-whitespace" "-p1"))), but no results.

Patch
diff mbox series

From 5fd558ad04249d6214fdbf12f376962f65af1a9e Mon Sep 17 00:00:00 2001
From: raingloom <raingloom@protonmail.com>
Date: Wed, 19 Feb 2020 14:36:26 +0100
Subject: [PATCH] gnu: desmume: fix build on new GCC versions

* gnu/packages/emulation.scm (desmume) add patches
* gnu/packages/patches/desmume-gcc6-fixes.patch: new file
* gnu/packages/patches/desmume-gcc7-fixes.patch: new file
---
 gnu/packages/emulators.scm                    |  4 +-
 gnu/packages/patches/desmume-gcc6-fixes.patch | 59 +++++++++++++++++++
 gnu/packages/patches/desmume-gcc7-fixes.patch | 18 ++++++
 3 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/desmume-gcc6-fixes.patch
 create mode 100644 gnu/packages/patches/desmume-gcc7-fixes.patch

diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index b7f29a6f5b..aec4ce73ba 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -102,7 +102,9 @@ 
              version "/desmume-" version ".tar.gz"))
        (sha256
         (base32
-         "15l8wdw3q61fniy3h93d84dnm6s4pyadvh95a0j6d580rjk4pcrs"))))
+         "15l8wdw3q61fniy3h93d84dnm6s4pyadvh95a0j6d580rjk4pcrs"))
+       (patches (search-patches "desmume-gcc6-fixes.patch"
+                                "desmume-gcc7-fixes.patch"))))
     (build-system gnu-build-system)
     (arguments
      ;; Enable support for WiFi and microphone.
diff --git a/gnu/packages/patches/desmume-gcc6-fixes.patch b/gnu/packages/patches/desmume-gcc6-fixes.patch
new file mode 100644
index 0000000000..6eb9576f64
--- /dev/null
+++ b/gnu/packages/patches/desmume-gcc6-fixes.patch
@@ -0,0 +1,59 @@ 
+From: zeromus
+Origin: upstream, https://sourceforge.net/p/desmume/code/5514, https://sourceforge.net/p/desmume/code/5517, https://sourceforge.net/p/desmume/code/5430
+Subject: fix GCC6 issues
+Bug: https://sourceforge.net/p/desmume/bugs/1570/
+Bug-Debian: http://bugs.debian.org/811691
+
+Index: desmume/src/MMU_timing.h
+===================================================================
+--- desmume/src/MMU_timing.h	(revision 5513)
++++ desmume/src/MMU_timing.h	(revision 5517)
+@@ -155,8 +155,8 @@
+ 	enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };
+ 	enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };
+ 	enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };
+-	enum { TAGMASK = (u32)(~0 << TAGSHIFT) };
+-	enum { BLOCKMASK = ((u32)~0 >> (32 - TAGSHIFT)) & (u32)(~0 << BLOCKSIZESHIFT) };
++	enum { TAGMASK = (u32)(~0U << TAGSHIFT) };
++	enum { BLOCKMASK = ((u32)~0U >> (32 - TAGSHIFT)) & (u32)(~0U << BLOCKSIZESHIFT) };
+ 	enum { WORDSIZE = sizeof(u32) };
+ 	enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };
+ 	enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };
+Index: desmume/src/ctrlssdl.cpp
+===================================================================
+--- desmume/src/ctrlssdl.cpp	(revision 5513)
++++ desmume/src/ctrlssdl.cpp	(revision 5517)
+@@ -200,7 +200,7 @@
+           break;
+         case SDL_JOYAXISMOTION:
+           /* Dead zone of 50% */
+-          if( (abs(event.jaxis.value) >> 14) != 0 )
++          if( ((u32)abs(event.jaxis.value) >> 14) != 0 )
+             {
+               key = ((event.jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event.jaxis.axis & 127) << 1);
+               if (event.jaxis.value > 0) {
+@@ -370,7 +370,7 @@
+          Note: button constants have a 1bit offset. */
+     case SDL_JOYAXISMOTION:
+       key_code = ((event->jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event->jaxis.axis & 127) << 1);
+-      if( (abs(event->jaxis.value) >> 14) != 0 )
++      if( ((u32)abs(event->jaxis.value) >> 14) != 0 )
+         {
+           if (event->jaxis.value > 0)
+             key_code |= 1;
+Index: desmume/src/wifi.cpp
+===================================================================
+--- desmume/src/wifi.cpp	(revision 5429)
++++ desmume/src/wifi.cpp	(revision 5430)
+@@ -320,9 +320,9 @@
+ 
+ #if (WIFI_LOGGING_LEVEL >= 1)
+ 	#if WIFI_LOG_USE_LOGC
+-		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__);
++		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: " __VA_ARGS__);
+ 	#else
+-		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: "__VA_ARGS__);
++		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: " __VA_ARGS__);
+ 	#endif
+ #else
+ #define WIFI_LOG(level, ...) {}
diff --git a/gnu/packages/patches/desmume-gcc7-fixes.patch b/gnu/packages/patches/desmume-gcc7-fixes.patch
new file mode 100644
index 0000000000..a4934ff6e6
--- /dev/null
+++ b/gnu/packages/patches/desmume-gcc7-fixes.patch
@@ -0,0 +1,18 @@ 
+From e1f7039f1b06add4fb75b2f8774000b8f05574af Mon Sep 17 00:00:00 2001
+From: rogerman <rogerman@users.sf.net>
+Date: Mon, 17 Aug 2015 21:15:04 +0000
+Subject: Fix bug with libfat string handling.
+
+diff --git a/src/utils/libfat/directory.cpp b/src/utils/libfat/directory.cpp
+index 765d7ae5..b6d7f01f 100644
+--- a/src/utils/libfat/directory.cpp
++++ b/src/utils/libfat/directory.cpp
+@@ -139,7 +139,7 @@ static size_t _FAT_directory_mbstoucs2 (ucs2_t* dst, const char* src, size_t len
+ 	int bytes;
+ 	size_t count = 0;
+ 
+-	while (count < len-1 && src != '\0') {
++	while (count < len-1 && *src != '\0') {
+ 		bytes = mbrtowc (&tempChar, src, MB_CUR_MAX, &ps);
+ 		if (bytes > 0) {
+ 			*dst = (ucs2_t)tempChar;
-- 
2.25.0