diff options
| author | ruki <[email protected]> | 2020-04-02 22:43:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-02 10:22:42 +0800 |
| commit | e502dac2f44e1b00a97caf79d8f42b292403bc87 (patch) | |
| tree | 6d703cb0dad1c7fa916f7313bf7d577db62454e8 | |
| parent | 21dbab6afaa0de6f0f9f43aa4c55ffc6e31a8657 (diff) | |
add mode rules
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/mode/xmake.lua | 123 |
2 files changed, 104 insertions, 21 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 9cf15ef8c..bf613f257 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -99,7 +99,7 @@ function nf_symbol(self, level) local maps = { debug = "-g" - , hidden = "-fvisibility=hidden" + , hidden = "-fvisibility=hidden -fvisibility-inlines-hidden" } -- make it diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua index f0d1b80c6..9682d98f2 100644 --- a/xmake/rules/mode/xmake.lua +++ b/xmake/rules/mode/xmake.lua @@ -49,7 +49,7 @@ rule("mode.release") target:set("symbols", "hidden") end - -- enable fastest optimization + -- enable optimization if not target:get("optimize") then if is_plat("android", "iphoneos") then target:set("optimize", "smallest") @@ -77,9 +77,13 @@ rule("mode.profile") target:set("symbols", "debug") end - -- enable fastest optimization + -- enable optimization if not target:get("optimize") then - target:set("optimize", "fastest") + if is_plat("android", "iphoneos") then + target:set("optimize", "smallest") + else + target:set("optimize", "fastest") + end end -- enable gprof @@ -89,12 +93,12 @@ rule("mode.profile") end end) --- define rule: check mode -rule("mode.check") +-- define rule: coverage mode +rule("mode.coverage") after_load(function (target) - -- is check mode now? xmake f -m check - if is_mode("check") then + -- is coverage mode now? xmake f -m coverage + if is_mode("coverage") then -- enable the debug symbols if not target:get("symbols") then @@ -106,21 +110,98 @@ rule("mode.check") target:set("optimize", "none") end - -- attempt to enable some checkers for pc - if is_mode("check") and is_arch("i386", "x86_64") then - target:add("cxflags", "-fsanitize=address", "-ftrapv") - target:add("mxflags", "-fsanitize=address", "-ftrapv") - target:add("ldflags", "-fsanitize=address") + -- enable coverage + target:add("cxflags", "--coverage") + target:add("mxflags", "--coverage") + target:add("ldflags", "--coverage") + end + end) + +-- define rule: asan mode +rule("mode.asan") + after_load(function (target) + + -- is asan mode now? xmake f -m asan + if is_mode("asan") then + + -- enable the debug symbols + if not target:get("symbols") then + target:set("symbols", "debug") end + + -- enable optimization + if not target:get("optimize") then + if is_plat("android", "iphoneos") then + target:set("optimize", "smallest") + else + target:set("optimize", "fastest") + end + end + + -- enable asan checker + target:add("cxflags", "-fsanitize=address") + target:add("mxflags", "-fsanitize=address") + target:add("ldflags", "-fsanitize=address") end end) --- define rule: coverage mode -rule("mode.coverage") +-- define rule: tsan mode +rule("mode.tsan") after_load(function (target) - -- is coverage mode now? xmake f -m coverage - if is_mode("coverage") then + -- is tsan mode now? xmake f -m tsan + if is_mode("tsan") then + + -- enable the debug symbols + if not target:get("symbols") then + target:set("symbols", "debug") + end + + -- enable optimization + if not target:get("optimize") then + if is_plat("android", "iphoneos") then + target:set("optimize", "smallest") + else + target:set("optimize", "fastest") + end + end + + -- enable tsan checker + target:add("cxflags", "-fsanitize=thread") + target:add("mxflags", "-fsanitize=thread") + target:add("ldflags", "-fsanitize=thread") + end + end) + +-- define rule: valgrind mode +rule("mode.valgrind") + after_load(function (target) + + -- is valgrind mode now? xmake f -m valgrind + if is_mode("valgrind") then + + -- enable the debug symbols + if not target:get("symbols") then + target:set("symbols", "debug") + end + + -- enable optimization + if not target:get("optimize") then + if is_plat("android", "iphoneos") then + target:set("optimize", "smallest") + else + target:set("optimize", "fastest") + end + end + end + end) + +-- define rule: check mode (deprecated) +rule("mode.check") + after_load(function (target) + + -- is check mode now? xmake f -m check + if is_mode("check") then -- enable the debug symbols if not target:get("symbols") then @@ -132,9 +213,11 @@ rule("mode.coverage") target:set("optimize", "none") end - -- enable coverage - target:add("cxflags", "--coverage") - target:add("mxflags", "--coverage") - target:add("ldflags", "--coverage") + -- attempt to enable some checkers for pc + if is_mode("check") and is_arch("i386", "x86_64") then + target:add("cxflags", "-fsanitize=address", "-ftrapv") + target:add("mxflags", "-fsanitize=address", "-ftrapv") + target:add("ldflags", "-fsanitize=address") + end end end) |
