summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-05-11 16:21:52 +0200
committerArthur LAURENT <[email protected]>2025-05-11 16:21:59 +0200
commit2c161e887cb5aeb6e2e3d4d0871a7380403e5e09 (patch)
treea480fc8e8a22c3d5d1383e615c6b9a084e03039e
parent22fcfc64078f4ad04a9ecf5af30adaf7dae199e5 (diff)
(C++ modules support) default cxx11abi to true when gcc version is >= 15
-rw-r--r--xmake/core/project/policy.lua2
-rw-r--r--xmake/rules/c++/modules/gcc/support.lua7
2 files changed, 8 insertions, 1 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index cad9fd4cd..0c79be649 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -101,7 +101,7 @@ function policy.policies()
-- 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++.modules.gcc.cxx11abi"] = {description = "Force to enable new cxx11 abi in C++ modules for gcc.", type = "boolean"},
- ["build.c++.gcc.modules.cxx11abi"] = {description = "Force to enable new cxx11 abi in C++ modules for gcc. (deprecated)", type = "boolean", default = false},
+ ["build.c++.gcc.modules.cxx11abi"] = {description = "Force to enable new cxx11 abi in C++ modules for gcc. (deprecated)", type = "boolean"},
-- Set the default vs runtime, e.g. MT, MD
["build.c++.msvc.runtime"] = {description = "Set the default vs runtime.", type = "string", values = {"MT", "MD"}},
-- Enable cuda device link
diff --git a/xmake/rules/c++/modules/gcc/support.lua b/xmake/rules/c++/modules/gcc/support.lua
index bc924f35c..e6f8591a0 100644
--- a/xmake/rules/c++/modules/gcc/support.lua
+++ b/xmake/rules/c++/modules/gcc/support.lua
@@ -61,6 +61,13 @@ function load(target)
-- https://github.com/xmake-io/xmake/issues/3855
local cxx11abi = target:policy("build.c++.modules.gcc.cxx11abi") or
target:policy("build.c++.gcc.modules.cxx11abi")
+ if cxx11abi == nil then
+ -- enable cxx11abi on GCC >= 15 as it is required for C++23 module
+ local gcc_version = get_gcc_version(target)
+ if gcc_version and semver.compare(gcc_version, "15") > 0 then
+ cxx11abi = true
+ end
+ end
if cxx11abi then
target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=1")
else