Skip to content

Add a WOLFSSL_ARM_ASM CMake option - #12126

Open
Frauschi wants to merge 6 commits into
wolfSSL:masterfrom
Frauschi:cmake-armasm-option
Open

Frauschi wants to merge 6 commits into
wolfSSL:masterfrom
Frauschi:cmake-armasm-option

Conversation

@Frauschi

Copy link
Copy Markdown
Member

Description

CMake picked the ARM assembly sources on WOLFSSL_ARM_ASM but never declared the option or defined WOLFSSL_ARMASM, so ARM assembly only worked through a hand-written user_settings.h. This adds the option with the --enable-armasm CPU defaults and builds the ARM ML-DSA assembly in CMake and the Zephyr module.

Changes

  • Declare WOLFSSL_ARM_ASM and WOLFSSL_ARMASM_THUMB2, define WOLFSSL_ARMASM and add configure's per-CPU defaults unless the user set -mcpu/-mfpu/-march
  • Treat a 32-bit userland on a 64-bit kernel as armv8l, as config.guess does
  • Build the AArch64 and ARM32 ML-DSA assembly in CMake and the Zephyr module
  • Derive WOLFSSL_AARCH64_NO_SQRDMLSH in settings.h from the compiler's target CPU
  • Define WOLFSSL_IGNORE_FILE_WARN empty in CMake so user_settings.h templates don't hit a redefinition error
  • Leave the CSR v2 pending CA path out of NO_TLS builds, which failed to link with user_settings_ca.h

Testing

  • New build-armasm CMake job on AArch64 Linux and macOS: assembly and inline forms, checks options.h exports every library define, runs ctest
  • New CMake step that builds the tls12, tls13, dtls13, pq, rsa_only, ca and pkcs7 user_settings.h templates

