diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index e0a7b0228a0..0727cb6d5cb 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -75,11 +75,22 @@ function load(target) target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", implicitmodulesflag, {force = true}) - -- TODO fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file + -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file -- module.pcm cannot be loaded due to a configuration mismatch with the current compilation. -- -- it will happen in binary target depend ont shared target with modules, and enable release mode at same time. - target:set("symbols", "none") + local dep_symbols + local has_shared_deps = false + for _, dep in ipairs(target:orderdeps()) do + if dep:is_shared() then + dep_symbols = dep:get("symbols") + has_shared_deps = true + break + end + end + if has_shared_deps then + target:set("symbols", dep_symbols and dep_symbols or "none") + end -- if use libc++, we need install libc++ and libc++abi --