Skip to content

COMP: Constrain x86_64 optimization flags according to CMAKE_SYSTEM_PROCESSOR#2459

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
thewtex:x86_64-flags-check
Mar 30, 2021
Merged

COMP: Constrain x86_64 optimization flags according to CMAKE_SYSTEM_PROCESSOR#2459
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
thewtex:x86_64-flags-check

Conversation

@thewtex
Copy link
Copy Markdown
Member

@thewtex thewtex commented Mar 30, 2021

CMAKE_SYSTEM_PROCESSOR defines the target compilation architecture. When
we want x86_64 optimizations, e.g. -march=corei7, only add these flags
when building for this architecture. On Linux/macOS (GCC/AppleClang),
CMAKE_SYSTEM_PROCESSOR is "x86_64" and on Windows (Visual Studio) it is
"AMD64".

…ROCESSOR

CMAKE_SYSTEM_PROCESSOR defines the target compilation architecture. When
we want x86_64 optimizations, e.g. -march=corei7, only add these flags
when building for this architecture. On Linux/macOS (GCC/AppleClang),
CMAKE_SYSTEM_PROCESSOR is "x86_64" and on Windows (Visual Studio) it is
"AMD64".
@seanm
Copy link
Copy Markdown
Contributor

seanm commented Mar 30, 2021

Introspecting the system processor is antithetical to cross compiling. It'd be nice to see less of it, not more of it. As you know, I just got rid of a problematic case the other day: #2450

It's still setting -march=corei7, which, in my view, as I've said before, is undesirable:

  • If you're building to deploy to the public, you may want to support older processors, which many people out there have
  • If you're building for yourself only, you might want an even higher setting, like -march=core-avx2

It seems to be a choice that is best for no one, and best left to the person building the code.

@thewtex
Copy link
Copy Markdown
Member Author

thewtex commented Mar 30, 2021

Introspecting the system processor is antithetical to cross compiling. It'd be nice to see less of it, not more of it. As you know, I just got rid of a problematic case the other day: #2450

Note that CMAKE_SYSTEM_PROCESSOR is not the host system processor. This improves cross compilation support -- it is not antithetical to cross compliing.

It seems to be a choice that is best for no one, and best left to the person building the code.

We do want the person building the code to be able to choose their optimization flags, but we also want good, sensible defaults. Enabling SIMD support on x86_64 is a good default.

@thewtex thewtex merged commit 4d24c3b into InsightSoftwareConsortium:master Mar 30, 2021
@thewtex thewtex deleted the x86_64-flags-check branch March 30, 2021 18:54
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…-flags-check

COMP: Constrain x86_64 optimization flags according to CMAKE_SYSTEM_PROCESSOR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants