Skip to content

ARMCLANG.cmake: Add option NO_FSHORT_FLAGS#420

Merged
avinaw01-arm merged 1 commit intoARM-software:mainfrom
nicola-mazzucato-arm:fshort
Apr 17, 2026
Merged

ARMCLANG.cmake: Add option NO_FSHORT_FLAGS#420
avinaw01-arm merged 1 commit intoARM-software:mainfrom
nicola-mazzucato-arm:fshort

Conversation

@nicola-mazzucato-arm
Copy link
Copy Markdown
Contributor

The default build flag set for ARMCLANG contains both -fshort-enums -fshort-wchar which can cause linking errors if the secure side is built without them.

Add a build option NO_FSHORT_FLAGS so that users can adapt the psa tests with their secure side build options.

@nicola-mazzucato-arm
Copy link
Copy Markdown
Contributor Author

This is to fix errors like:
Error: L6242E: Cannot link object val_entry.o as its attributes are incompatible with the image attributes. ... wchart-16 clashes with wchart-32. ... packed-enum clashes with enum_is_int.

@avinaw01-arm avinaw01-arm self-assigned this Mar 25, 2026
@avinaw01-arm
Copy link
Copy Markdown
Member

Hi @nicola-mazzucato-arm
Thank you for raising the P.R. Are you experiencing this error only with ARMCLANG complier or with other compilers as well?

@nicola-mazzucato-arm
Copy link
Copy Markdown
Contributor Author

hi @avinaw01-arm , I have only seen the above with ARMCLANG among the tests we have in TF-M CI.
Hope that helps,
Thanks

@avinaw01-arm
Copy link
Copy Markdown
Member

avinaw01-arm commented Apr 6, 2026

Hi Nicola,
Thanks for letting me know. There are few comments:

  1. Please update the Copyright year in the changed file like below:
    # * Copyright (c) 2019-2023, 2026, Arm Limited or its affiliates. All rights reserved.
  2. It would be better to phrase the message as: Disable -fshort-enums and -fshort-wchar. Same for Enable also.

I request you to please make the above changes. Thank you.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable build-time switch for the ARMCLANG toolchain so users can omit -fshort-enums / -fshort-wchar when their secure-side build doesn’t use them, avoiding ABI/link mismatches.

Changes:

  • Introduces NO_FSHORT_FLAGS logic to conditionally include/exclude -fshort-enums and -fshort-wchar in ARMCLANG CMAKE_C_FLAGS.
  • Adds status messages indicating whether the short-type flags are enabled.
  • Updates the file header copyright line.

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

Comment thread api-tests/tools/cmake/compiler/ARMCLANG.cmake Outdated
Comment on lines +67 to +73
if (NO_FSHORT_FLAGS)
set(FSHORT_C_FLAGS "")
message(STATUS "Disable -fshort-enums and -fshort-wchar flags")
else()
set(FSHORT_C_FLAGS "-fshort-enums -fshort-wchar")
message(STATUS "Enable -fshort-enums and -fshort-wchar flags")
endif()
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

NO_FSHORT_FLAGS is treated as a build option, but it’s not declared as a cache variable/option anywhere (no option() / set(... CACHE BOOL ...) in the repo). As a result, it won’t show up in cmake-gui/ccmake and may not be obvious to users how to set it. Consider defining it in this toolchain file (e.g., default OFF as a CACHE BOOL) so it behaves like a real, discoverable build option.

Copilot uses AI. Check for mistakes.
Comment thread api-tests/tools/cmake/compiler/ARMCLANG.cmake Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


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

@nicola-mazzucato-arm nicola-mazzucato-arm force-pushed the fshort branch 2 times, most recently from d70611b to 4d34742 Compare April 17, 2026 09:21
The default build flag set for ARMCLANG contains both
-fshort-enums -fshort-wchar which can cause linking errors
if the secure side is built without them.

Add a build option NO_FSHORT_FLAGS so that users can adapt
the psa tests with their secure side build options.

Signed-off-by: Nicola Mazzucato <nicola.mazzucato@arm.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

Comment on lines +67 to +73
if (NO_FSHORT_FLAGS)
set(FSHORT_C_FLAGS "")
message(STATUS "[PSA] : Disable -fshort-enums and -fshort-wchar flags")
else()
set(FSHORT_C_FLAGS "-fshort-enums -fshort-wchar")
message(STATUS "[PSA] : Enable -fshort-enums and -fshort-wchar flags")
endif()
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

NO_FSHORT_FLAGS is used as a user-facing CMake option here, but it isn't defined as a cache variable anywhere (no option() / set(... CACHE ...) found). That makes the default/intent harder to discover in CMake GUIs and inconsistent with how other build options in this repo are defaulted/validated in api-tests/CMakeLists.txt (e.g. INCLUDE_PANIC_TESTS, WATCHDOG_AVAILABLE). Consider defining NO_FSHORT_FLAGS as a CACHE BOOL with a documented default (0/OFF) and (optionally) validating accepted values alongside the other command-line options.

Copilot uses AI. Check for mistakes.
@avinaw01-arm avinaw01-arm merged commit 9218c1e into ARM-software:main Apr 17, 2026
3 of 4 checks passed
@avinaw01-arm
Copy link
Copy Markdown
Member

Hi @nicola-mazzucato-arm
Thank you for addressing the comments and updating the P.R. We have merged the same into our 'main' branch.

Best Regards,
Avi.

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