Backport 1.1: IAR build fixes after 1.1.0 #708

Open
gilles-peskine-arm wants to merge 12 commits from gilles-peskine-arm/iar-1.1.0 into tf-psa-crypto-1.1
gilles-peskine-arm commented 2026-03-11 17:42:37 -05:00 (Migrated from github.com)

Fix the build of the library and the unit tests with IAR.

This is the 1.1 version. I'll do the development version once the 1.1 version is approved or close to being appoved, since development is a moving target and there's already one more warning (in the new MLDSA code) now.

The build was already broken in 1.0.0, but https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/694 made it worse by adding deprecation warnings on the use of many standard library functions.

Needs preceding PR: submodule update, although this is only needed to actually fix the IAR build, not to pass our CI.

Needs preceding PR:

PR checklist

Fix the build of the library and the unit tests with IAR. This is the 1.1 version. I'll do the development version once the 1.1 version is approved or close to being appoved, since development is a moving target and there's already one more warning (in the new MLDSA code) now. The build was already broken in 1.0.0, but https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/694 made it worse by adding deprecation warnings on the use of many standard library functions. Needs preceding PR: submodule update, although this is only needed to actually fix the IAR build, not to pass our CI. Needs preceding PR: * [x] https://github.com/Mbed-TLS/mbedtls-framework/pull/289 * [ ] https://github.com/Mbed-TLS/mbedtls-framework/pull/299 ## PR checklist - [x] **changelog** provided - [x] **mbedtls development PR** provided https://github.com/Mbed-TLS/mbedtls/pull/10635 - [ ] **mbedtls 4.1 PR** TODO - [ ] **TF-PSA-Crypto development PR** TODO - [x] **TF-PSA-Crypto 1.1 PR** provided https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/708 - [x] **framework PR** provided https://github.com/Mbed-TLS/mbedtls-framework/pull/289; https://github.com/Mbed-TLS/mbedtls-framework/pull/299 - [x] **3.6 PR** provided https://github.com/Mbed-TLS/mbedtls/pull/10636 - **tests** built (but did not link) the library, the unit test support code and the unit tests (but not the programs) in the baremetal config with IAR 9.40 for Arm
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-03-12 05:00:27 -05:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

Fixes IAR build issues/regressions in the library and unit tests (notably IAR-specific deprecation warnings and diagnostics).

Changes:

  • Adds IAR-specific configuration and diagnostic suppressions to unblock compilation of library and test code.
  • Updates unit tests to avoid constructs that trigger IAR warnings/errors (e.g., TEST_ASSERT(!"msg") → TEST_FAIL("msg")).
  • Adjusts platform/header behavior around C11 Annex K and zeroization functions; updates framework submodule.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/suites/test_suite_rsa.function Simplifies a test callsite argument (always NULL).
tests/suites/test_suite_psa_crypto_pake.function Replaces assertion idiom with explicit test failure to satisfy IAR.
tests/suites/test_suite_psa_crypto.function Same as above for PSA crypto suite variant.
tests/suites/test_suite_alignment.function Removes unused local buffer initialization from alignment test.
tests/suites/main_test.function Adds IAR DLIB config and suppresses specific IAR diagnostics in test runner TU.
tests/suites/host_test.function Changes integer parsing validation for IAR compatibility.
platform/platform_util.c Enables memset_s path even under IAR.
framework Updates framework submodule pointer.
drivers/builtin/src/psa_crypto_cipher.c Suppresses IAR goto/initialization diagnostic in cipher module TU.
drivers/builtin/src/bignum.c Suppresses IAR goto/initialization diagnostic in bignum module TU.
drivers/builtin/src/aes.c Fixes logic for selecting AES implementation return value under hardware-only builds.
core/tf_psa_crypto_platform_requirements.h Documents IAR Annex K side-effect on deprecations.
core/tf_psa_crypto_common.h Adds IAR-specific workaround redefining __DEPREC after enabling Annex K.

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

You can also share your feedback on Copilot code review. Take the survey.

