From 43ab32ae7e6d92ed0b743e7489e55a66382092fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 1 Feb 2021 14:26:16 +0100 Subject: [PATCH] Linux: Build with use_static_cpp=yes by default for x86_64 This enables `-static-libgcc -static-libstdc++` which help make custom Linux builds more portable (official builds have been using this option for years). For some obscure reason Ubuntu 18.04 i386 crashes when using the option for i386 builds, so let's play it safe and enable for x86_64 only for now. (cherry picked from commit 1ebd66dafff915fb76aa0da77af9fa0f6ec741ef) --- platform/x11/detect.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index e77d559ad28..fe9ebe098ef 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -65,7 +65,7 @@ def get_opts(): BoolVariable("use_llvm", "Use the LLVM compiler", False), BoolVariable("use_lld", "Use the LLD linker", False), BoolVariable("use_thinlto", "Use ThinLTO", False), - BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", False), + BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True), BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), @@ -380,4 +380,7 @@ def configure(env): # Link those statically for portability if env["use_static_cpp"]: - env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) + # Workaround for GH-31743, Ubuntu 18.04 i386 crashes when it's used. + # That doesn't make any sense but it's likely a Ubuntu bug? + if is64 or env["bits"] == "64": + env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])