commit:     5014c69d1924530bad1c0f3ab756e5d041f48008
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 28 19:00:00 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Sat Sep 28 19:03:37 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5014c69d

games-strategy/ufoai: Fix building with Clang

Closes: https://bugs.gentoo.org/895998
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 .../ufoai/files/ufoai-2.5.0_p20180603-flags.patch  | 54 ++++++++++++++
 .../files/ufoai-2.5.0_p20180603-no-register.patch  | 84 ++++++++++++++++++++++
 .../ufoai/ufoai-2.5.0_p20180603-r3.ebuild          |  2 +
 3 files changed, 140 insertions(+)

diff --git a/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-flags.patch 
b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-flags.patch
new file mode 100644
index 000000000000..3d28a5a997c9
--- /dev/null
+++ b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-flags.patch
@@ -0,0 +1,54 @@
+From a824da365964aa57dc7f735d1887be4a3c6c5b71 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <[email protected]>
+Date: Sat, 28 Sep 2024 19:24:35 +0100
+Subject: [PATCH] Clang doesn't support these flags
+
+---
+ build/modes/debug.mk   |  2 +-
+ build/modes/release.mk | 13 ++++++-------
+ 2 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/build/modes/debug.mk b/build/modes/debug.mk
+index 4b857dc576..1ded5e7ec7 100644
+--- a/build/modes/debug.mk
++++ b/build/modes/debug.mk
+@@ -6,7 +6,7 @@ endif
+ 
+ ifeq ($(SSE),1) # Not all -O options are working with sse
+   ifneq ($(filter -O2 -O3 -O4 -Ofast,$(CFLAGS)),)
+-    CFLAGS += -O1 -fthread-jumps -falign-functions -falign-jumps 
-falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-skip-blocks 
-fdelete-null-pointer-checks -fexpensive-optimizations -fgcse-lm 
-foptimize-sibling-calls -fpeephole2 -fregmove -freorder-blocks 
-freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec 
-fschedule-insns2 -fstrict-overflow -ftree-pre -ftree-vrp
++    CFLAGS += -O1 -falign-functions -fdelete-null-pointer-checks 
-foptimize-sibling-calls -fsched-interblock -fschedule-insns2 -fstrict-overflow
+   endif
+   ifneq ($(filter -O3 -O4 -Ofast,$(CFLAGS)),)
+     CFLAGS += -finline-functions -funswitch-loops -fpredictive-commoning 
-fgcse-after-reload -ftree-vectorize -fno-strict-aliasing
+diff --git a/build/modes/release.mk b/build/modes/release.mk
+index 81dc21e24e..e166d8e902 100644
+--- a/build/modes/release.mk
++++ b/build/modes/release.mk
+@@ -9,17 +9,16 @@ ifeq ($(TARGET_ARCH),i386)
+ endif
+ 
+ ifeq ($(TARGET_ARCH),x86_64)
+-  CFLAGS += -fexpensive-optimizations -fno-strict-aliasing
++  CFLAGS += -fno-strict-aliasing
+ endif
+ 
+ ifeq ($(SSE),1) # Not all -O options are working with sse
+   ifneq ($(filter -O2 -O3 -O4 -Ofast,$(CFLAGS)),)
+-    CFLAGS += -O1 -fthread-jumps -falign-functions -falign-jumps -falign-loops
+-    CFLAGS += -falign-labels -fcaller-saves -fcrossjumping -fcse-skip-blocks
+-    CFLAGS += -fdelete-null-pointer-checks -fexpensive-optimizations -fgcse-lm
+-    CFLAGS += -foptimize-sibling-calls -fpeephole2 -fregmove -freorder-blocks
+-    CFLAGS += -freorder-functions -frerun-cse-after-loop -fsched-interblock
+-    CFLAGS += -fsched-spec -fschedule-insns2 -fstrict-overflow -ftree-pre 
-ftree-vrp
++    CFLAGS += -O1 -falign-functions
++    CFLAGS += -fdelete-null-pointer-checks
++    CFLAGS += -foptimize-sibling-calls
++    CFLAGS += -fsched-interblock
++    CFLAGS += -fstrict-overflow
+   endif
+   ifneq ($(filter -O3 -O4 -Ofast,$(CFLAGS)),)
+     CFLAGS += -finline-functions -funswitch-loops -fpredictive-commoning
+-- 
+2.46.0
+

