diff options
| author | ruki <[email protected]> | 2023-06-20 22:58:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-06-20 22:58:46 +0800 |
| commit | 945df4a01a9f2a88380138884b5c62e4fedf86be (patch) | |
| tree | e78134058c169b8777bc34f84d25f3d275569631 | |
| parent | 558afe6d4272c7f0471e484cec2345635620793d (diff) | |
add modules.cxx11abi policy for gcc #3855
| -rw-r--r-- | xmake/core/project/policy.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 56fbc2219..82944d415 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -60,6 +60,10 @@ function policy.policies() ["build.c++.msvc.fallbackscanner"] = {description = "Force msvc fallback module dependency scanner.", default = false, type = "boolean"}, -- force C++ modules fallback dependency scanner for gcc ["build.c++.gcc.fallbackscanner"] = {description = "Force gcc fallback module dependency scanner.", default = false, type = "boolean"}, + -- force to enable new cxx11 abi in C++ modules for gcc + -- If in the future, gcc can support it well, we'll turn it on by default + -- https://github.com/xmake-io/xmake/issues/3855 + ["build.c++.gcc.modules.cxx11abi"] = {description = "Force to enable new cxx11 abi in C++ modules for gcc.", type = "boolean"}, -- enable cuda device link ["build.cuda.devlink"] = {description = "Enable Cuda devlink.", type = "boolean"}, -- preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index a528a57ae..3c509edf5 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -73,8 +73,14 @@ function load(target) os.rm(_get_module_mapper(target)) end target:add("cxxflags", {modulesflag, modulemapperflag .. path.translate(_get_module_mapper(target))}, {force = true, expand = false}) - -- fix cxxabi issue, @see https://github.com/xmake-io/xmake/issues/2716#issuecomment-1225057760 - target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=0") + -- fix cxxabi issue + -- @see https://github.com/xmake-io/xmake/issues/2716#issuecomment-1225057760 + -- https://github.com/xmake-io/xmake/issues/3855 + if target:policy("build.c++.gcc.modules.cxx11abi") then + target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=1") + else + target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=0") + end end -- get includedirs for stl headers |
