summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-07-31 22:45:10 +0800
committerruki <[email protected]>2020-07-31 22:45:10 +0800
commitc63545cbe59c57f370abd7c93f8977836f4f0e14 (patch)
tree1b45b8f94c7e2aa027cf1246b04b59cdf8294333
parentd120256e16d2f1ea1b610390dd0e34737f410b54 (diff)
strip codes for msvc
-rw-r--r--xmake/modules/core/tools/cl.lua2
-rw-r--r--xmake/modules/core/tools/clang.lua8
-rw-r--r--xmake/modules/core/tools/link.lua15
-rw-r--r--xmake/rules/utils/symbols/xmake.lua7
4 files changed, 20 insertions, 12 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 45a205f20..5d1b8f502 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -140,7 +140,7 @@ function nf_optimize(self, level)
none = "-Od"
, faster = "-O2"
, fastest = "-Ox -fp:fast"
- , smallest = "-O1 -GL" -- /GL and (/OPT:REF is on by default in linker)
+ , smallest = "-O1 -GL" -- /GL and (/OPT:REF is on by default in linker), we need enable /ltcg
, aggressive = "-Ox -fp:fast"
}
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 297ab700d..4551ea3a4 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -73,8 +73,6 @@ end
-- make the optimize flag
function nf_optimize(self, level)
-
- -- the maps
local maps =
{
none = "-O0"
@@ -84,15 +82,11 @@ function nf_optimize(self, level)
, smallest = "-Oz" -- smaller than -Os
, aggressive = "-Ofast"
}
-
- -- make it
return maps[level]
end
-- make the warning flag
function nf_warning(self, level)
-
- -- the maps
local maps =
{
none = "-w"
@@ -102,7 +96,5 @@ function nf_warning(self, level)
, everything = "-Weverything"
, error = "-Werror"
}
-
- -- make it
return maps[level]
end
diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua
index 10a242e6d..98dc98982 100644
--- a/xmake/modules/core/tools/link.lua
+++ b/xmake/modules/core/tools/link.lua
@@ -57,6 +57,19 @@ function get(self, name)
return values
end
+-- make the strip flag
+function nf_strip(self, level)
+ -- @note we explicitly strip some useless code, because `/debug` may keep them
+ -- @see https://github.com/xmake-io/xmake/issues/907
+ --
+ local maps =
+ {
+ debug = "/opt:ref /opt:icf"
+ , all = "/opt:ref /opt:icf /ltcg" -- we enable /ltcg for optimize/smallest:/Gl
+ }
+ return maps[level]
+end
+
-- make the symbol flag
function nf_symbol(self, level, target)
@@ -70,8 +83,6 @@ function nf_symbol(self, level, target)
flags = "-debug"
end
end
-
- -- none
return flags
end
diff --git a/xmake/rules/utils/symbols/xmake.lua b/xmake/rules/utils/symbols/xmake.lua
index 5277cd783..4f158862d 100644
--- a/xmake/rules/utils/symbols/xmake.lua
+++ b/xmake/rules/utils/symbols/xmake.lua
@@ -21,10 +21,15 @@
-- define rule: utils.symbols.extract
rule("utils.symbols.extract")
before_link(function(target)
+
+ -- imports
+ import("core.platform.platform")
+
-- need generate symbols?
local strip = target:get("strip")
local targetkind = target:targetkind()
- if target:get("symbols") == "debug" and (strip == "all" or strip == "debug") and (targetkind == "binary" or targetkind == "shared") then
+ if target:get("symbols") == "debug" and (strip == "all" or strip == "debug")
+ and (targetkind == "binary" or targetkind == "shared") and platform.tool("strip") then -- only for strip command
target:data_set("utils.symbols.extract", true)
target:set("strip", "none") -- disable strip in link stage, because we need to run separate strip commands
end