diff --git a/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-no-register.patch 
b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-no-register.patch
new file mode 100644
index 000000000000..66ba5b25eb84
--- /dev/null
+++ b/games-strategy/ufoai/files/ufoai-2.5.0_p20180603-no-register.patch
@@ -0,0 +1,84 @@
+From 829468a95ae1dca297765143b0a0aa73717e13d6 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <[email protected]>
+Date: Sat, 28 Sep 2024 19:53:59 +0100
+Subject: [PATCH] ISO C++17 does not allow 'register' storage class specifier
+
+---
+ src/client/renderer/r_font.cpp |  2 +-
+ src/common/md5.cpp             |  2 +-
+ src/shared/shared.cpp          | 12 ++++++------
+ 3 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/client/renderer/r_font.cpp b/src/client/renderer/r_font.cpp
+index abbe67e68e..53c69d6ee9 100644
+--- a/src/client/renderer/r_font.cpp
++++ b/src/client/renderer/r_font.cpp
+@@ -259,7 +259,7 @@ void R_FontListCache_f (void)
+  */
+ static int R_FontHash (const char* string, const font_t* font)
+ {
+-      register int hashValue, i;
++      int hashValue, i;
+ 
+       hashValue = 0x2040189 * ((font - fonts) + 1);
+       for (i = 0; string[i] != '\0'; i++)
+diff --git a/src/common/md5.cpp b/src/common/md5.cpp
+index e04b34b05c..46ba312f0d 100644
+--- a/src/common/md5.cpp
++++ b/src/common/md5.cpp
+@@ -78,7 +78,7 @@ static void MD5Init (struct MD5Context *ctx)
+  */
+ static void MD5Transform (uint32_t buf[4], uint32_t const in[16])
+ {
+-      register uint32_t a, b, c, d;
++      uint32_t a, b, c, d;
+ 
+       a = buf[0];
+       b = buf[1];
+diff --git a/src/shared/shared.cpp b/src/shared/shared.cpp
+index 07347378c4..0d4e27b556 100644
+--- a/src/shared/shared.cpp
++++ b/src/shared/shared.cpp
+@@ -105,8 +105,8 @@ char* Com_ConvertToASCII7 (char* s)
+  */
+ static int Com_FilterAfterStar (const char* pattern, const char* text)
+ {
+-      register const char* p = pattern, *t = text;
+-      register char c, c1;
++      const char* p = pattern, *t = text;
++      char c, c1;
+ 
+       while ((c = *p++) == '?' || c == '*')
+               if (c == '?' && *t++ == '\0')
+@@ -144,8 +144,8 @@ static int Com_FilterAfterStar (const char* pattern, const 
char* text)
+  */
+ int Com_Filter (const char* pattern, const char* text)
+ {
+-      register const char* p = pattern, *t = text;
+-      register char c;
++      const char* p = pattern, *t = text;
++      char c;
+ 
+       while ((c = *p++) != '\0')
+               switch (c) {
+@@ -166,7 +166,7 @@ int Com_Filter (const char* pattern, const char* text)
+ 
+               case '[':
+                       {
+-                              register char c1 = *t++;
++                              char c1 = *t++;
+                               int invert;
+ 
+                               if (!c1)
+@@ -178,7 +178,7 @@ int Com_Filter (const char* pattern, const char* text)
+ 
+                               c = *p++;
+                               while (1) {
+-                                      register char cstart = c, cend = c;
++                                      char cstart = c, cend = c;
+ 
+                                       if (c == '\\') {
+                                               cstart = *p++;
+-- 
+2.46.0
+

diff --git a/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild 
b/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild
index 4a608e33a4d1..855e93fe458b 100644
--- a/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild
+++ b/games-strategy/ufoai/ufoai-2.5.0_p20180603-r3.ebuild
@@ -62,6 +62,8 @@ DEPEND="
 PATCHES=(
        "${FILESDIR}"/${P}-install.patch
        "${FILESDIR}"/${P}-mxml4.patch
+       "${FILESDIR}"/${P}-flags.patch
+       "${FILESDIR}"/${P}-no-register.patch
 )
 
 src_unpack() {

Reply via email to