Skip to content

Commit c3ccfa8

Browse files
committed
Implement use_static_cpp flag for Linux
See godotengine/godot-cpp#1747
1 parent 8524240 commit c3ccfa8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/linux.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Based on https://github.com/godotengine/godot-cpp/blob/98ea2f60bb3846d6ae410d8936137d1b099cd50b/tools/linux.py
1+
# Based on https://github.com/godotengine/godot-cpp/blob/e83fd0904c13356ed1d4c3d09f8bb9132bdc6b77/tools/linux.py
22
from build import common_compiler_flags
33
from SCons.Variables import BoolVariable
44
from SCons.Tool import clang, clangxx
55

66

77
def options(opts):
88
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler - only effective when targeting Linux", False))
9+
opts.Add(BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True))
910
opts.Add(BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False))
1011
opts.Add(BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN)", False))
1112
opts.Add(BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN)", False))
@@ -43,6 +44,10 @@ def generate(env):
4344
env.Append(CCFLAGS=["-march=rv64gc"])
4445
env.Append(LINKFLAGS=["-march=rv64gc"])
4546

47+
# Link statically for portability
48+
if env["use_static_cpp"]:
49+
env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
50+
4651
if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]:
4752
env.extra_suffix += ".san"
4853
env.Append(CCFLAGS=["-DSANITIZERS_ENABLED"])

0 commit comments

Comments
 (0)