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

fixed order in SConstruct #65583

Closed
Closed
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
47 changes: 24 additions & 23 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import time
from types import ModuleType
from collections import OrderedDict
from importlib.util import spec_from_file_location, module_from_spec
from platform_methods import is_lto_recommended

# Explicitly resolve the helper modules, this is done to avoid clash with
# modules of the same name that might be randomly added (e.g. someone adding
Expand Down Expand Up @@ -466,28 +467,6 @@ if selected_platform in platform_list:
if not (f[0] in ARGUMENTS) or ARGUMENTS[f[0]] == "auto": # Allow command line to override platform flags
env[f[0]] = f[1]

# Must happen after the flags' definition, so that they can be used by platform detect
detect.configure(env)

print(
'Building for platform "%s", architecture "%s", %s, target "%s".'
% (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"])
)

# Set our C and C++ standard requirements.
# C++17 is required as we need guaranteed copy elision as per GH-36436.
# Prepending to make it possible to override.
# This needs to come after `configure`, otherwise we don't have env.msvc.
if not env.msvc:
# Specifying GNU extensions support explicitly, which are supported by
# both GCC and Clang. Both currently default to gnu11 and gnu++14.
env.Prepend(CFLAGS=["-std=gnu11"])
env.Prepend(CXXFLAGS=["-std=gnu++17"])
else:
# MSVC doesn't have clear C standard support, /std only covers C++.
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
env.Prepend(CCFLAGS=["/std:c++17"])

# 'dev' and 'production' are aliases to set default options if they haven't been set
# manually by the user.
if env["dev"]:
Expand All @@ -498,7 +477,7 @@ if selected_platform in platform_list:
env["tests"] = methods.get_cmdline_bool("tests", True)
if env["production"]:
env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True)
env["lto"] = ARGUMENTS.get("lto", "full")
env["lto"] = ARGUMENTS.get("lto", "full" if is_lto_recommended(detect, env) else "none")
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False)
if not env["tools"] and env["target"] == "debug":
print(
Expand All @@ -519,6 +498,28 @@ if selected_platform in platform_list:
if env["lto"] != "none":
print("Using LTO: " + env["lto"])

# Must happen after the flags' definition, so that they can be used by platform detect
detect.configure(env)

print(
'Building for platform "%s", architecture "%s", %s, target "%s".'
% (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"])
)

# Set our C and C++ standard requirements.
# C++17 is required as we need guaranteed copy elision as per GH-36436.
# Prepending to make it possible to override.
# This needs to come after `configure`, otherwise we don't have env.msvc.
if not env.msvc:
# Specifying GNU extensions support explicitly, which are supported by
# both GCC and Clang. Both currently default to gnu11 and gnu++14.
env.Prepend(CFLAGS=["-std=gnu11"])
env.Prepend(CXXFLAGS=["-std=gnu++17"])
else:
# MSVC doesn't have clear C standard support, /std only covers C++.
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
env.Prepend(CCFLAGS=["/std:c++17"])

# Enforce our minimal compiler version requirements
cc_version = methods.get_compiler_version(env) or {
"major": None,
Expand Down
4 changes: 4 additions & 0 deletions platform_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ def detect_arch():
print("Unsupported CPU architecture: " + host_machine)
print("Falling back to x86_64.")
return "x86_64"


def is_lto_recommended(detect, env):
return not (("lto", "none") in detect.get_flags() or env.msvc)