Skip to content

Fix GCC CMSIS-RTOS v1/v2 builds hitting __stdcall in types.h - #12099

Open
stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:fix/cmsis-rtos-thread-types
Open

stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:fix/cmsis-rtos-thread-types

Conversation

@stenslae

@stenslae stenslae commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

When WOLFSSL_CMSIS_RTOS or WOLFSSL_CMSIS_RTOSv2 is built with GCC and without WOLFSSL_MDK_ARM, types.h falls through to its generic threading branch. That branch defines WOLFSSL_THREAD as the MSVC-only __stdcall, so any file that includes types.h fails to compile. MBED is also affected, because settings.h sets WOLFSSL_CMSIS_RTOS for it.

  • added a CMSIS-RTOS branch with the same THREAD_RETURN/THREAD_TYPE as the generic branch, but with an empty WOLFSSL_THREAD. WOLFSSL_MDK_ARM builds still use their existing branch.
  • a host-only reproducer that uses stub cmsis_os.h/cmsis_os2.h and compiles with gcc explicitly, since clang accepts __stdcall and would pass without the fix.
  • runs the reproducer on ubuntu-24.04.

Testing

  • The reproducer passes for v1 and v2 with the fix and fails for both against the old types.h.
  • Full library cross-compile with arm-none-eabi-gcc -mcpu=cortex-m4 and the real CMSIS headers from STM32Cube F4 1.28.0, building all 129 sources.

Known limitation (pre-existing, follow-up PR): a GCC build against a pure CMSIS-RTOS v1.x header (osCMSIS < 0x20000) now gets past types.h but then fails in src/internal.c at LowResTimer(). That function calls the v2-only osKernelGetTickCount(). v1-compat headers built on RTOS2, such as Keil RTX5 and STM32Cube FreeRTOS CMSIS_RTOS_V2, are not affected.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Without WOLFSSL_MDK_ARM they fell into the MSVC-only __stdcall branch.
@stenslae stenslae self-assigned this Nov 11, 2026
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:17

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.

🟢 Approval recommended

There are no active review issues blocking the CMSIS threading compatibility change.

No open issues 🎉

What changed in this PR

Fixes GCC compilation for CMSIS-RTOS v1/v2 configurations without WOLFSSL_MDK_ARM by avoiding __stdcall in wolfSSL’s thread definitions.

Changes:

  • Adds a CMSIS-specific threading branch while preserving existing MDK ARM behavior.
  • Adds a host-only GCC regression test with minimal CMSIS header stubs.
  • Packages the test files and runs the reproducer in Ubuntu 24.04 CI.
File Description
wolfssl/​wolfcrypt/​types.h Defines CMSIS thread types with an empty calling-convention macro.
tests/​include.am Includes regression test files in source distributions.
tests/​cmsis-rtos-thread-types-repro/​user_settings.h Provides minimal multithreaded test settings.
tests/​cmsis-rtos-thread-types-repro/​run.sh Compiles both CMSIS variants explicitly with GCC.
tests/​cmsis-rtos-thread-types-repro/​repro.c Exercises thread callback declarations and assignment.
tests/​cmsis-rtos-thread-types-repro/​cmsis_os2.h Supplies minimal CMSIS-RTOS v2 type stubs.
tests/​cmsis-rtos-thread-types-repro/​cmsis_os.h Supplies minimal CMSIS-RTOS v1 type stubs.
.github/​workflows/​cmsis-rtos-thread-types.yml Runs the regression test on Ubuntu 24.04.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +36 B, text +10,544 B (+3.7%, 293,052 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12099

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/workflows/cmsis-rtos-thread-types.yml, tests/cmsis-rtos-thread-types-repro/cmsis_os.h, tests/cmsis-rtos-thread-types-repro/cmsis_os2.h, tests/cmsis-rtos-thread-types-repro/run.sh, tests/cmsis-rtos-thread-types-repro/user_settings.h, tests/include.am
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@stenslae stenslae assigned wolfSSL-Bot and unassigned stenslae Nov 11, 2026
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.

4 participants