diff options
| author | ruki <[email protected]> | 2021-10-28 00:37:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-10-28 00:37:30 +0800 |
| commit | 020ec323df6377390fe144e8af78dd7cc741ec0b (patch) | |
| tree | 92ae67e5301eab91ad4e8fd6d8fa074429811b00 | |
| parent | d527a9213c3ac1651dc7f7bea7a2ea91139ed6ff (diff) | |
improve ml
| -rw-r--r-- | xmake/core/base/table.lua | 46 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/core/tools/ml.lua | 21 |
4 files changed, 52 insertions, 18 deletions
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 |
