$OpenBSD: patch-scripts_genie_lua,v 1.10 2019/09/07 07:02:29 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
@@ -853,17 +853,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
@@ -1077,54 +1079,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",
-				"-Wno-missing-braces", -- clang is not as permissive as GCC about std::array initialization
-				"-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
-		else
-			if (version < 50000) then
-				print("GCC version 5.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
-		end
 	end
 
 if (_OPTIONS["PLATFORM"]=="alpha") then
