summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-10-06 23:59:02 +0800
committerruki <[email protected]>2020-10-06 23:59:02 +0800
commit0e6d98d453674e52d676e80a3378e6e74b4250fa (patch)
tree8b229f400de2f4856d66a21fd31b1f4c7d21193f
parent17b71915bd116b542447a9243dd9210beff1ccab (diff)
add set_fpmodels
-rw-r--r--xmake/core/project/target.lua1
-rw-r--r--xmake/languages/c++/xmake.lua2
-rw-r--r--xmake/modules/core/tools/cl.lua13
-rw-r--r--xmake/modules/core/tools/clang.lua25
-rw-r--r--xmake/modules/core/tools/gcc.lua13
5 files changed, 54 insertions, 0 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index af62b667b..7f93eeb94 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1867,6 +1867,7 @@ function target.apis()
, "target.set_filename"
, "target.set_basename"
, "target.set_warnings"
+ , "target.set_fpmodels"
, "target.set_optimize"
, "target.set_languages"
, "target.set_toolchains"
diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua
index 3717f97bd..a7b73a677 100644
--- a/xmake/languages/c++/xmake.lua
+++ b/xmake/languages/c++/xmake.lua
@@ -58,6 +58,7 @@ language("c++")
, "config.frameworks"
, "target.symbols"
, "target.warnings"
+ , "target.fpmodels:check"
, "target.optimize:check"
, "target.vectorexts:check"
, "target.languages"
@@ -70,6 +71,7 @@ language("c++")
, "target.pcxxheader"
, "option.symbols"
, "option.warnings"
+ , "option.fpmodels:check"
, "option.optimize:check"
, "option.vectorexts:check"
, "option.languages"
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index eddd61720..4be07f30b 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -113,6 +113,19 @@ function nf_symbol(self, level, target)
return flags
end
+-- make the fp-model flag
+function nf_fpmodel(self, level)
+ local maps =
+ {
+ precise = "-fp:precise" -- default
+ , fast = "-fp:fast"
+ , strict = "-fp:strict"
+ , except = "-fp:except"
+ , noexcept = "-fp:except-"
+ }
+ return maps[level]
+end
+
-- make the warning flag
function nf_warning(self, level)
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 2be9803be..549bdaae1 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -71,6 +71,31 @@ function init(self)
end
+-- make the fp-model flag
+function nf_fpmodel(self, level)
+ local maps
+ if self:has_flags("-ffp-model=fast") then
+ maps =
+ {
+ precise = "-ffp-model=precise"
+ , fast = "-ffp-model=fast"
+ , strict = "-ffp-model=strict"
+ , except = "-ftrapping-math"
+ , noexcept = "-fno-trapping-math"
+ }
+ else
+ maps =
+ {
+ precise = "" -- default
+ , fast = "-ffast-math"
+ , strict = {"-frounding-math", "-ftrapping-math"}
+ , except = "-ftrapping-math"
+ , noexcept = "-fno-trapping-math"
+ }
+ end
+ return maps[level]
+end
+
-- make the optimize flag
function nf_optimize(self, level)
local maps =
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 22efda1fd..352153e57 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -117,6 +117,19 @@ function nf_warning(self, level)
return maps[level]
end
+-- make the fp-model flag
+function nf_fpmodel(self, level)
+ local maps =
+ {
+ precise = "" --default
+ , fast = "-ffast-math"
+ , strict = {"-frounding-math", "-ftrapping-math"}
+ , except = "-ftrapping-math"
+ , noexcept = "-fno-trapping-math"
+ }
+ return maps[level]
+end
+
-- make the optimize flag
function nf_optimize(self, level)
local maps =