summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-18 17:40:53 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-18 17:40:53 +0200
commit804d9775b55c566950d74331ec3bedfdb9255206 (patch)
tree9b56c540496697d6580072174db59a1933fd97c5
parent8ba3c2aeb45c5ccdd98c1991a3f85084f710b844 (diff)
parent28b95ff55010d8f9e3f9feca4f75e5aeaf1ac9aa (diff)
downloadredot-engine-804d9775b55c566950d74331ec3bedfdb9255206.tar.gz
Merge pull request #96407 from alvinhochun/mingw-ar-long-command-tempfile
Remove `ARFLAGS` hack for Windows, replace with `TEMPFILE`
-rw-r--r--methods.py24
-rw-r--r--platform/windows/detect.py5
2 files changed, 11 insertions, 18 deletions
diff --git a/methods.py b/methods.py
index 36462fd30b..3f11d39bd0 100644
--- a/methods.py
+++ b/methods.py
@@ -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
@@ -500,19 +490,17 @@ def use_windows_spawn_fix(self, platform=None):
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
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 684a7c34a0..2db58172bf 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -709,6 +709,11 @@ def configure_mingw(env: "SConsEnvironment"):
# 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"
+
## Build type
if not env["use_llvm"] and not try_cmd("gcc --version", env["mingw_prefix"], env["arch"]):