Repository navigation
Build OpenSSL from portable C sources where there is no assembly - #112863
Conversation
`contrib/openssl-cmake` picks a `PLATFORM_DIRECTORY` and the AES/BN/SHA/... implementations from a per-architecture `if/elseif` chain. An architecture the chain does not know about matches nothing: no `buildinf.h` include directory, and not one of the crypto cores gets compiled. The build then runs all the way to the final link before failing on undefined `OPENSSL_cleanse` and friends, which says nothing about what is actually wrong. Add a no-asm arm that builds the portable C implementations - the same source set the Darwin arms already use, since those are no-asm builds too - against a hand-written generic `buildinf.h`, with the endianness taken from `CMAKE_CXX_BYTE_ORDER`. An unrecognized architecture now selects it by itself, so a new port gets a working (if slower) libcrypto instead of a link failure. Some targets, WebAssembly for one, have no assembler at all and can only build this way. The same arm can be selected explicitly with `-DOPENSSL_NO_ASM=1`, which is how it was tested: an x86_64 build with that flag links no `.s` object at all, and `SHA1`/`SHA256`/`SHA512`/`MD5`/`keccak256`, AES-GCM and AES-CBC round trips and an HTTPS fetch through `url()` all give the same answers as the assembly build. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [e67d8f6] Summary: ✅
AI ReviewSummaryThis PR adds a generic Findings❌ Blockers
Final VerdictChanges requested. The new no-asm mode needs to define the upstream |
| set(OPENSSL_NO_ASM ON) | ||
| endif() | ||
|
|
||
| if(OPENSSL_NO_ASM) |
There was a problem hiding this comment.
The new OPENSSL_NO_ASM mode never defines the upstream OPENSSL_NO_ASM preprocessor macro; it only swaps the source list. That means the "no-asm" build still takes inline-assembly paths in the pinned OpenSSL sources, e.g. include/crypto/modes.h, include/internal/constant_time.h, crypto/chacha/chacha_enc.c, and crypto/bn/bn_div.c, so -DOPENSSL_NO_ASM=1 does not actually give the portable C configuration this option promises. Please add -DOPENSSL_NO_ASM in this branch as well, otherwise the new flag remains incomplete and the "no assembler" target the PR description talks about is still exposed to asm-dependent code.
contrib/openssl-cmakepicks aPLATFORM_DIRECTORYand the AES/BN/SHA/... implementations from a per-architectureif/elseifchain. An architecture the chain does not know about matches nothing: nobuildinf.hinclude directory, and not one of the crypto cores gets compiled. The build then runs all the way to the final link before failing on undefinedOPENSSL_cleanseand friends, which says nothing about what is actually wrong.This adds a no-asm arm that builds the portable C implementations - the same source set the Darwin arms already use, since those are no-asm builds too - against a hand-written generic
buildinf.h, with the endianness taken fromCMAKE_CXX_BYTE_ORDER. An unrecognized architecture now selects it by itself, so a new port gets a working (if slower) libcrypto instead of a link failure. Some targets, WebAssembly for one, have no assembler at all and can only build this way.The same arm can be selected explicitly with
-DOPENSSL_NO_ASM=1, which is how it was tested: an x86_64 build with that flag links no.sobject at all, andSHA1/SHA256/SHA512/MD5/keccak256, AES-GCM and AES-CBC round trips and an HTTPS fetch throughurl()all give the same answers as the assembly build.Default builds are unaffected - every architecture with a build description here takes the same arm as before.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
OpenSSL can now be built from its portable C sources on architectures that have no hand-written assembly in the build description, instead of failing at the final link with undefined symbols. The new
OPENSSL_NO_ASMCMake option selects the same path explicitly.Documentation entry for user-facing changes