@Frauschi Frauschi self-assigned this Nov 13, 2026
Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:44
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +140 B, text +14,496 B (+5.2%, 297,108 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.

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.

🟡 Changes recommended

Toolchain-supplied CPU flags can leave C and assembly targets inconsistent, causing AArch64 link failures, and bypass the required ARMv7 FIPS inline workaround.

2 open issues
What changed in this PR

Adds explicit ARM assembly support to wolfSSL’s CMake configuration, aligning CPU defaults with Autotools and extending ML-DSA assembly integration.

Changes:

  • Adds ARM assembly options, CPU defaults, and generated-header definitions.
  • Includes ARM ML-DSA assembly in CMake and Zephyr builds.
  • Adds ARM and configuration-template CI coverage, with fixes for template and NO_TLS builds.
File Description
zephyr/​CMakeLists.txt Includes supported ARM ML-DSA assembly sources.
wolfssl/​wolfcrypt/​settings.h Derives SQRDMLSH availability from compiler target features.
src/​internal.c Excludes CSR v2 pending-CA handling from NO_TLS builds.
CMakeLists.txt Adds ARM options, CPU defaults, target detection, and warning-macro compatibility.
cmake/​options.h.in Exports ARM assembly configuration macros.
cmake/​functions.cmake Selects inline or standalone ARM ML-DSA assembly sources.
.github/​workflows/​cmake.yml Adds ARM assembly tests and user-settings template builds.

Review effort: Balanced

Comment thread CMakeLists.txt Resolved
Comment thread CMakeLists.txt Resolved

@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 #12126

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/workflows/cmake.yml, CMakeLists.txt, cmake/functions.cmake, cmake/options.h.in, zephyr/CMakeLists.txt
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

@Frauschi
Frauschi force-pushed the cmake-armasm-option branch from 2793703 to c9418bd Compare November 13, 2026 14:04
@Frauschi

Copy link
Copy Markdown
Member Author

@claude review

Comment thread CMakeLists.txt Resolved
@Frauschi
Frauschi force-pushed the cmake-armasm-option branch from c9418bd to 8d71f48 Compare November 13, 2026 15:51
Autotools adds armv8-mldsa-asm and armv8-32-mldsa-asm when ARM assembly
is enabled, but the CMake build never did, so an ARM assembly CMake
build with ML-DSA failed to link on the mldsa_*_neon functions. Add
them as the ML-KEM block does; each file guards itself on the target
architecture.
The AArch64 ML-KEM and ML-DSA assembly use SQRDMLSH unless
WOLFSSL_AARCH64_NO_SQRDMLSH is defined, and that instruction only
assembles when the target CPU has RDM. Only configure's default
-mcpu=generic+crypto and the Zephyr settings defined it, so an AArch64
assembly build for a CPU without RDM, such as -march=armv8-a+crypto or
an iOS arm64 target, failed with "instruction requires: rdm". Define it
in settings.h whenever __ARM_FEATURE_QRDMX is absent. Targets with RDM
keep the SQRDMLSH code.
cmake/functions.cmake already picked the ARM assembly sources on
WOLFSSL_ARM_ASM, but nothing declared the option or defined
WOLFSSL_ARMASM, so an ARM assembly CMake build only worked from a
user_settings.h with hand-picked CPU flags.

Declare the option and define WOLFSSL_ARMASM, which reaches the assembly
sources and options.h. Unless a -mcpu=, -mfpu= or -march= option is set
in CMAKE_C_FLAGS or CMAKE_ASM_FLAGS, in any of their per-configuration
variants or in the directory compile options, or the build uses
user_settings.h, add the CPU defaults of --enable-armasm:
-mcpu=generic+crypto and -mstrict-align on AArch64, the SHA-512/SHA-3
crypto instructions on macOS, NEON without the crypto extension on
ARMv7-A, Thumb-2 without NEON on ARMv7-M and ARMv7E-M, ARMv6 and ARMv4
without NEON or the crypto extension, and the ARMv8 crypto extension on
other 32-bit ARM. When CMAKE_C_COMPILER_TARGET is set, its arch picks
the CPU branch, with thumb read as arm, as configure does with its host
triple, so thumbv7em-none-eabi takes the ARMv7E-M path. iOS and the
other Apple arm64 targets keep their own CPU flags. ARMv5, ARMv6-M,
ARMv7-R, ARMv8-R, ARMv8-M and any other processor name, such as a core
name, have no defaults and get a warning. A build that skips the
defaults says so in a status line. ARMv7 FIPS builds use the inline
assembly, as configure does. A user who sets the CPU also sets it in
CMAKE_ASM_FLAGS, and gets a warning when only one of CMAKE_C_FLAGS and
CMAKE_ASM_FLAGS sets it. Declare WOLFSSL_ARMASM_THUMB2, which already
picked the Thumb-2 sources, as an option that defines the macro on
32-bit ARM together with WOLFSSL_ARMASM_NO_NEON and
WOLFSSL_ARMASM_NO_HW_CRYPTO, since the Thumb-2 ports have neither.
Refuse a build for a known non-ARM target or for several macOS
architectures at once, and ignore WOLFSSL_ARM_ASM when WOLFSSL_ASM is
off, as configure does, without changing its cached value.

A 32-bit userland on a 64-bit kernel, such as 32-bit Raspberry Pi OS,
reports aarch64 as the processor. Treat it as 32-bit ARMv8 (armv8l, as
config.guess reports it) when the compiler has 4-byte pointers and does
not define __aarch64__, so that neither the AArch64 CPU flags nor
WOLFSSL_AARCH64_BUILD reach a 32-bit compiler. AArch64 ILP32 defines
__aarch64__ and stays on the AArch64 path.

Export WOLFSSL_ARMASM_INLINE and the new macros through options.h.

Add a CMake CI job on AArch64 Linux and macOS that builds the assembly
and inline forms, checks that options.h exports every library define and
runs ctest.
CMake passed -DWOLFSSL_IGNORE_FILE_WARN, which defines it as 1, while
the examples/configs templates define it empty. A CMake user_settings.h
build from user_settings_pq.h, _tls12.h, _tls13.h, _dtls13.h,
_rsa_only.h, _ca.h or _pkcs7.h therefore failed -Werror on the macro
redefinition. Define it empty so both definitions match.
ProcessPeerCertAddPendingCA() calls TLSX_CSR2_AddPendingSigner(), which
tls.c only builds without NO_TLS. Every other CSR v2 call in
ProcessPeerCerts() already checks NO_TLS, so a NO_TLS build with
HAVE_CERTIFICATE_STATUS_REQUEST_V2, such as user_settings_ca.h, failed
to link whenever the unused helper was kept, as in an unoptimized CMake
build. Guard the helper, its call and addToPendingCAs the same way.

Add a CMake CI step that builds the tls12, tls13, dtls13, pq, rsa_only,
ca and pkcs7 user_settings.h templates as Debug builds, so this link
failure and the WOLFSSL_IGNORE_FILE_WARN redefinition fixed in the
previous commit stay caught.
zephyr/CMakeLists.txt never added armv8-mldsa-asm_c.c or
armv8-32-mldsa-asm_c.c, so a Zephyr AArch64 build with
CONFIG_WOLFCRYPT_ASM and ML-DSA failed to link on the mldsa_*_neon
functions. Add them for the ARMv8 prefixes, in the symmetric assembly
list and after wc_mldsa in the FIPS v7 boundary as src/include.am does.
There is no Thumb-2 ML-DSA assembly, so Cortex-M builds are unchanged.
@Frauschi
Frauschi force-pushed the cmake-armasm-option branch from 8d71f48 to 73517bf Compare December 4, 2026 08:23
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