Skip to content

COMP: Remove hardcoded -march=corei7, -mtune=generic, and dead code#6049

Merged
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:comp-remove-march-corei7
Apr 13, 2026
Merged

COMP: Remove hardcoded -march=corei7, -mtune=generic, and dead code#6049
hjmjohnson merged 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:comp-remove-march-corei7

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson commented Apr 13, 2026

Remove architecture-specific compiler flags that are unnecessary or broken, and dead Intel ICC detection code. Closes #2634. Supersedes #6039.

What was removed and why
Removed Reason
-march=corei7 Recent GCC removed corei7 as an -march option (#2634). Targeted Nehalem (2008).
-mtune=generic This is the compiler default when no -mtune is specified — always a no-op.
Intel ICC detection (icc/icpc) ICC was EOL 2023, replaced by ICX which identifies as Clang. The detection block only set InstructionSetOptimizationFlags to empty — same as the default.

No architecture flags are set by default, ensuring maximum redistributability for pip wheels, Docker images, and hardware translation (Rosetta, QEMU). Users building for local performance should add -march=native via CMAKE_C_FLAGS or CMakeUserPresets.json.

Added a CMake comment cautioning that -march=native on AVX-512 CPUs should be paired with -mprefer-vector-width=256 to avoid Intel frequency throttling.

@github-actions github-actions bot added type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots labels Apr 13, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 13, 2026

Greptile Summary

Removes the -march=corei7 and -mtune=generic compiler flags from the non-MSVC x86/x86_64 path in check_compiler_optimization_flags, and deletes the now-redundant Intel ICC detection block (both branches of which already set InstructionSetOptimizationFlags to empty and were then unconditionally overwritten). The change is correct: -march=corei7 has been dropped from recent GCC releases, and -mtune=generic was always the compiler default, making both flags either harmful or no-ops.

Confidence Score: 5/5

Safe to merge — removes a build-breaking flag with no functional regression.

The only remaining finding is a P2 style suggestion about two empty placeholder variables. All logic changes are correct and well-documented; no new flags, no behaviour change for MSVC or non-x86 paths.

No files require special attention.

Important Files Changed

Filename Overview
CMake/ITKSetStandardCompilerFlags.cmake Removes -march=corei7 and -mtune=generic from non-MSVC x86/x86_64 GCC/Clang paths, deletes now-dead ICC detection code, and documents the rationale inline. Logic is correct; c_flags/cxx_flags placeholders remain but are harmless.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[check_compiler_optimization_flags] --> B{x86_64 / AMD64?}
    B -- No --> Z[c_and_cxx_flags = empty]
    B -- Yes --> C{MSVC?}
    C -- Yes --> D[check_avx_flags\n+ /arch:SSE /arch:SSE2 if 32-bit]
    C -- No --> E{NOT EMSCRIPTEN\nOR WASI?}
    E -- Yes --> F["InstructionSetOptimizationFlags = empty\n(was: -march=corei7 -mtune=generic)\n(was also: dead ICC detection)"]
    E -- No --> Z
    D --> G[c_and_cxx_flags = InstructionSetOptimizationFlags]
    F --> G
    G --> H[check_c_compiler_flags\ncheck_cxx_compiler_flags]
    H --> I[Return c / cxx optimization flags to caller]
Loading

Reviews (1): Last reviewed commit: "COMP: Remove hardcoded -march=corei7 and..." | Re-trigger Greptile

Comment thread CMake/ITKSetStandardCompilerFlags.cmake Outdated
Comment thread CMake/ITKSetStandardCompilerFlags.cmake Outdated
Comment thread CMake/ITKSetStandardCompilerFlags.cmake Outdated
@blowekamp
Copy link
Copy Markdown
Member

I agree with this packager need specific flags ( and it can be tedious to disable hard coded one), and local developers using the native architecture is a good option for local executables.

Copy link
Copy Markdown
Member Author

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

Close, but some changes need addressing.

@hjmjohnson hjmjohnson force-pushed the comp-remove-march-corei7 branch from a948fea to bfbb4a9 Compare April 13, 2026 17:57
@hjmjohnson hjmjohnson changed the title COMP: Remove hardcoded -march=corei7 and -mtune=generic COMP: Remove hardcoded -march=corei7, -mtune=generic, and dead ICC detection Apr 13, 2026
Remove architecture-specific compiler flags and dead code from the
non-MSVC x86_64 path in ITKSetStandardCompilerFlags.cmake:
- -march=corei7: recent GCC removed corei7 as an option (InsightSoftwareConsortium#2634)
- -mtune=generic: compiler default, always a no-op
- Intel ICC detection (icc/icpc): EOL 2023, replaced by ICX/Clang
- Empty c_flags/cxx_flags placeholder variables: never populated

No architecture flags are set by default, ensuring maximum
redistributability. Added AVX-512 frequency throttling caution
for users who add -march=native.

Closes InsightSoftwareConsortium#2634.
@hjmjohnson hjmjohnson force-pushed the comp-remove-march-corei7 branch from bfbb4a9 to 7c0bfe8 Compare April 13, 2026 18:02
@hjmjohnson hjmjohnson changed the title COMP: Remove hardcoded -march=corei7, -mtune=generic, and dead ICC detection COMP: Remove hardcoded -march=corei7, -mtune=generic, and dead code Apr 13, 2026
The check_avx_flags() function had a CMake scoping bug: it set a local
variable `avx_flags_var` instead of using `set(${avx_flags_var} ...
PARENT_SCOPE)`, so the caller's InstructionSetOptimizationFlags was
never modified. The MSVC AVX/AVX2 runtime detection ran but its
results were silently discarded.

Remove:
- check_avx_flags() function definition (72 lines)
- Its sole call site in the MSVC branch
- The MSVC 32-bit /arch:SSE /arch:SSE2 append (also dead — appended
  to the unmodified InstructionSetOptimizationFlags)
- The InstructionSetOptimizationFlags variable and c_and_cxx_flags
  intermediary (both always empty on all platforms)

The check_c_compiler_flags/check_cxx_compiler_flags calls now receive
no architecture flags, matching the actual behavior that has been
in effect since the function was introduced.

Note: check_sse2_flags() is a separate function with a different
(also broken) scoping pattern but is still called elsewhere — left
for a follow-up.
@hjmjohnson hjmjohnson merged commit 215c0f1 into InsightSoftwareConsortium:main Apr 13, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest GCC releases have removed corei7 as an arch option

3 participants