diff options
| author | ruki <[email protected]> | 2023-01-29 22:17:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-01-29 22:18:08 +0800 |
| commit | d6f64cf2a51e2225afd292167e2baba6250233d0 (patch) | |
| tree | c88e57ade26172da5371402572e717ce43e285ac | |
| parent | 0e533c28f85bf23b57a08709c9a845efad16ff45 (diff) | |
improve ldc
| -rw-r--r-- | xmake/modules/core/tools/dmd.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/core/tools/ldc2.lua | 29 | ||||
| -rw-r--r-- | xmake/rules/dlang/build_optimization/config.lua | 6 |
3 files changed, 33 insertions, 17 deletions
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index cb364c92c..9e3001aeb 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -73,10 +73,17 @@ end -- make the symbol flag function nf_symbol(self, level) - local maps = { - debug = "-g -debug" - } - return maps[level] + local kind = self:kind() + if language.sourcekinds()[kind] then + local maps = _g.symbol_maps + if not maps then + maps = { + debug = {"-g", "-debug"} + } + _g.symbol_maps = maps + end + return maps[level .. '_' .. kind] or maps[level] + end end -- make the warning flag diff --git a/xmake/modules/core/tools/ldc2.lua b/xmake/modules/core/tools/ldc2.lua index 86c821252..3a2dbf160 100644 --- a/xmake/modules/core/tools/ldc2.lua +++ b/xmake/modules/core/tools/ldc2.lua @@ -20,6 +20,7 @@ -- imports inherit("dmd") +import("core.language.language") -- init it function init(self) @@ -37,20 +38,28 @@ end -- make the optimize flag function nf_optimize(self, level) local maps = { - fast = "-O" - , faster = {"-O", "--release"} - , fastest = {"-O", "--release", "--boundscheck=off"} - , smallest = {"-O", "--release", "--boundscheck=off"} - , aggressive = {"-O", "--release", "--boundscheck=off"} + none = "--O0" + , fast = "--O1" + , faster = {"--O2", "--release"} + , fastest = {"--O3", "--release", "--boundscheck=off"} + , smallest = {"--Oz", "--release", "--boundscheck=off"} + , aggressive = {"--O4", "--release", "--boundscheck=off"} } return maps[level] end -- make the symbol flag function nf_symbol(self, level) - local maps = { - debug = "-g --d-debug" - } - return maps[level] + local kind = self:kind() + if language.sourcekinds()[kind] then + local maps = _g.symbol_maps + if not maps then + maps = { + debug = {"-g", "--d-debug"} + , hidden = "-fvisibility=hidden" + } + _g.symbol_maps = maps + end + return maps[level .. '_' .. kind] or maps[level] + end end - diff --git a/xmake/rules/dlang/build_optimization/config.lua b/xmake/rules/dlang/build_optimization/config.lua index 0df57179b..c79d9f062 100644 --- a/xmake/rules/dlang/build_optimization/config.lua +++ b/xmake/rules/dlang/build_optimization/config.lua @@ -26,9 +26,9 @@ import("core.project.project") function _add_lto_optimization(target) if target:has_tool("dc", "ldc2") and target:has_tool("dcld", "ldc2") then target:add("dcflags", "-flto=thin", {force = true}) - target:add("ldflags", "-flto=thin", {force = true}) - target:add("shflags", "-flto=thin", {force = true}) - -- to use the link-time optimizer, -flto and optimization options should be specified at compile time and during the final link. + target:add("ldflags", "-flto=thin", "-defaultlib=phobos2-ldc-lto,druntime-ldc-lto", {force = true}) + target:add("shflags", "-flto=thin", "-defaultlib=phobos2-ldc-lto,druntime-ldc-lto", {force = true}) + -- to use the link-time optimizer, lto and optimization options should be specified at compile time and during the final link. -- @see https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html local optimize = target:get("optimize") if optimize then |
