Skip to content

Hint GCC >= 12 on aarch64 for bf16/fp16 capability probes#28785

Merged
tianleiwu merged 2 commits into
microsoft:mainfrom
Rishi-Dave:rishidave/fix/aarch64-gcc-min-version
Jun 6, 2026
Merged

Hint GCC >= 12 on aarch64 for bf16/fp16 capability probes#28785
tianleiwu merged 2 commits into
microsoft:mainfrom
Rishi-Dave:rishidave/fix/aarch64-gcc-min-version

Conversation

@Rishi-Dave

Copy link
Copy Markdown
Contributor

Summary

  • Adds an explicit, aarch64-scoped GCC >= 12 guard immediately before the existing -march=armv8.2-a+bf16 / -march=armv8.2-a+fp16 check_cxx_compiler_flag probes in cmake/CMakeLists.txt.
  • The new guard fires with an actionable FATAL_ERROR that names the required compiler version and the version that was detected.
  • No change to the global GCC 11.1 minimum, and no impact on x86_64, Apple, Emscripten, MSVC, or Clang builds.

Motivation

On aarch64, GCC versions prior to 12 ship with an assembler that does not accept the +bf16 / +fp16 architecture extensions. The existing capability probes therefore fail at configure time with the opaque message The compiler doesn't support BFLOAT16!!!, leaving users to guess that a newer toolchain (not just a newer compiler) is required. This is the exact scenario reported on RHEL 9 / GCC 11.

Fixes #22837

Changes

  • cmake/CMakeLists.txt: inside the existing if (NOT APPLE AND NOT Emscripten AND onnxruntime_target_platform STREQUAL "aarch64") block, add a CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 12 check that emits a descriptive FATAL_ERROR naming the required GCC version and the detected version.

Test Plan

  • This is a CMake-only configure-time change; no runtime tests are affected.
  • Verified lintrunner -a reports no issues on the changed file.
  • Existing CI linux-aarch64 build jobs exercise the unchanged code path on a supported toolchain.
  • Manual verification: configuring on aarch64 with GCC < 12 now fails at CMake time with GCC >= 12 is required for aarch64 BFloat16/Float16 support. Found GCC <version>., instead of the previous cryptic The compiler doesn't support BFLOAT16!!!.

GCC < 12 on aarch64 ships with an assembler that does not accept the
`+bf16` / `+fp16` architecture extensions used by ORT's MLAS kernels,
causing the existing `check_cxx_compiler_flag` probes to fail with the
opaque message "The compiler doesn't support BFLOAT16!!!".

Add an explicit, aarch64-scoped GCC version guard immediately before the
capability probes so the failure surfaces with an actionable message
that names the required compiler version.

Fixes microsoft#22837

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the aarch64 build configuration experience by adding a clearer, earlier CMake failure when using GCC toolchains that are known to fail the -march=armv8.2-a+bf16 / +fp16 capability probes with an opaque error.

Changes:

  • Add an aarch64-scoped GCC version guard immediately before the existing BF16/FP16 check_cxx_compiler_flag probes.
  • Emit an actionable FATAL_ERROR that includes the detected GCC version and the required minimum.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/CMakeLists.txt Outdated

@tianleiwu tianleiwu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: require GCC >= 12 on aarch64 for bf16/fp16 capability probes

Small, well-scoped CMake-only change that turns a previously cryptic configure failure (#22837) into an actionable one. The explanatory comment block is helpful.

Two points worth considering before merge:

  • Static version gate vs. the authoritative probe (inline comment): The capability that is actually required comes from the assembler (binutils/gas), which versions independently of GCC. A static VERSION_LESS 12 gate can reject a valid GCC 11 + newer-binutils toolchain that the check_cxx_compiler_flag probe just below would accept. Improving the existing probe's error message would be a non-breaking alternative.
  • C vs C++ compiler mismatch: Already raised on the existing thread — the guard keys off CMAKE_C_COMPILER_* while the probes use check_cxx_compiler_flag; in mixed toolchains (CC=gcc, CXX=clang++) this can FATAL_ERROR incorrectly, and the version reported in the message should be the C++ compiler's.

Neither is blocking; verdict is COMMENT.

Comment thread cmake/CMakeLists.txt Outdated
@Rishi-Dave

Copy link
Copy Markdown
Contributor Author

Thanks for the review — both points addressed in 83e12f9.

Took the Option A path you preferred: dropped the static CMAKE_C_COMPILER_VERSION VERSION_LESS 12 gate entirely and let the check_cxx_compiler_flag probes remain the authoritative check. Removing the gate also resolves the CMAKE_C_COMPILER_* vs check_cxx_compiler_flag (C++) mismatch you flagged, so a GCC-11 + newer-binutils toolchain (or a mixed CC=gcc / CXX=clang++ setup) will no longer hit a spurious FATAL_ERROR — only the real probe failure will trigger.

The existing HAS_ARM64_BFLOAT16 / HAS_ARM64_FLOAT16 failure messages now explain that the gating capability comes from the assembler, note that GCC >= 12 with a recent binutils is typically required on aarch64, and link to #22837 for context. Lintrunner clean; only cmake/CMakeLists.txt touched.

@tianleiwu
tianleiwu enabled auto-merge (squash) June 5, 2026 17:03
@tianleiwu tianleiwu changed the title fix: require GCC >= 12 on aarch64 for bf16/fp16 capability probes Hint GCC >= 12 on aarch64 for bf16/fp16 capability probes Jun 5, 2026
@tianleiwu
tianleiwu merged commit d9ecd81 into microsoft:main Jun 6, 2026
89 of 91 checks passed
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.

[Build] v1.20.0 min GCC version can't build on armv8

3 participants