Skip to content

Rework of -target/-mcpu/-mfpu options for LLVM CLANG#2498

Open
chentang16 wants to merge 3 commits into
Open-CMSIS-Pack:mainfrom
chentang16:main
Open

Rework of -target/-mcpu/-mfpu options for LLVM CLANG#2498
chentang16 wants to merge 3 commits into
Open-CMSIS-Pack:mainfrom
chentang16:main

Conversation

@chentang16

Copy link
Copy Markdown

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

Changes

  • CLANG_MCPU
  • CLANG_MFPU
  • CLANG_TARGET
  • CLANG_ARCH
    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

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

@chentang16 chentang16 changed the title Rework of -target/-mcpu/-mfpu options Rework of -target/-mcpu/-mfpu options for LLVM CLANG Jun 18, 2026
@brondani brondani requested review from brondani and Copilot June 18, 2026 14:23

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 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 -mcpu feature 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 thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
Comment thread tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Outdated
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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unclear whether this is a valid fix as we are no long considering CLANG_MABI at all.

chentang16 and others added 2 commits June 19, 2026 09:33
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

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.24%. Comparing base (859cb6c) to head (3a93294).

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           
Flag Coverage Δ
buildmgr-cov 79.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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