Fix GH-20920: fix build with LibreSSL - #23689
Open
gvozdetsky wants to merge 2 commits into
Open
gvozdetsky wants to merge 2 commits into
gvozdetsky wants to merge 2 commits into
Conversation
The call was guarded by #ifndef OPENSSL_NO_ENGINE until the v1/v3 backend split in d662ab5 moved it from ext/openssl/openssl.c into ext/openssl/openssl_backend_v1.c, where only the surrounding #ifdef LIBRESSL_VERSION_NUMBER was kept. LibreSSL defines OPENSSL_NO_ENGINE, so <openssl/engine.h> is not included and ENGINE_cleanup() ends up being called without a prototype. That is a warning with older compilers and an error with GCC 14 and later, which default to C23. Restore the guard so that the call matches the condition of its include.
PKCS7_NO_DUAL_CONTENT was only added in LibreSSL 4.3.0, so the generated registration in openssl_arginfo.h fails to compile against older releases. Guard the constant on the macro itself rather than on LIBRESSL_VERSION_NUMBER so that LibreSSL 4.3.0 and later, which added the macro in response to this report, keep exposing the constant.
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20920.
Supersedes #20932 — thanks to @jordikroon for the original patch and for
letting me pick this up.
This addresses two of the three LibreSSL build failures reported in GH-20920,
one commit each.
1.
ENGINE_cleanup()called without a prototypeThe call used to be guarded by
#ifndef OPENSSL_NO_ENGINE. The v1/v3 backendsplit in d662ab5 moved it from
ext/openssl/openssl.cintoext/openssl/openssl_backend_v1.cand kept only the surrounding#ifdef LIBRESSL_VERSION_NUMBER. LibreSSL definesOPENSSL_NO_ENGINE, so<openssl/engine.h>is not included and the call is compiled without aprototype — a warning with older compilers, an error with GCC 14 and later,
which default to C23. That is what @bkuhls hit with gcc15.
This restores the guard, so the call matches the condition of its include,
as suggested by @botovq.
2.
PKCS7_NO_DUAL_CONTENTis not always availableThe constant was only added in LibreSSL 4.3.0. Following @sthen's suggestion,
it is guarded on the macro itself rather than on
LIBRESSL_VERSION_NUMBER, sothat LibreSSL 4.3.0 and later — which added the macro in response to this very
report (openbsd/src@a7d6713) — keep exposing it.
Testing
Built with
--enable-debug --enable-ztsagainst LibreSSL 4.2.1 and 4.3.2(both built from source) and against OpenSSL 3.0.13:
PHP-8.5and compiles cleanly withthis PR.
ext/openssltests is identicalwith and without this PR (26 pre-existing LibreSSL incompatibilities:
removed TLS 1.0/1.1, DH/DSA differences,
openssl_error_string()formats,security_level). So this PR neither fixes nor breaks any of them.(
PKCS7_NO_DUAL_CONTENT === 65536), confirming the macro-based guard.ext/openssl214 passed, 0 failed, 15 skipped — nobehaviour change, since
OPENSSL_NO_ENGINEis not defined there and theconstant exists.
This is not sufficient on its own
Linking still fails under LibreSSL with:
#21430 fixes that, and it is needed on
PHP-8.5as well, not only onmaster.With #21430 applied on top of this PR, the build against LibreSSL 4.2.1
completes successfully.
@bkuhls, @bneumeier — could you confirm this matches what you see on your
LibreSSL setups?