Compare commits

...

7 Commits

Author SHA1 Message Date
Feiyun Wang 5637b6894c
Merge 64a818cfd9 into 3f44e9b404 2024-01-02 17:26:53 +02:00
Feiyun Wang 64a818cfd9 Fix #1059: Linking for mingw/x86_64 on MSYS2 fails, and optimize "ar" command execution
Command line length=8158 is the maximum to be OK.
2023-04-04 19:54:14 +08:00
Feiyun Wang fb06503307 Fix #1059: Linking for mingw/x86_64 on MSYS2 fails, w/ ar execution speed up
Command line length=8153 is OK, while 8159 is broken.
2023-04-02 23:45:48 +08:00
Feiyun Wang 189f56c34e Fix #1059: Linking for mingw/x86_64 on MSYS2 fails, w/ ar execution speed up 2023-04-01 01:20:41 +08:00
Feiyun Wang 88e135d53b Fix #1059: Linking for mingw/x86_64 on MSYS2 fails, w/ ar execution speed up 2023-04-01 00:46:28 +08:00
Feiyun Wang 8d3dc7551d Fix #1059: Linking for mingw/x86_64 on MSYS2 fails, w/ ar execution speed up 2023-04-01 00:25:45 +08:00
Feiyun Wang 61c3f8a440 Fix #1059: Linking for mingw/x86_64 on MSYS2 fails 2023-04-01 00:25:44 +08:00
1 changed files with 24 additions and 27 deletions

View File

@ -11,41 +11,38 @@ def configure(env):
import subprocess
def mySubProcess(cmdline, env):
# print "SPAWNED : " + cmdline
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(
cmdline,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo,
shell=False,
env=env,
)
data, err = proc.communicate()
rv = proc.wait()
# print(cmdline)
rv = subprocess.run(args=cmdline, shell=True, env=env).returncode
if rv:
print("=====")
print(err.decode("utf-8"))
print("subprocess.run().returncode=", rv, "(", hex(rv), ")")
print("len(cmdline)=", len(cmdline))
print("=====")
return rv
def mySpawn(sh, escape, cmd, args, env):
newargs = " ".join(args[1:])
cmdline = cmd + " " + newargs
rv = 0
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 len(args) > 4 and cmd.endswith("ar"):
# print("Long ar command is split.\nargc=", len(args))
lead = len(" ".join(args[0:3]))
begin = 3
length = lead + 1 + len(args[begin])
for i in range(4, len(args)):
length += 1 + len(args[i])
if length > 8158:
cmdline = " ".join(args[0:3] + args[begin:i])
# print("objs=", i - begin, ", length=", len(cmdline))
rv = mySubProcess(cmdline, env)
if rv:
break
else:
begin = i
length = lead + 1 + len(args[begin])
if not rv:
cmdline = " ".join(args[0:3] + args[begin:])
# print("objs=", len(args) - begin, ", length=", len(cmdline))
rv = mySubProcess(cmdline, env)
else:
rv = mySubProcess(" ".join(args), env)
return rv
env["SPAWN"] = mySpawn