mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-28 00:12:44 +00:00
Add options for sanitizers to premake5.lua
Given that Valgrind is not yet avx512 ready [1] all the more reason to have easy access to ASAN and friends for compilers that support it. This commit adds options for ASAN, TSAN and UBSAN. [2] [1] https://bugs.kde.org/show_bug.cgi?id=383010 [2] https://github.com/google/sanitizers/wiki Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
@@ -4,6 +4,9 @@ newoption { category = "Pyrogenesis", trigger = "gles", description = "Use non-w
|
||||
newoption { category = "Pyrogenesis", trigger = "jenkins-tests", description = "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output" }
|
||||
newoption { category = "Pyrogenesis", trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" }
|
||||
newoption { category = "Pyrogenesis", trigger = "outpath", description = "Location for generated project files", default="../workspaces/default" }
|
||||
newoption { category = "Pyrogenesis", trigger = "sanitize-address", description = "Enable ASAN if available" }
|
||||
newoption { category = "Pyrogenesis", trigger = "sanitize-thread", description = "Enable TSAN if available" }
|
||||
newoption { category = "Pyrogenesis", trigger = "sanitize-undefined-behaviour", description = "Enable UBSAN if available" }
|
||||
newoption { category = "Pyrogenesis", trigger = "with-system-cxxtest", description = "Search standard paths for cxxtest, instead of using bundled copy" }
|
||||
newoption { category = "Pyrogenesis", trigger = "with-lto", description = "Enable Link Time Optimization (LTO)" }
|
||||
newoption { category = "Pyrogenesis", trigger = "with-system-mozjs", description = "Search standard paths for libmozjs115, instead of using bundled copy" }
|
||||
@@ -188,6 +191,19 @@ function project_set_build_flags()
|
||||
symbols "On"
|
||||
end
|
||||
|
||||
-- ASAN, TSAN, UBSAN
|
||||
local sanitizers = {}
|
||||
if _OPTIONS['sanitize-address'] then
|
||||
table.insert(sanitizers, 'Address')
|
||||
end
|
||||
if _OPTIONS['sanitize-thread'] then
|
||||
table.insert(sanitizers, 'Thread')
|
||||
end
|
||||
if _OPTIONS['sanitize-undefined-behaviour'] then
|
||||
table.insert(sanitizers, 'UndefinedBehavior')
|
||||
end
|
||||
sanitize(sanitizers)
|
||||
|
||||
if os.istarget("windows") or not _OPTIONS["minimal-flags"] then
|
||||
-- adds the -Wall compiler flag
|
||||
warnings "Extra"
|
||||
@@ -321,7 +337,9 @@ function project_set_build_flags()
|
||||
|
||||
if os.istarget("linux") or os.istarget("bsd") then
|
||||
buildoptions { "-fPIC" }
|
||||
linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed", "-Wl,-z,relro" }
|
||||
if next(sanitizers) == nil then
|
||||
linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed", "-Wl,-z,relro" }
|
||||
end
|
||||
end
|
||||
|
||||
if arch == "x86" then
|
||||
|
||||
Reference in New Issue
Block a user