IAR build fixes before 1.1.0/4.1.0/3.6.6: framework support #289

Merged
gilles-peskine-arm merged 4 commits from iar-1.1.0-framework into main 2026-03-16 08:48:45 -05:00
gilles-peskine-arm commented 2026-03-11 17:42:29 -05:00 (Migrated from github.com)

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

Also fix a problem with the structure of test helper code that I introduced in https://github.com/Mbed-TLS/mbedtls-framework/pull/279 and which is causing me a problem in a security fix: part of test_common.h should have been in tests/src, not tests/include/test.

PR checklist

Fix the build of the library and the unit tests with IAR. Also fix a problem with the structure of test helper code that I introduced in https://github.com/Mbed-TLS/mbedtls-framework/pull/279 and which is causing me a problem in a security fix: part of `test_common.h` should have been in `tests/src`, not `tests/include/test`. ## PR checklist - [x] **changelog** not required because: I don't think we should make any official promise that the IAR build is fixed since it isn't validated by a CI job - [x] **development PR** provided https://github.com/Mbed-TLS/mbedtls/pull/10635 - [x] **TF-PSA-Crypto 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 - [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-11 17:46:02 -05:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR fixes IAR build issues for the library/unit tests by restructuring test build-configuration includes and adding IAR-specific compatibility knobs in the test harness.

Changes:

  • Introduce tests/include/test/build_info.h and switch test headers to include it (instead of test_common.h) for consistent build configuration and private-access support.
  • Move C-file-only setup into tests/src/test_common.h and ensure test .c files include it first.
  • Add IAR-specific defines and warning suppression for successful compilation with IAR.

Reviewed changes

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

Show a summary per file
File Description
tests/src/threading_helpers.c Include test_common.h first for consistent compiler/test setup.
tests/src/test_memory.c Include test_common.h first for consistent compiler/test setup.
tests/src/test_common.h Add IAR _DLIB_FILE_DESCRIPTOR define; include test/build_info.h for test build config.
tests/src/random.c Include test_common.h first for consistent compiler/test setup.
tests/src/psa_memory_poisoning_wrappers.c Include test_common.h first for consistent compiler/test setup.
tests/src/psa_exercise_key.c Include test_common.h; suppress an IAR-specific diagnostic.
tests/src/psa_crypto_stubs.c Include test_common.h first for consistent compiler/test setup.
tests/src/psa_crypto_helpers.c Include test_common.h first for consistent compiler/test setup.
tests/src/pk_helpers.c Include test_common.h first for consistent compiler/test setup.
tests/src/helpers.c Include test_common.h first for consistent compiler/test setup.
tests/src/fake_external_rng_for_test.c Include test_common.h first for consistent compiler/test setup.
tests/src/bignum_helpers.c Replace direct private-access define with test_common.h include.
tests/src/bignum_codepath_check.c Include test_common.h first for consistent compiler/test setup.
tests/src/asn1_helpers.c Include test_common.h first for consistent compiler/test setup.
tests/include/test/threading_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/random.h Switch to including new build_info.h (test header build config).
tests/include/test/psa_memory_poisoning_wrappers.h Switch to including new build_info.h (test header build config).
tests/include/test/psa_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/psa_exercise_key.h Switch to including new build_info.h (test header build config).
tests/include/test/psa_crypto_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/pk_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/memory.h Switch to including new build_info.h (test header build config).
tests/include/test/macros.h Switch to including new build_info.h (test header build config).
tests/include/test/helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/fake_external_rng_for_test.h Switch to including new build_info.h (test header build config).
tests/include/test/constant_flow.h Switch to including new build_info.h (test header build config).
tests/include/test/build_info.h New header centralizing test header build configuration and private-access enablement.
tests/include/test/bignum_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/bignum_codepath_check.h Switch to including new build_info.h (test header build config).
tests/include/test/asn1_helpers.h Switch to including new build_info.h (test header build config).
tests/include/test/arguments.h Switch to including new build_info.h (test header build config).

