diff --git a/tools/common_compiler_flags.py b/tools/common_compiler_flags.py index 437f256b..838dbcf0 100644 --- a/tools/common_compiler_flags.py +++ b/tools/common_compiler_flags.py @@ -39,6 +39,14 @@ def generate(env): elif env.get("is_msvc", False): env.Append(CXXFLAGS=["/EHsc"]) + if not env.get("is_msvc", False): + if env["symbols_visibility"] == "visible": + env.Append(CCFLAGS=["-fvisibility=default"]) + env.Append(LINKFLAGS=["-fvisibility=default"]) + elif env["symbols_visibility"] == "hidden": + env.Append(CCFLAGS=["-fvisibility=hidden"]) + env.Append(LINKFLAGS=["-fvisibility=hidden"]) + # Set optimize and debug_symbols flags. # "custom" means do nothing and let users set their own optimization flags. if env.get("is_msvc", False): diff --git a/tools/godotcpp.py b/tools/godotcpp.py index 92ad7aeb..adfd4975 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -291,6 +291,15 @@ def options(opts, env): ) ) + opts.Add( + EnumVariable( + key="symbols_visibility", + help="Symbols visibility on GNU platforms. Use 'auto' to apply the default value.", + default=env.get("symbols_visibility", "hidden"), + allowed_values=["auto", "visible", "hidden"], + ) + ) + opts.Add( EnumVariable( "optimize",