Skip to content

SCons: Properly set SSE2 as baseline on x86_32 #100337

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

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
6 changes: 6 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ elif env.msvc:
)
Exit(255)

# Default architecture flags.
if env["arch"] == "x86_32":
if env.msvc:
env.Append(CCFLAGS=["/arch:SSE2"])
else:
env.Append(CCFLAGS=["-msse2"])

# Set optimize and debug_symbols flags.
# "custom" means do nothing and let users set their own optimization flags.
Expand Down
8 changes: 1 addition & 7 deletions modules/raycast/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,12 @@ if env["builtin_embree"]:
env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL"])
env_raycast.AppendUnique(CPPDEFINES=["NDEBUG"]) # No assert() even in debug builds.

if not env.msvc:
if env["arch"] in ["x86_64", "x86_32"]:
env_raycast.Append(CCFLAGS=["-msse2", "-mxsave"])

if env["platform"] == "windows":
env_raycast.Append(CCFLAGS=["-mstackrealign"])

if env["platform"] == "windows":
if env.msvc:
env.Append(LINKFLAGS=["psapi.lib"])
else:
env.Append(LIBS=["psapi"])
env_raycast.Append(CCFLAGS=["-mstackrealign"])

if env.msvc: # Disable bogus warning about intentional struct padding.
env_raycast.Append(CCFLAGS=["/wd4324"])
Expand Down
12 changes: 3 additions & 9 deletions platform/macos/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ def configure(env: "SConsEnvironment"):
supported_arches = ["x86_64", "arm64"]
validate_arch(env["arch"], get_name(), supported_arches)

## Build type

if env["target"] == "template_release":
if env["arch"] != "arm64":
env.Prepend(CCFLAGS=["-msse2"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reference - current min. supported macOS version (10.13) require SSE4.1 to work.

elif env.dev_build:
env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"])

## Compiler configuration

# Save this in environment for use by other modules
Expand All @@ -97,6 +89,7 @@ def configure(env: "SConsEnvironment"):
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.13"])

env.Append(CCFLAGS=["-ffp-contract=off"])
env.Append(CCFLAGS=["-fobjc-arc"])

cc_version = get_compiler_version(env)
cc_version_major = cc_version["apple_major"]
Expand All @@ -106,7 +99,8 @@ def configure(env: "SConsEnvironment"):
if is_apple_clang(env) and cc_version_major == 1500 and cc_version_minor == 0:
env.Prepend(LINKFLAGS=["-ld_classic"])

env.Append(CCFLAGS=["-fobjc-arc"])
if env.dev_build:
env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"])

if "osxcross" not in env: # regular native build
if env["macports_clang"] != "no":
Expand Down
6 changes: 1 addition & 5 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,7 @@ def configure_mingw(env: "SConsEnvironment"):
print("Detected GCC to be a wrapper for Clang.")
env["use_llvm"] = True

# TODO: Re-evaluate the need for this / streamline with common config.
if env["target"] == "template_release":
if env["arch"] != "arm64":
env.Append(CCFLAGS=["-msse2"])
elif env.dev_build:
if env.dev_build:
# Allow big objects. It's supposed not to have drawbacks but seems to break
# GCC LTO, so enabling for debug builds only (which are not built with LTO
# and are the only ones with too big objects).
Expand Down