💡 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 This PR fixes IAR build issues for the library/unit tests by restructuring test build-configuration includes and adding IAR-specific compatibility knobs in the test harness. **Changes:** - Introduce `tests/include/test/build_info.h` and switch test headers to include it (instead of `test_common.h`) for consistent build configuration and private-access support. - Move C-file-only setup into `tests/src/test_common.h` and ensure test `.c` files include it first. - Add IAR-specific defines and warning suppression for successful compilation with IAR. ### Reviewed changes Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | tests/src/threading_helpers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/test_memory.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/test_common.h | Add IAR `_DLIB_FILE_DESCRIPTOR` define; include `test/build_info.h` for test build config. | | tests/src/random.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/psa_memory_poisoning_wrappers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/psa_exercise_key.c | Include `test_common.h`; suppress an IAR-specific diagnostic. | | tests/src/psa_crypto_stubs.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/psa_crypto_helpers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/pk_helpers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/helpers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/fake_external_rng_for_test.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/bignum_helpers.c | Replace direct private-access define with `test_common.h` include. | | tests/src/bignum_codepath_check.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/src/asn1_helpers.c | Include `test_common.h` first for consistent compiler/test setup. | | tests/include/test/threading_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/random.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/psa_memory_poisoning_wrappers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/psa_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/psa_exercise_key.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/psa_crypto_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/pk_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/memory.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/macros.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/fake_external_rng_for_test.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/constant_flow.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/build_info.h | New header centralizing test header build configuration and private-access enablement. | | tests/include/test/bignum_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/bignum_codepath_check.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/asn1_helpers.h | Switch to including new `build_info.h` (test header build config). | | tests/include/test/arguments.h | Switch to including new `build_info.h` (test header build config). | </details> --- 💡 <a href="/Mbed-TLS/mbedtls-framework/new/main?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).
valeriosetti (Migrated from github.com) approved these changes 2026-03-12 10:09:14 -05:00
valeriosetti (Migrated from github.com) left a comment

The only current failure on the CI (DTLS proxy: 3d, gnutls client, fragmentation, nbio=2) looks spurious and changes look good to me, so I approve

The only current failure on the CI (`DTLS proxy: 3d, gnutls client, fragmentation, nbio=2`) looks spurious and changes look good to me, so I approve
gilles-peskine-arm commented 2026-03-12 10:25:07 -05:00 (Migrated from github.com)

I've restarted the CI since we want to see it pass.

I've restarted the CI since we want to see it pass.
bjwtaylor (Migrated from github.com) reviewed 2026-03-12 10:46:37 -05:00
bjwtaylor (Migrated from github.com) commented 2026-03-12 10:42:53 -05:00

Can this be changed to a push/pop or restore instead of a pragma, or is it required to cover the whole file?

Can this be changed to a push/pop or restore instead of a pragma, or is it required to cover the whole file?
gilles-peskine-arm (Migrated from github.com) reviewed 2026-03-12 11:24:26 -05:00
gilles-peskine-arm (Migrated from github.com) commented 2026-03-12 11:24:26 -05:00

I'd use it for the whole file anyway (I'm ignoring the warning because it's a common idiom, if it was just in one place I'd refactor that one place).

But anyway, does IAR have push/pop for #pragma diag_xxx? I can't find it in the manual.

I'd use it for the whole file anyway (I'm ignoring the warning because it's a common idiom, if it was just in one place I'd refactor that one place). But anyway, does IAR have push/pop for `#pragma diag_xxx`? I can't find it in the manual.
gilles-peskine-arm (Migrated from github.com) reviewed 2026-03-12 11:26:44 -05:00
bjwtaylor (Migrated from github.com) reviewed 2026-03-13 02:27:38 -05:00
bjwtaylor (Migrated from github.com) reviewed 2026-03-13 02:28:20 -05:00
bjwtaylor (Migrated from github.com) commented 2026-03-13 02:28:20 -05:00

OK, fair enough. Just wanted to check it had been considered. I'll close this one.

OK, fair enough. Just wanted to check it had been considered. I'll close this one.
bjwtaylor (Migrated from github.com) approved these changes 2026-03-13 02:28:59 -05:00
bjwtaylor (Migrated from github.com) left a comment

Looks good as long as we can get the CI to pass.

Looks good as long as we can get the CI to pass.
Sign in to join this conversation.
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/mbedtls-framework!289
No description provided.