summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-07 16:52:46 +0800
committerruki <[email protected]>2015-06-07 16:53:46 +0800
commit6e928d29aa3e30b92b6ad5b51edc105ec90b39ad (patch)
tree6d281e0d421dfd65fc0958ec31ac58cf3f097e68 /xmake/scripts
parentf254d7f88fbbb159593cdfbadffe98498b14870c (diff)
add ftrapv and address sanitizer
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/platform/windows/tools/cl.lua4
-rw-r--r--xmake/scripts/platform/windows/tools/link.lua3
-rw-r--r--xmake/scripts/tools/clang.lua29
3 files changed, 36 insertions, 0 deletions
diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua
index 2a0833759..84b5b33ac 100644
--- a/xmake/scripts/platform/windows/tools/cl.lua
+++ b/xmake/scripts/platform/windows/tools/cl.lua
@@ -67,6 +67,10 @@ function cl.init(name)
-- language
, ["-ansi"] = ""
, ["-std=.*"] = ""
+
+ -- others
+ , ["-ftrapv"] = ""
+ , ["-fsanitize=address"] = ""
}
end
diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua
index 6b18a5e15..b550934c2 100644
--- a/xmake/scripts/platform/windows/tools/link.lua
+++ b/xmake/scripts/platform/windows/tools/link.lua
@@ -63,6 +63,9 @@ function link.init(name)
, ["-S"] = ""
, ["--strip-all"] = ""
, ["--strip-debug"] = ""
+
+ -- others
+ , ["-ftrapv"] = ""
}
end
diff --git a/xmake/scripts/tools/clang.lua b/xmake/scripts/tools/clang.lua
index b8c6cbdeb..5ee3171db 100644
--- a/xmake/scripts/tools/clang.lua
+++ b/xmake/scripts/tools/clang.lua
@@ -29,6 +29,27 @@ local config = require("base/config")
-- define module: clang
local clang = clang or {}
+-- check the given flag
+function clang._check(flag)
+
+ -- this flag has been checked?
+ clang._CHECK = clang._CHECK or {}
+ if clang._CHECK[flag] then
+ return clang._CHECK[flag]
+ end
+
+ -- check it
+ if 0 ~= os.execute(string.format("%s %s -S -o %s -xc %s > %s 2>&1", clang.name, flag, xmake._NULDEV, xmake._NULDEV, xmake._NULDEV)) then
+ flag = ""
+ end
+
+ -- save it
+ clang._CHECK[flag] = flag
+
+ -- ok?
+ return flag
+end
+
-- the init function
function clang.init(name)
@@ -74,6 +95,14 @@ function clang.init(name)
table.join2(clang.mxflags, "-Qunused-arguments")
end
+ -- init flags map
+ clang.mapflags =
+ {
+ -- others
+ ["-ftrapv"] = clang._check
+ , ["-fsanitize=address"] = clang._check
+ }
+
end
-- make the compile command