From 80475adabf6fb7625b0b955dc8c5eeb18006757d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= <gustaf@hanicef.me>
Date: Sat, 4 Nov 2023 11:48:20 +0100
Subject: [PATCH] Always apply -fwrapv on builds

---
 src/CMakeLists.txt         | 6 ++----
 src/Makefile               | 2 +-
 src/Makefile.d/detect.mk   | 3 +--
 src/Makefile.d/versions.mk | 4 ----
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5fbc7002ad..405fa95725 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -253,6 +253,7 @@ target_compile_options(SRB2SDL2 PRIVATE
 		-Winline
 		-Wformat-y2k
 		-Wformat-security
+		-fwrapv
 
 		$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
 			-Wno-div-by-zero
@@ -260,10 +261,6 @@ target_compile_options(SRB2SDL2 PRIVATE
 			-Wdisabled-optimization
 		>
 
-		$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,3.4.0>:
-			-fwrapv
-		>
-
 		$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.0.0>:
 			-Wold-style-definition
 			-Wmissing-field-initializers
@@ -326,6 +323,7 @@ target_compile_options(SRB2SDL2 PRIVATE
 		-Wno-error=non-literal-null-conversion
 		-Wno-error=constant-conversion
 		-Wno-error=unused-but-set-variable
+		-fwrapv
 	>
 
 	# C, MSVC
diff --git a/src/Makefile b/src/Makefile
index a0a18be769..b730cd0bb0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -164,7 +164,7 @@ sources:=
 makedir:=../make
 
 # -DCOMPVERSION: flag to use comptime.h
-opts:=-DCOMPVERSION -g
+opts:=-DCOMPVERSION -g -fwrapv
 libs:=
 
 # This is a list of variables names, of which if defined,
diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk
index 3d9fc27661..9e27369462 100644
--- a/src/Makefile.d/detect.mk
+++ b/src/Makefile.d/detect.mk
@@ -65,8 +65,7 @@ gcc_versions:=\
 	75 74 73 72 71 70\
 	64 63 62 61 60\
 	55 54 53 52 51 50\
-	49 48 47 46 45 44 43 42 41 40\
-	34
+	49 48 47 46 45 44 43 42 41 40
 
 latest_gcc_version:=13.2
 
diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk
index 40ccd9f261..d2877b3743 100644
--- a/src/Makefile.d/versions.mk
+++ b/src/Makefile.d/versions.mk
@@ -160,10 +160,6 @@ opts+=-O0
 endif
 endif
 
-ifdef GCC34
-opts+=-fwrapv
-endif
-
 ifdef VALGRIND
 ifdef GCC46
 WFLAGS+=-Wno-error=unused-but-set-variable
-- 
GitLab