Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,6 @@ def use_windows_spawn_fix(self, platform=None):
if os.name != "nt":
return # not needed, only for windows

# On Windows, due to the limited command line length, when creating a static library
# from a very high number of objects SCons will invoke "ar" once per object file;
# that makes object files with same names to be overwritten so the last wins and
# the library loses symbols defined by overwritten objects.
# By enabling quick append instead of the default mode (replacing), libraries will
# got built correctly regardless the invocation strategy.
# Furthermore, since SCons will rebuild the library from scratch when an object file
# changes, no multiple versions of the same object file will be present.
self.Replace(ARFLAGS="q")

def mySubProcess(cmdline, env):
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
Expand All @@ -498,19 +488,17 @@ def mySubProcess(cmdline, env):
return rv

def mySpawn(sh, escape, cmd, args, env):
# Used by TEMPFILE.
if cmd == "del":
os.remove(args[1])
return 0

newargs = " ".join(args[1:])
cmdline = cmd + " " + newargs

rv = 0
env = {str(key): str(value) for key, value in iter(env.items())}
if len(cmdline) > 32000 and cmd.endswith("ar"):
cmdline = cmd + " " + args[1] + " " + args[2] + " "
for i in range(3, len(args)):
rv = mySubProcess(cmdline + args[i], env)
if rv:
break
else:
rv = mySubProcess(cmdline, env)
rv = mySubProcess(cmdline, env)

return rv

Expand Down
20 changes: 18 additions & 2 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):

## Compile/link flags

env["MAXLINELENGTH"] = 8192 # Windows Vista and beyond, so always applicable.

if env["silence_msvc"] and not env.GetOption("clean"):
from tempfile import mkstemp

Expand Down Expand Up @@ -631,11 +629,29 @@ def spawn_capture(sh, escape, cmd, args, env):
env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)])


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"]):
Expand Down
Loading