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

Fix shell argument limit #1731

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions tools/common_compiler_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ def generate(env):
elif env["lto"] == "full":
env.Append(CCFLAGS=["-flto"])
env.Append(LINKFLAGS=["-flto"])

if env["platform"] == "linux" or env.get("use_mingw", False):
env['ARFLAGS'] = "rcs"
31 changes: 30 additions & 1 deletion tools/godotcpp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import tempfile
import sys

from SCons.Action import Action
Expand Down Expand Up @@ -162,6 +163,25 @@ def scons_generate_bindings(target, source, env):
return None


def _build_static_lib_with_rsp(target, source, env):
target_lib = str(target[0])

with tempfile.NamedTemporaryFile(mode="w", suffix=".rsp", delete=False) as rsp_file:
rsp_path = rsp_file.name
for src in source:
rsp_file.write(str(src) + "\n")

try:
ar = env['AR']
arflags = env.get("ARFLAGS", "")
command = "{} {} {} @{}".format(ar, arflags, target_lib, rsp_path)
env.Execute(command)
finally:
os.remove(rsp_path)

return None


platforms = ["linux", "macos", "windows", "android", "ios", "web"]

# CPU architecture options.
Expand Down Expand Up @@ -513,6 +533,9 @@ def generate(env):
"GodotCPPDocData": Builder(action=scons_generate_doc_source),
}
)
if env["platform"] == "linux" or env.get("use_mingw", False):
env.Append(BUILDERS={"GodotStaticLibRspBuilder": Builder(action=Action(_build_static_lib_with_rsp, "$ARCOMSTR"))})

env.AddMethod(_godot_cpp, "GodotCPP")


Expand Down Expand Up @@ -547,7 +570,13 @@ def _godot_cpp(env):
library_name = "libgodot-cpp" + env["suffix"] + env["LIBSUFFIX"]

if env["build_library"]:
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
if env["platform"] == "linux" or env.get("use_mingw", False):
# Use a custom builder to aggregate object files into a static library using a temporary response file.
# This avoids hitting the shell argument limit.
library = env.GodotStaticLibRspBuilder(target=env.File("bin/%s" % library_name), source=env.Object(sources))
else:
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)

env.NoCache(library)
default_args = [library]

Expand Down