From 1f2e6861e8160fa1584c67d6783b11b2dbd6c85e Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 27 Oct 2021 22:35:15 +0800 Subject: add symbols for masm --- xmake/modules/core/tools/ml.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 83da11fb6..e9154251d 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -20,6 +20,7 @@ -- imports import("private.tools.vstool") +import("core.base.hashset") -- init it -- @@ -57,6 +58,23 @@ function init(self) }) end +-- make the symbol flags +function nf_symbols(self, levels, target) + local flags = nil + local values = hashset.from(levels) + if values:has("debug") then + flags = {} + if values:has("edit") then + table.insert(flags, "-ZI") + elseif values:has("embed") then + table.insert(flags, "-Z7") + else + table.insert(flags, "-Zi") + end + end + return flags +end + -- make the warning flag function nf_warning(self, level) -- cgit v1.3.1 From 71217ef2ce95a70aad0fd1cad05eb462b4612a5b Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 27 Oct 2021 22:36:35 +0800 Subject: remove some comments --- xmake/modules/core/tools/dmd.lua | 8 -------- xmake/modules/core/tools/go.lua | 20 -------------------- xmake/modules/core/tools/ml.lua | 4 ---- xmake/modules/core/tools/rustc.lua | 16 ---------------- xmake/modules/core/tools/sdcc.lua | 14 -------------- xmake/modules/core/tools/zig.lua | 8 -------- 6 files changed, 70 deletions(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index 2a9d860e1..3f29da28f 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -146,11 +146,7 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end @@ -161,11 +157,7 @@ end -- compile the source file function compile(self, sourcefile, objectfile, dependinfo, flags) - - -- ensure the object directory os.mkdir(path.directory(objectfile)) - - -- compile it os.runv(compargv(self, sourcefile, objectfile, flags)) end diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua index fbd046cf0..34d096873 100644 --- a/xmake/modules/core/tools/go.lua +++ b/xmake/modules/core/tools/go.lua @@ -35,14 +35,10 @@ end -- make the optimize flag function nf_optimize(self, level) - - -- the maps local maps = { none = "-N" } - - -- make it return maps[level] end @@ -59,22 +55,16 @@ function nf_symbol(self, level, target, mapkind) { debug = "-E" } - - -- make it return maps[level] end -- make the strip flag function nf_strip(self, level) - - -- the maps local maps = { debug = "-s" , all = "-s" } - - -- make it return maps[level] end @@ -95,8 +85,6 @@ end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags) - - -- make it if targetkind == "static" then return self:program(), table.join("tool", "pack", flags, targetfile, objectfiles) else @@ -106,11 +94,7 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) os.runv(program, argv, {envs = self:runenvs()}) end @@ -122,11 +106,7 @@ end -- compile the source file function compile(self, sourcefiles, objectfile, dependinfo, flags) - - -- ensure the object directory os.mkdir(path.directory(objectfile)) - - -- compile it local program, argv = compargv(self, sourcefiles, objectfile, flags) os.runv(program, argv, {envs = self:runenvs()}) end diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index e9154251d..3550b1a32 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -77,8 +77,6 @@ end -- make the warning flag function nf_warning(self, level) - - -- the maps local maps = { none = "-w" @@ -88,8 +86,6 @@ function nf_warning(self, level) , everything = "-W3" , error = "-WX" } - - -- make it return maps[level] end diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua index ade2daea4..a30a389af 100644 --- a/xmake/modules/core/tools/rustc.lua +++ b/xmake/modules/core/tools/rustc.lua @@ -41,8 +41,6 @@ end -- make the optimize flag function nf_optimize(self, level) - - -- the maps local maps = { none = "-C opt-level=0" @@ -52,21 +50,15 @@ function nf_optimize(self, level) , smallest = "-C opt-level=s" , aggressive = "-C opt-level=z" } - - -- make it return maps[level] end -- make the symbol flag function nf_symbol(self, level) - - -- the maps local maps = { debug = "-C debuginfo=2" } - - -- make it return maps[level] end @@ -82,11 +74,7 @@ end -- build the target file function build(self, sourcefiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- build it os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags)) end @@ -97,11 +85,7 @@ end -- compile the source file function compile(self, sourcefiles, objectfile, dependinfo, flags) - - -- ensure the object directory os.mkdir(path.directory(objectfile)) - - -- compile it os.runv(compargv(self, sourcefiles, objectfile, flags)) end diff --git a/xmake/modules/core/tools/sdcc.lua b/xmake/modules/core/tools/sdcc.lua index 0153ed652..4605f12f8 100644 --- a/xmake/modules/core/tools/sdcc.lua +++ b/xmake/modules/core/tools/sdcc.lua @@ -68,23 +68,17 @@ end -- make the warning flag function nf_warning(self, level) - - -- the maps local maps = { none = "--less-pedantic" , less = "--less-pedantic" , error = "-Werror" } - - -- make it return maps[level] end -- make the optimize flag function nf_optimize(self, level) - - -- the maps local maps = { none = "" @@ -94,15 +88,11 @@ function nf_optimize(self, level) , smallest = "--opt-code-size" , aggressive = "--opt-code-speed" } - - -- make it return maps[level] end -- make the language flag function nf_language(self, stdname) - - -- the stdc maps if _g.cmaps == nil then _g.cmaps = { @@ -176,11 +166,7 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end diff --git a/xmake/modules/core/tools/zig.lua b/xmake/modules/core/tools/zig.lua index 140e1ae0a..f0d6c5d98 100644 --- a/xmake/modules/core/tools/zig.lua +++ b/xmake/modules/core/tools/zig.lua @@ -116,11 +116,7 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - - -- ensure the target directory os.mkdir(path.directory(targetfile)) - - -- link it os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end @@ -131,11 +127,7 @@ end -- compile the source file function compile(self, sourcefile, objectfile, dependinfo, flags) - - -- ensure the object directory os.mkdir(path.directory(objectfile)) - - -- compile it os.runv(compargv(self, sourcefile, objectfile, flags)) end -- cgit v1.3.1 From 020ec323df6377390fe144e8af78dd7cc741ec0b Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 28 Oct 2021 00:37:30 +0800 Subject: improve ml --- xmake/core/base/table.lua | 46 ++++++++++++++++++++++++++++++---------- xmake/core/tool/compiler.lua | 2 +- xmake/modules/core/tools/gcc.lua | 1 - xmake/modules/core/tools/ml.lua | 21 +++++++++++++----- 4 files changed, 52 insertions(+), 18 deletions(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 4f21ec358..21fa185a0 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -227,21 +227,45 @@ function table.is_dictionary(dict) return type(dict) == "table" and dict[1] == nil end --- does contain the given value in table? -function table.contains(t, value) +-- does contain the given values in table? +-- contains arg1 or arg2 ... +function table.contains(t, arg1, arg2, ...) local found = false - if table.is_array(t) then - for _, v in ipairs(t) do - if v == value then - found = true - break + if arg2 == nil then -- only one value + if table.is_array(t) then + for _, v in ipairs(t) do + if v == arg1 then + found = true + break + end + end + else + for _, v in pairs(t) do + if v == arg1 then + found = true + break + end end end else - for _, v in pairs(t) do - if v == value then - found = true - break + local values = {} + local args = table.pack(arg1, arg2, ...) + for _, arg in ipairs(args) do + values[arg] = true + end + if table.is_array(t) then + for _, v in ipairs(t) do + if values[v] then + found = true + break + end + end + else + for _, v in pairs(t) do + if values[v] then + found = true + break + end end end end diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index 3aa2a8e6c..bddfea057 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -284,7 +284,7 @@ end -- e.g. -- {target = ..., targetkind = "static", configs = {defines = "", cxflags = "", includedirs = ""}} -- --- @return flags string, flags list +-- @return flags list -- function compiler:compflags(opt) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 49998fec6..2e93ea2bb 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -421,7 +421,6 @@ end -- make the compile arguments list function compargv(self, sourcefile, objectfile, flags) - -- precompiled header? local extension = path.extension(sourcefile) if (extension:startswith(".h") or extension == ".inl") then diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 3550b1a32..6678bec81 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -29,11 +29,7 @@ import("core.base.hashset") function init(self) -- init asflags - if self:program():find("64") then - self:set("asflags", "-nologo") - else - self:set("asflags", "-nologo", "-Gd") - end + self:set("asflags", "-nologo") -- init flags map self:set("mapflags", @@ -111,6 +107,21 @@ end -- make the compile arguments list function compargv(self, sourcefile, objectfile, flags) + -- we need to set the default -Gd option for the x86 architecture, + -- if the other calling convention flags are not set + -- + -- we can't directly remove -Gd. This is not only for backward compatibility, + -- but also to simplify mixed compilation with c programs. + -- + -- although this may affect some performance, + -- it only takes effect under x86 asm, so there will be no major performance issues. + -- + -- @see https://github.com/xmake-io/xmake/issues/1779 + -- + if not self:program():find("64", 1, true) and + not table.contains(flags, "-Gd", "/Gd", "-Gc", "/Gc", "-GZ", "/GZ") then + table.insert(flags, "-Gd") + end return self:program(), table.join("-c", flags, "-Fo" .. objectfile, sourcefile) end -- cgit v1.3.1 From 7b6391d71e863e8395bfd8b7e28337c84e7cac36 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 28 Oct 2021 00:38:50 +0800 Subject: improve ml --- xmake/modules/core/tools/ml.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/modules/core/tools/ml.lua') diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 6678bec81..59749974c 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -119,7 +119,7 @@ function compargv(self, sourcefile, objectfile, flags) -- @see https://github.com/xmake-io/xmake/issues/1779 -- if not self:program():find("64", 1, true) and - not table.contains(flags, "-Gd", "/Gd", "-Gc", "/Gc", "-GZ", "/GZ") then + not table.contains(flags, "-Gc", "/Gc", "-GZ", "/GZ") then table.insert(flags, "-Gd") end return self:program(), table.join("-c", flags, "-Fo" .. objectfile, sourcefile) -- cgit v1.3.1