diff options
Diffstat (limited to 'platform/windows/detect.py')
-rw-r--r-- | platform/windows/detect.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 684a7c34a0..9adab7284c 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -620,18 +620,16 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config): print("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.") sys.exit(255) - env.Append(CCFLAGS=["-flto=thin"]) - env.Append(LINKFLAGS=["-flto=thin"]) + env.AppendUnique(CCFLAGS=["-flto=thin"]) elif env["use_llvm"]: - env.Append(CCFLAGS=["-flto"]) - env.Append(LINKFLAGS=["-flto"]) + env.AppendUnique(CCFLAGS=["-flto"]) else: env.AppendUnique(CCFLAGS=["/GL"]) - env.AppendUnique(ARFLAGS=["/LTCG"]) - if env["progress"]: - env.AppendUnique(LINKFLAGS=["/LTCG:STATUS"]) - else: - env.AppendUnique(LINKFLAGS=["/LTCG"]) + if env["progress"]: + env.AppendUnique(LINKFLAGS=["/LTCG:STATUS"]) + else: + env.AppendUnique(LINKFLAGS=["/LTCG"]) + env.AppendUnique(ARFLAGS=["/LTCG"]) if vcvars_msvc_config: env.Prepend(CPPPATH=[p for p in str(os.getenv("INCLUDE")).split(";")]) @@ -704,11 +702,29 @@ def get_is_ar_thin_supported(env): return False +WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)") + + +def tempfile_arg_esc_func(arg): + from SCons.Subst import quote_spaces + + arg = quote_spaces(arg) + # GCC requires double Windows slashes, let's use UNIX separator + return WINPATHSEP_RE.sub(r"/\1", arg) + + def configure_mingw(env: "SConsEnvironment"): # Workaround for MinGW. See: # https://www.scons.org/wiki/LongCmdLinesOnWin32 env.use_windows_spawn_fix() + # In case the command line to AR is too long, use a response file. + env["ARCOM_ORIG"] = env["ARCOM"] + env["ARCOM"] = "${TEMPFILE('$ARCOM_ORIG', '$ARCOMSTR')}" + env["TEMPFILESUFFIX"] = ".rsp" + if os.name == "nt": + env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func + ## Build type if not env["use_llvm"] and not try_cmd("gcc --version", env["mingw_prefix"], env["arch"]): |