## Pull request overview Fixes IAR build issues/regressions in the library and unit tests (notably IAR-specific deprecation warnings and diagnostics). **Changes:** - Adds IAR-specific configuration and diagnostic suppressions to unblock compilation of library and test code. - Updates unit tests to avoid constructs that trigger IAR warnings/errors (e.g., `TEST_ASSERT(!"msg")` → `TEST_FAIL("msg")`). - Adjusts platform/header behavior around C11 Annex K and zeroization functions; updates framework submodule. ### Reviewed changes Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | tests/suites/test_suite_rsa.function | Simplifies a test callsite argument (always `NULL`). | | tests/suites/test_suite_psa_crypto_pake.function | Replaces assertion idiom with explicit test failure to satisfy IAR. | | tests/suites/test_suite_psa_crypto.function | Same as above for PSA crypto suite variant. | | tests/suites/test_suite_alignment.function | Removes unused local buffer initialization from alignment test. | | tests/suites/main_test.function | Adds IAR DLIB config and suppresses specific IAR diagnostics in test runner TU. | | tests/suites/host_test.function | Changes integer parsing validation for IAR compatibility. | | platform/platform_util.c | Enables `memset_s` path even under IAR. | | framework | Updates framework submodule pointer. | | drivers/builtin/src/psa_crypto_cipher.c | Suppresses IAR goto/initialization diagnostic in cipher module TU. | | drivers/builtin/src/bignum.c | Suppresses IAR goto/initialization diagnostic in bignum module TU. | | drivers/builtin/src/aes.c | Fixes logic for selecting AES implementation return value under hardware-only builds. | | core/tf_psa_crypto_platform_requirements.h | Documents IAR Annex K side-effect on deprecations. | | core/tf_psa_crypto_common.h | Adds IAR-specific workaround redefining `__DEPREC` after enabling Annex K. | </details> --- 💡 <a href="/Mbed-TLS/TF-PSA-Crypto/new/development?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.<br><br>You can also share your feedback on Copilot code review. [Take the survey](https://www.surveymonkey.com/r/XP6L3XJ).
@ -29,0 +29,4 @@
#if defined(__IAR_SYSTEMS_ICC__)
/* In IAR (at least IAR 9.40 for Arm), enabling the C11 annex K functions
* (memset_s(), memcpy_s(), ...) with `#define __STDC_WANT_LIB_EXT1__ 1`
* causes the non-s functions to be declared as deprecatd. We want some
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-12 05:00:26 -05:00

Corrected spelling of 'deprecatd' to 'deprecated'.

 * causes the non-s functions to be declared as deprecated. We want some
Corrected spelling of 'deprecatd' to 'deprecated'. ```suggestion * causes the non-s functions to be declared as deprecated. We want some ```
@ -29,0 +48,4 @@
#include <stddef.h>
#undef __DEPREC
#define __DEPREC
#endif
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-12 05:00:26 -05:00

Redefining a toolchain/system macro like __DEPREC in a widely-included header can leak into downstream includes and alter how unrelated headers declare deprecations (effectively disabling deprecation annotations beyond this library). A more contained approach would be to localize this workaround to implementation files, or to bracket only the specific system header inclusions that trigger the unwanted deprecations (and then restore the original macro), or to prefer a compiler pragma/warning-control mechanism where possible.

Redefining a toolchain/system macro like `__DEPREC` in a widely-included header can leak into downstream includes and alter how *unrelated* headers declare deprecations (effectively disabling deprecation annotations beyond this library). A more contained approach would be to localize this workaround to implementation files, or to bracket only the specific system header inclusions that trigger the unwanted deprecations (and then restore the original macro), or to prefer a compiler pragma/warning-control mechanism where possible.
@ -43,3 +42,4 @@
if (*end != '\0' || end == str) {
mbedtls_fprintf(stderr,
"Expected integer for parameter and got: %s\n", str);
return KEY_VALUE_MAPPING_NOT_FOUND;
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-12 05:00:26 -05:00

strtol() errors aren’t fully handled here: overflow/underflow sets errno = ERANGE and returns a clamped value, which would currently be accepted and can yield incorrect test parameter values. Consider setting errno = 0 before calling strtol() and rejecting inputs when errno == ERANGE (in addition to the existing end == str / trailing characters checks).

`strtol()` errors aren’t fully handled here: overflow/underflow sets `errno = ERANGE` and returns a clamped value, which would currently be accepted and can yield incorrect test parameter values. Consider setting `errno = 0` before calling `strtol()` and rejecting inputs when `errno == ERANGE` (in addition to the existing `end == str` / trailing characters checks).
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-12 05:00:26 -05:00

These diagnostic suppressions apply to the remainder of the translation unit and are not restored, which can mask unrelated warnings and make future debugging harder. Consider scoping them (e.g., using IAR’s diagnostic push/pop if available, or restoring with #pragma diag_default=Pe546 / #pragma diag_default=Pe188 after the affected section) so only the intended code patterns are covered.

These diagnostic suppressions apply to the remainder of the translation unit and are not restored, which can mask unrelated warnings and make future debugging harder. Consider scoping them (e.g., using IAR’s diagnostic push/pop if available, or restoring with `#pragma diag_default=Pe546` / `#pragma diag_default=Pe188` after the affected section) so only the intended code patterns are covered.
bjwtaylor (Migrated from github.com) approved these changes 2026-08-25 07:10:24 -05:00
bjwtaylor (Migrated from github.com) left a comment

Besides the typo already highlighted this looks good.

Besides the typo already highlighted this looks good.
This pull request has changes conflicting with the target branch.
  • framework
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'gilles-peskine-arm/iar-1.1.0:gilles-peskine-arm/iar-1.1.0'
git switch 'gilles-peskine-arm/iar-1.1.0'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'tf-psa-crypto-1.1'
git merge --no-ff 'gilles-peskine-arm/iar-1.1.0'
git switch 'gilles-peskine-arm/iar-1.1.0'
git rebase 'tf-psa-crypto-1.1'
git switch 'tf-psa-crypto-1.1'
git merge --ff-only 'gilles-peskine-arm/iar-1.1.0'
git switch 'gilles-peskine-arm/iar-1.1.0'
git rebase 'tf-psa-crypto-1.1'
git switch 'tf-psa-crypto-1.1'
git merge --no-ff 'gilles-peskine-arm/iar-1.1.0'
git switch 'tf-psa-crypto-1.1'
git merge --squash 'gilles-peskine-arm/iar-1.1.0'
git switch 'tf-psa-crypto-1.1'
git merge --ff-only 'gilles-peskine-arm/iar-1.1.0'
git switch 'tf-psa-crypto-1.1'
git merge 'gilles-peskine-arm/iar-1.1.0'
git push origin 'tf-psa-crypto-1.1'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto!708
No description provided.