Rework of -target/-mcpu/-mfpu options for LLVM CLANG#2498
Open
chentang16 wants to merge 3 commits into
Open
Conversation
Due to various issues reported so far: Open-CMSIS-Pack/cmsis-toolbox#583 arm/arm-toolchain#861 the -target/-mcpu/-mfpu options in CLANG.17.0.1.cmake have been reworked based on the ATfE manual pages: https://developer.arm.com/documentation/107976/22-1-0/Compile-for-a-specific-Arm-architecture-or-Arm-processor/-mcpu-command-line-options-for-M-profile-processors?lang=en https://developer.arm.com/documentation/107976/22-1-0/Compile-for-a-specific-Arm-architecture-or-Arm-processor/-mcpu-command-line-options-for-A-profile-processors https://developer.arm.com/documentation/107976/22-1-0/Compile-for-a-specific-Arm-architecture-or-Arm-processor/-mcpu-command-line-options-for-R-profile-processors
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request reworks how the LLVM Embedded Toolchain (Clang) CPU/arch-related flags are derived in CLANG.17.0.1.cmake, aiming to resolve reported backend crashes/hardfaults by adjusting the use of -target, -mcpu, and -mfpu according to Arm toolchain guidance.
Changes:
- Reworked per-CPU mappings to prefer encoding FP/MVE/DSP capabilities into
-mcpufeature strings and, in many cases, omit-mfpu. - Adjusted target triple selection logic (notably for Cortex-A/M/R vs other arches) and added conditional handling for
-mabi. - Added validation/error branches for unsupported FPU/MVE combinations for Cortex-M52/M55/M85 and related CPUs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+439
to
+443
| if(DEFINED CLANG_MABI) | ||
| set(CLANG_CPU "-mcpu=${CLANG_MCPU} -mabi=${CLANG_MABI}") | ||
| else() | ||
| set(CLANG_CPU "-mcpu=${CLANG_MCPU}") | ||
| endif() |
Member
There was a problem hiding this comment.
Unclear whether this is a valid fix as we are no long considering CLANG_MABI at all.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Removed redundant checks for FP_FVE in MVE conditions to simplify error handling for cortex-m CPUs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2498 +/- ##
=======================================
Coverage 65.24% 65.24%
=======================================
Files 147 147
Lines 26675 26675
Branches 16166 16166
=======================================
Hits 17405 17405
Misses 7074 7074
Partials 2196 2196
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Due to various issues reported so far:
the -target/-mcpu/-mfpu options in CLANG.17.0.1.cmake have been reworked based on the ATfE manual pages:
Fixes
mcpu=cortex-m55 -mfpu=fpv5-sp-d16can lead to fatal error in backend #2491Changes
options for Cortex-M/A/R covered by CMSIS-Toolbox.
Changes have been tested with all Cortex-M built targets in https://github.com/Arm-Examples/AVH-Hello
No more crash issue tested with https://github.com/Arm-Examples/cmsis-mlek-examples
No more hardfault issue tested with Tensorflow_LiteRT_HelloWorld on STM32F7-Disco
Checklist