$OpenBSD: patch-scripts_genie_lua,v 1.15 2020/06/26 19:54:47 fcambus Exp $

- Set OPT_FLAGS even when OPTIMIZE is unset, to allow passing CXXFLAGS
- Remove broken GCC version detection

Index: scripts/genie.lua
--- scripts/genie.lua.orig
+++ scripts/genie.lua
@@ -835,17 +835,19 @@ if _OPTIONS["NOWERROR"]==nil then
 	}
 end
 
+-- add optional flags
+if _OPTIONS["OPT_FLAGS"] then
+	buildoptions {
+		_OPTIONS["OPT_FLAGS"]
+	}
+end
+
 -- if we are optimizing, include optimization options
 if _OPTIONS["OPTIMIZE"] then
 	buildoptions {
 		"-O".. _OPTIONS["OPTIMIZE"],
 		"-fno-strict-aliasing"
 	}
-	if _OPTIONS["OPT_FLAGS"] then
-		buildoptions {
-			_OPTIONS["OPT_FLAGS"]
-		}
-	end
 	if _OPTIONS["LTO"]=="1" then
 		buildoptions {
 -- windows native mingw GCC 5.2 fails with -flto=x with x > 1. bug unfixed as of this commit
@@ -1060,68 +1062,6 @@ end
 
 
 
-		local version = str_to_version(_OPTIONS["gcc_version"])
-		if string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "pnacl") or string.find(_OPTIONS["gcc"], "asmjs") or string.find(_OPTIONS["gcc"], "android") then
-			if (version < 30400) then
-				print("Clang version 3.4 or later needed")
-				os.exit(-1)
-			end
-			buildoptions {
-				"-Wno-cast-align",
-				"-Wno-tautological-compare",
-				"-Wno-unused-value",
-				"-Wno-constant-logical-operand",
-				"-fdiagnostics-show-note-include-stack",
-			}
-			if (version >= 30500) then
-				buildoptions {
-					"-Wno-unknown-warning-option",
-					"-Wno-extern-c-compat",
-					"-Wno-unknown-attributes",
-					"-Wno-ignored-qualifiers"
-				}
-			end
-			if (version >= 60000) then
-				buildoptions {
-					"-Wno-pragma-pack" -- clang 6.0 complains when the packing change lifetime is not contained within a header file.
-				}
-			end
-			if ((version < 60000) or (_OPTIONS["targetos"]=="macosx" and (version <= 90000))) then
-				buildoptions {
-					"-Wno-missing-braces" -- std::array brace initialization not fixed until 6.0.0 (https://reviews.llvm.org/rC314838)
-				}
-			end
-			if (_OPTIONS["targetos"]=="macosx" and (version < 80000)) then
-				defines {
-					"TARGET_OS_OSX=1",
-				}
-			end
-		else
-			if (version < 70000) then
-				print("GCC version 7.0 or later needed")
-				os.exit(-1)
-			end
-				buildoptions {
-					"-Wno-unused-result", -- needed for fgets,fread on linux
-					-- array bounds checking seems to be buggy in 4.8.1 (try it on video/stvvdp1.c and video/model1.c without -Wno-array-bounds)
-					"-Wno-array-bounds",
-				}
-			if (version >= 80000) then
-				buildoptions {
-					"-Wno-format-overflow", -- try machine/bfm_sc45_helper.cpp in GCC 8.0.1, among others
-					"-Wno-stringop-truncation", -- ImGui again
-					"-Wno-stringop-overflow",   -- formats/victor9k_dsk.cpp bugs the compiler
-				}
-				buildoptions_cpp {
-					"-Wno-class-memaccess", -- many instances in ImGui and BGFX
-				}
-			end
-			if (version >= 100000) then
-				buildoptions {
-					"-Wno-return-local-addr", -- sqlite3.c in GCC 10
-				}
-			end
-		end
 	end
 
 if (_OPTIONS["PLATFORM"]=="alpha") then
