Hint GCC >= 12 on aarch64 for bf16/fp16 capability probes#28785
Conversation
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
There was a problem hiding this comment.
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_flagprobes. - Emit an actionable
FATAL_ERRORthat includes the detected GCC version and the required minimum.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tianleiwu
left a comment
There was a problem hiding this comment.
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 staticVERSION_LESS 12gate can reject a valid GCC 11 + newer-binutils toolchain that thecheck_cxx_compiler_flagprobe 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 usecheck_cxx_compiler_flag; in mixed toolchains (CC=gcc,CXX=clang++) this canFATAL_ERRORincorrectly, and the version reported in the message should be the C++ compiler's.
Neither is blocking; verdict is COMMENT.
|
Thanks for the review — both points addressed in 83e12f9. Took the Option A path you preferred: dropped the static The existing |
Summary
GCC >= 12guard immediately before the existing-march=armv8.2-a+bf16/-march=armv8.2-a+fp16check_cxx_compiler_flagprobes incmake/CMakeLists.txt.FATAL_ERRORthat names the required compiler version and the version that was detected.Motivation
On aarch64, GCC versions prior to 12 ship with an assembler that does not accept the
+bf16/+fp16architecture extensions. The existing capability probes therefore fail at configure time with the opaque messageThe 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 existingif (NOT APPLE AND NOT Emscripten AND onnxruntime_target_platform STREQUAL "aarch64")block, add aCMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 12check that emits a descriptiveFATAL_ERRORnaming the required GCC version and the detected version.Test Plan
lintrunner -areports no issues on the changed file.linux-aarch64build jobs exercise the unchanged code path on a supported toolchain.GCC >= 12 is required for aarch64 BFloat16/Float16 support. Found GCC <version>., instead of the previous crypticThe compiler doesn't support BFLOAT16!!!.