commit:     7d9a1b2df949a03883e81d47bda176054480b14a
Author:     Jonas Frei <freijon <AT> pm <DOT> me>
AuthorDate: Mon Nov 13 05:33:31 2023 +0000
Commit:     Jonas Frei <freijon <AT> pm <DOT> me>
CommitDate: Mon Nov 13 05:35:14 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=7d9a1b2d

games-engines/fs2_open: Added patch to respect -O flags, fixes 887671

This new patch is to be removed on the next release, it was implemented
upstream.

Closes: https://bugs.gentoo.org/887671
Signed-off-by: Jonas Frei <freijon <AT> pm.me>

 .../fs2_open-23.2.1-dont-ignore-user-cflags.patch  | 117 +++++++++++++++++++++
 ...pen-23.2.1.ebuild => fs2_open-23.2.1-r1.ebuild} |   1 +
 2 files changed, 118 insertions(+)

diff --git 
a/games-engines/fs2_open/files/fs2_open-23.2.1-dont-ignore-user-cflags.patch 
b/games-engines/fs2_open/files/fs2_open-23.2.1-dont-ignore-user-cflags.patch
new file mode 100644
index 0000000000..c0f29d05f8
--- /dev/null
+++ b/games-engines/fs2_open/files/fs2_open-23.2.1-dont-ignore-user-cflags.patch
@@ -0,0 +1,117 @@
+From 3ebdc51c4814648c2171440484c2d429899d3ab4 Mon Sep 17 00:00:00 2001
+From: Jonas Frei <frei...@pm.me>
+Date: Tue, 7 Nov 2023 21:21:28 +0100
+Subject: [PATCH] Don't ignore user-set -O* flags
+
+---
+ cmake/toolchain-clang.cmake | 37 +++++++++++++++++++++++++++++--------
+ cmake/toolchain-gcc.cmake   | 34 ++++++++++++++++++++++++++++------
+ 2 files changed, 57 insertions(+), 14 deletions(-)
+
+--- a/cmake/toolchain-clang.cmake
++++ b/cmake/toolchain-clang.cmake
+@@ -83,20 +83,41 @@ if(SUPPORTS_SHIFT_NEGATIVE_VALUE)
+       set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-shift-negative-value")
+ endif()
+ 
+-set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable -Wno-unused-parameter")
++# Check if there is a user-set optimisation flag
++string(REGEX MATCH "-O[a-zA-Z|0-9]+" CXX_OPT_FLAG ${CXX_BASE_FLAGS})
++string(REGEX MATCH "-O[a-zA-Z|0-9]+" C_OPT_FLAG ${C_BASE_FLAGS})
++
++# If no user-set opt flag, set -O2 and -Og
++if ("${CXX_OPT_FLAG}" STREQUAL "")
++      set(CXX_OPT_FLAG_RELEASE "-O2")
++      set(CXX_OPT_FLAG_DEBUG "-Og")
++else()
++      set(CXX_OPT_FLAG_RELEASE "${CXX_OPT_FLAG}")
++      set(CXX_OPT_FLAG_DEBUG "${CXX_OPT_FLAG}")
++endif()
++if ("${C_OPT_FLAG}" STREQUAL "")
++      set(C_OPT_FLAG_RELEASE "-O2")
++      set(C_OPT_FLAG_DEBUG "-Og")
++else()
++      set(C_OPT_FLAG_RELEASE "${C_OPT_FLAG}")
++      set(C_OPT_FLAG_DEBUG "${C_OPT_FLAG}")
++endif()
+ 
+-set(COMPILER_FLAGS_DEBUG "-Og -g -Wshadow")
++set(CXX_FLAGS_RELEASE "${CXX_OPT_FLAG_RELEASE} -Wno-unused-variable 
-Wno-unused-parameter")
++set(C_FLAGS_RELEASE "${C_OPT_FLAG_RELEASE} -Wno-unused-variable 
-Wno-unused-parameter")
+ 
+-# Always use the base flags and add our compiler flags at the bacl
++set(CXX_FLAGS_DEBUG "${CXX_OPT_FLAG_DEBUG} -g -Wshadow")
++set(C_FLAGS_DEBUG "${C_OPT_FLAG_DEBUG} -g -Wshadow")
++
++# Always use the base flags and add our compiler flags at the back
+ set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
+ set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
+ 
+-set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
+-set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
+-
+-set(CMAKE_CXX_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
+-set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
++set(CMAKE_CXX_FLAGS_RELEASE ${CXX_FLAGS_RELEASE})
++set(CMAKE_C_FLAGS_RELEASE ${C_FLAGS_RELEASE})
+ 
++set(CMAKE_CXX_FLAGS_DEBUG ${CXX_FLAGS_DEBUG})
++set(CMAKE_C_FLAGS_DEBUG ${C_FLAGS_DEBUG})
+ 
+ set(CMAKE_EXE_LINKER_FLAGS "")
+ 
+diff --git a/cmake/toolchain-gcc.cmake b/cmake/toolchain-gcc.cmake
+index ca740832e..78577038c 100644
+--- a/cmake/toolchain-gcc.cmake
++++ b/cmake/toolchain-gcc.cmake
+@@ -113,19 +113,41 @@ if(SUPPORTS_STRINGOP_TRUNCATION)
+       set(COMPILER_FLAGS "${COMPILER_FLAGS} -Wno-stringop-overflow")
+ endif()
+ 
+-set(COMPILER_FLAGS_RELEASE "-O2 -Wno-unused-variable 
-Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered  
-Wno-unused-parameter")
++# Check if there is a user-set optimisation flag
++string(REGEX MATCH "-O[a-zA-Z|0-9]+" CXX_OPT_FLAG ${CXX_BASE_FLAGS})
++string(REGEX MATCH "-O[a-zA-Z|0-9]+" C_OPT_FLAG ${C_BASE_FLAGS})
+ 
+-set(COMPILER_FLAGS_DEBUG "-Og -g -Wshadow")
++# If no user-set opt flag, set -O2 and -Og
++if ("${CXX_OPT_FLAG}" STREQUAL "")
++      set(CXX_OPT_FLAG_RELEASE "-O2")
++      set(CXX_OPT_FLAG_DEBUG "-Og")
++else()
++      set(CXX_OPT_FLAG_RELEASE "${CXX_OPT_FLAG}")
++      set(CXX_OPT_FLAG_DEBUG "${CXX_OPT_FLAG}")
++endif()
++if ("${C_OPT_FLAG}" STREQUAL "")
++      set(C_OPT_FLAG_RELEASE "-O2")
++      set(C_OPT_FLAG_DEBUG "-Og")
++else()
++      set(C_OPT_FLAG_RELEASE "${C_OPT_FLAG}")
++      set(C_OPT_FLAG_DEBUG "${C_OPT_FLAG}")
++endif()
++
++set(CXX_FLAGS_RELEASE "${CXX_OPT_FLAG_RELEASE} -Wno-unused-variable 
-Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered 
-Wno-unused-parameter")
++set(C_FLAGS_RELEASE "${C_OPT_FLAG_RELEASE} -Wno-unused-variable 
-Wno-unused-but-set-variable -Wno-array-bounds -Wno-empty-body -Wno-clobbered 
-Wno-unused-parameter")
++
++set(CXX_FLAGS_DEBUG "${CXX_OPT_FLAG_DEBUG} -g -Wshadow")
++set(C_FLAGS_DEBUG "${C_OPT_FLAG_DEBUG} -g -Wshadow")
+ 
+ # Always use the base flags and add our compiler flags at the back
+ set(CMAKE_CXX_FLAGS "${CXX_BASE_FLAGS} ${COMPILER_FLAGS}")
+ set(CMAKE_C_FLAGS "${C_BASE_FLAGS} ${COMPILER_FLAGS}")
+ 
+-set(CMAKE_CXX_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
+-set(CMAKE_C_FLAGS_RELEASE ${COMPILER_FLAGS_RELEASE})
++set(CMAKE_CXX_FLAGS_RELEASE ${CXX_FLAGS_RELEASE})
++set(CMAKE_C_FLAGS_RELEASE ${C_FLAGS_RELEASE})
+ 
+-set(CMAKE_CXX_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
+-set(CMAKE_C_FLAGS_DEBUG ${COMPILER_FLAGS_DEBUG})
++set(CMAKE_CXX_FLAGS_DEBUG ${CXX_FLAGS_DEBUG})
++set(CMAKE_C_FLAGS_DEBUG ${C_FLAGS_DEBUG})
+ 
+ set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}")
+ 
+-- 
+2.41.0
+

diff --git a/games-engines/fs2_open/fs2_open-23.2.1.ebuild 
b/games-engines/fs2_open/fs2_open-23.2.1-r1.ebuild
similarity index 98%
rename from games-engines/fs2_open/fs2_open-23.2.1.ebuild
rename to games-engines/fs2_open/fs2_open-23.2.1-r1.ebuild
index 8c63d4680d..aa639f9588 100644
--- a/games-engines/fs2_open/fs2_open-23.2.1.ebuild
+++ b/games-engines/fs2_open/fs2_open-23.2.1-r1.ebuild
@@ -48,6 +48,7 @@ BDEPEND="
 "
 PATCHES=(
        "${FILESDIR}/${P}-dont-build-lz4.patch"
+       "${FILESDIR}/${P}-dont-ignore-user-cflags.patch"
        "${FILESDIR}/${P}-make-arch-independent.patch"
 )
 

Reply via email to