Skip to content

Commit

Permalink
SCons: Properly set SSE2 as baseline on x86_32
Browse files Browse the repository at this point in the history
Setting it only for release templates on Windows and macOS was inconsistent,
and Jolt requires it as a minimum.

Drop the `-mxsave` flag from the raycast module, this doesn't seem to be
used explicitly by Embree, and unnecessarily makes our config and baseline
muddy.
  • Loading branch information
akien-mga committed Dec 12, 2024
1 parent 19e003b commit f86b369
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
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"])
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

0 comments on commit f86b369

Please sign in to comment.