Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking for mingw/x86_64 on MSYS2 fails #1078

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
47 changes: 24 additions & 23 deletions tools/my_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,12 @@ 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

Expand All @@ -36,15 +25,27 @@ def mySpawn(sh, escape, cmd, args, env):
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 rv:
break
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
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(cmdline, env)

rv = mySubProcess(" ".join(args), env)
return rv

env["SPAWN"] = mySpawn
Expand Down
Loading