Fix build failure from direct ONNX schema include in layernorm optimizer tests#29073
Merged
hariharans29 merged 1 commit intoJun 16, 2026
Conversation
Signed-off-by: Jonathan Clohessy <Jonathan.Clohessy@arm.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes a macOS AppleClang build failure in onnxruntime_test_all by avoiding direct inclusion of ONNX schema headers in a LayerNorm optimizer test, instead relying on ORT’s existing ONNX/protobuf wrapper that suppresses known Protobuf warnings under strict warning settings.
Changes:
- Replace direct include of
onnx/defs/schema.hwithcore/graph/onnx_protobuf.hin the LayerNorm graph transform test. - Ensure protobuf headers are included under ORT’s diagnostic suppression on AppleClang (arm64).
hariharans29
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This fixes a macOS AppleClang build failure in
onnxruntime_test_allcaused by directly including ONNX’sonnx/defs/schema.hfromgraph_transform_test_layernorm.cc.With the macOS arm64 CI build, ORT enables
-Wshorten-64-to-32and treats warnings as errors. ONNX’s schema header pulls in protobuf v21.12 headers, and protobuf’sgoogle/protobuf/parse_context.hemits several-Wshorten-64-to-32diagnostics under AppleClang. Because the test file includedonnx/defs/schema.hdirectly, it bypassed ORT’s existingcore/graph/onnx_protobuf.hwrapper, which already suppresses this known protobuf warning around ONNX/protobuf includes.The fix is to include/use the existing ORT ONNX protobuf wrapper instead of directly including
onnx/defs/schema.h.Repro
On macOS arm64 with AppleClang/Xcode, run:
./build.sh \ --config "${ORT_BUILD_CONFIG:-Release}" \ --use_xcode \ --apple_sysroot macosx \ --build_shared_lib \ --parallel \ --skip_tests \ --osx_arch arm64 \ --apple_deploy_target 14 \ --cmake_generator NinjaA faster targeted repro is:
Before this fix, the build fails compiling:
with errors like:
Root cause
graph_transform_test_layernorm.ccdirectly included:This exposed protobuf v21.12 headers to ORT’s normal AppleClang warning policy:
-Wshorten-64-to-32is enabled-Wshorten-64-to-32warnings inparse_context.hORT already has
core/graph/onnx_protobuf.h, which wraps ONNX/protobuf includes with the appropriate diagnostic suppression. The direct ONNX include bypassed that wrapper.Summary of fix
Replace the direct ONNX schema include in
graph_transform_test_layernorm.ccwith ORT’s existing ONNX protobuf wrapper include, so protobuf headers are included under the existing warning suppression.Validation
Validated locally on macOS arm64 / Xcode 16.4 / AppleClang 17 with:
and then the broader build step:
Both completed successfully after the fix.