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
7 changes: 2 additions & 5 deletions tools/ar_tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ def tempfile_arg_esc_func(arg):
# writing the command to a response file. Refer to the engine equivalent in
# https://github.com/godotengine/godot/blob/master/platform/windows/detect.py
def configure(env):
if "ARCOM_ORIG" in env:
return # Already configured, don't wrap ARCOM in TEMPFILE twice.

env["ARCOM_ORIG"] = env["ARCOM"]
# This is SCons lazy evaluation syntax, only switching to a file when the command is actually too long.
env["ARCOM"] = "${TEMPFILE('$ARCOM_ORIG', '$ARCOMSTR')}"
# The flags must stay in the command (not in the file) to work with GCC 13 or older.
env["ARCOM"] = "$AR $ARFLAGS ${TEMPFILE('$TARGET $SOURCES', '$ARCOMSTR')}"
env["TEMPFILESUFFIX"] = ".rsp"
if os.name == "nt":
env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func
12 changes: 12 additions & 0 deletions tools/common_compiler_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ def exists(env):
return True


def configure_gcc_ar(env, prefix=""):
if env.Detect(prefix + "gcc-ar"):
env["AR"] = prefix + "gcc-ar"
env["RANLIB"] = prefix + "gcc-ranlib"
return

if env["lto"] != "none":
print("WARNING: Couldn't find `{0}gcc-ar`; falling back to `{0}ar`. LTO builds might fail.".format(prefix))
env["AR"] = prefix + "ar"
env["RANLIB"] = prefix + "ranlib"


def generate(env):
assert env["lto"] in ["thin", "full", "none"], "Unrecognized lto: {}".format(env["lto"])
if env["lto"] != "none":
Expand Down
3 changes: 3 additions & 0 deletions tools/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def generate(env):
if env["lto"] == "auto":
env["lto"] = "full"

if not env["use_llvm"]:
common_compiler_flags.configure_gcc_ar(env)

# Configure ARCOM response file in case the command line call to AR is too long.
ar_tempfile.configure(env)

Expand Down
15 changes: 10 additions & 5 deletions tools/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def exists(env):


def generate(env):
gcc_tool_prefix = None

if not env["use_mingw"] and msvc.exists(env):
if env["arch"] == "x86_64":
env["TARGET_ARCH"] = "amd64"
Expand Down Expand Up @@ -133,6 +135,7 @@ def generate(env):

elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
env["use_mingw"] = True
gcc_tool_prefix = ""
mingw.generate(env)
# Don't want lib prefixes
env["IMPLIBPREFIX"] = ""
Expand Down Expand Up @@ -180,11 +183,10 @@ def generate(env):
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-clang"
else:
env["CXX"] = prefix + "-w64-mingw32-g++"
env["CC"] = prefix + "-w64-mingw32-gcc"
env["AR"] = prefix + "-w64-mingw32-gcc-ar"
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
env["LINK"] = prefix + "-w64-mingw32-g++"
gcc_tool_prefix = prefix + "-w64-mingw32-"
env["CXX"] = gcc_tool_prefix + "g++"
env["CC"] = gcc_tool_prefix + "gcc"
env["LINK"] = gcc_tool_prefix + "g++"

# Want dll suffix
env["SHLIBSUFFIX"] = ".dll"
Expand Down Expand Up @@ -218,4 +220,7 @@ def generate(env):
else: # Release
env["lto"] = "full"

if gcc_tool_prefix is not None:
common_compiler_flags.configure_gcc_ar(env, gcc_tool_prefix)

common_compiler_flags.generate(env)
Loading