Skip to content

LibreSSL build regression with PHP 8.5 #20920

Done

Description

@bneumeier

Description

I maintain a source-based Linux distribution, and strive to use the latest stable release of everything as much as possible. I have LibreSSL 4.2.1 on my build server (as well as, in cast it matters, MariaDB 12.1.2, libgd 2.3.3, libpng 1.6.53, libjpeg 9f, libzip 1.11.4, oniguruma 6.9.10, and ICU 78.1).

I configure PHP with:

./configure --prefix=/opt/php --sysconfdir=/etc/php --with-config-file-scan-dir=/etc/php.d --enable-fpm --with-mysqli --with-pdo-mysql=/opt/mariadb --with-layout=GNU --enable-libgcc --with-openssl --with-external-pcre --with-zlib --with-bz2 --with-gmp --with-gettext --with-readline --with-xsl --with-pear --enable-mbstring --enable-exif --with-curl --enable-gd --enable-intl --with-zip

With PHP 8.4.16, the build runs to completion and works fine.
With PHP 8.5.1, the build terminates when compiling the openssl extension, specifically with:

------cut here------
/bin/sh /home/lbl/php-8.5.1/libtool --silent --preserve-dup-deps --tag=CC --mode=compile cc -Iext/openssl/ -I/home/lbl/php-8.5.1/ext/openssl/ -I/home/lbl/php-8.5.1/main -I/home/lbl/php-8.5.1 -I/home/lbl/php-8.5.1/ext/date/lib -I/usr/incl
ude/libxml2 -I/usr/include/libpng16 -I/home/lbl/php-8.5.1/ext/lexbor -I/home/lbl/php-8.5.1/ext/mbstring/libmbfl -I/home/lbl/php-8.5.1/ext/mbstring/libmbfl/mbfl -I/opt/mariadb/include/mysql -I/opt/mariadb/include/mysql/mysql -I/home/lbl/p
hp-8.5.1/ext/uri/uriparser/include -I/home/lbl/php-8.5.1/TSRM -I/home/lbl/php-8.5.1/Zend -D_GNU_SOURCE -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-paramete
r -Wno-sign-compare -g -O2 -ffp-contract=off -fvisibility=hidden -DNDEBUG -Wimplicit-fallthrough=1 -DZEND_SIGNALS -c /home/lbl/php-8.5.1/ext/openssl/openssl.c -o ext/openssl/openssl.lo -MMD -MF ext/openssl/openssl.dep -MT ext/openssl/openssl.lo
In file included from /home/lbl/php-8.5.1/Zend/zend_execute.h:28,
from /home/lbl/php-8.5.1/Zend/zend_API.h:29,
from /home/lbl/php-8.5.1/main/php.h:35,
from /home/lbl/php-8.5.1/ext/openssl/openssl.c:27:
/home/lbl/php-8.5.1/ext/openssl/openssl_arginfo.h: In function 'register_openssl_symbols':
/home/lbl/php-8.5.1/ext/openssl/openssl_arginfo.h:592:57: error: 'PKCS7_NO_DUAL_CONTENT' undeclared (first use in this function); did you mean 'PKCS7_R_NO_CONTENT'?
592 | REGISTER_LONG_CONSTANT("PKCS7_NO_DUAL_CONTENT", PKCS7_NO_DUAL_CONTENT, CONST_PERSISTENT);
| ^~~~~~~~~~~~~~~~~~~~~
/home/lbl/php-8.5.1/Zend/zend_constants.h:64:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
64 | #define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
| ^~~~
/home/lbl/php-8.5.1/ext/openssl/openssl_arginfo.h:592:57: note: each undeclared identifier is reported only once for each function it appears in
------cut here------

If there's any additional information I can provide, or tests I can perform that would be helpful, I would be happy to do so!

PHP Version

PHP 8.5.1, from source archive.

Operating System

Linux 6.18.2 SMP PREEMPT_DYNAMIC Thu Jan 8 01:48:41 -00 2026 x86_64 GNU/Linux

Activity

  1. bneumeier commented on Jan 13, 2026

    @bneumeier
    Author

    OK, looking into this further there are two issues:

    1. LibreSSL does not publish PKCS7_NO_DUAL_CONTENT. For my purposes, this is not important, so it makes sense to simply elide that declaration when using LibreSSL.
    2. PHP invokes the function ENGINE_cleanup, which has been deprecated for a long time in OpenSSL and removed entirely in LibreSSL.

    here's the patch I'm using to work around the issues.

    [PATCH] Allow building with LibreSSL

    • LibreSSL does not publish PKCS7_NO_DUAL_CONTENT
    • ENGINE_cleanup has been deprecated for a long time in OpenSSL, and
      removed entirely in LibreSSL, so there's no need to call it.

    ext/openssl/openssl_arginfo.h | Bin 44480 -> 44525 bytes
    ext/openssl/openssl_backend_v1.c | 2 ++
    2 files changed, 2 insertions(+)

    diff --git a/ext/openssl/openssl_arginfo.h b/ext/openssl/openssl_arginfo.h
    index 796582c1..1f7a727d 100644
    --- a/ext/openssl/openssl_arginfo.h
    +++ b/ext/openssl/openssl_arginfo.h
    @@ -589,7 +589,9 @@ static void register_openssl_symbols(int module_number)
    REGISTER_LONG_CONSTANT("PKCS7_NOSMIMECAP", PKCS7_NOSMIMECAP, CONST_PERSISTENT);
    REGISTER_LONG_CONSTANT("PKCS7_CRLFEOL", PKCS7_CRLFEOL, CONST_PERSISTENT);
    REGISTER_LONG_CONSTANT("PKCS7_NOCRL", PKCS7_NOCRL, CONST_PERSISTENT);
    +#if !defined(LIBRESSL_VERSION_NUMBER)
    REGISTER_LONG_CONSTANT("PKCS7_NO_DUAL_CONTENT", PKCS7_NO_DUAL_CONTENT, CONST_PERSISTENT);
    +#endif
    REGISTER_LONG_CONSTANT("OPENSSL_CMS_DETACHED", CMS_DETACHED, CONST_PERSISTENT);
    REGISTER_LONG_CONSTANT("OPENSSL_CMS_TEXT", CMS_TEXT, CONST_PERSISTENT);
    REGISTER_LONG_CONSTANT("OPENSSL_CMS_NOINTERN", CMS_NOINTERN, CONST_PERSISTENT);
    diff --git a/ext/openssl/openssl_backend_v1.c b/ext/openssl/openssl_backend_v1.c
    index 87346457..18fc5617 100644
    --- a/ext/openssl/openssl_backend_v1.c
    +++ b/ext/openssl/openssl_backend_v1.c
    @@ -51,8 +51,10 @@ void php_openssl_backend_shutdown(void)
    /* prevent accessing locking callback from unloaded extension */
    CRYPTO_set_locking_callback(NULL);

    +#if !defined(LIBRESSL_VERSION_NUMBER)
    /* Free engine list initialized by OPENSSL_config */
    ENGINE_cleanup();
    +#endif

    /* free allocated error strings */
    ERR_free_strings();
    

    --
    2.52.0

  2. botovq commented on Jan 14, 2026

    @botovq
    Contributor

    We added PKCS7_NO_DUAL_CONTENT to LibreSSL because of this, so any behavior difference should be resolved in the next release: openbsd/src@a7d6713 .

    FWIW, we still have an ENGINE_cleanup() stub because a few things still call it (they don't check for OPENSSL_NO_ENGINE, which we define). AFAICS its prototype isn't available in the PHP build because #include <openssl/engine.h> is knocked out by OPENSSL_NO_ENGINE:

    #if defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_ENGINE)
    #include <openssl/engine.h>
    #endif

    Cc @sthen

  3. bneumeier commented on Jan 14, 2026

    @bneumeier
    Author

    That is great to know, thanks @botovq !

  4. sthen commented on Jan 15, 2026

    @sthen

    btw, "if defined(PKCS7_NO_DUAL_CONTENT)" would be a better conditional if you do want to allow building 8.5 on older libressl.

  5. bkuhls commented on May 12, 2026

    @bkuhls
    Contributor

    Trying to build libressl 4.2.1 and php 8.5.6 from source (buildroot/linux/gcc15) showed several build errors.

    We added PKCS7_NO_DUAL_CONTENT to LibreSSL because of this, so any behavior difference should be resolved in the next release: openbsd/src@a7d6713 .

    Thanks, this fixes one of them. #21430 fixes another build error.

    FWIW, we still have an ENGINE_cleanup() stub because a few things still call it (they don't check for OPENSSL_NO_ENGINE, which we define). AFAICS its prototype isn't available in the PHP build because #include <openssl/engine.h> is knocked out by OPENSSL_NO_ENGINE:

    php-src/ext/openssl/openssl_backend_v1.c

    Lines 26 to 28 in 858d34f
    #if defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_ENGINE)
    #include <openssl/engine.h>
    #endif

    This is the last build error here. This commit initially added "&& !defined(OPENSSL_NO_ENGINE)".
    Changing "&&" into "||" fixes the build error for example but I have no idea whether this is correct or not.

  6. botovq commented on May 12, 2026

    @botovq
    Contributor

    Thanks.

    #21430 fixes another build error.

    As I mentioned there, this was the motivation behind that PR.

    Changing && to || would of course work around the problem. The better and correct fix would be to guard the ENGINE_cleanup() call again with #ifndef OPENSSL_NO_ENGINE (like that commit originally did).

  7. changed the title [-]Build regression with PHP 8.5[/-] [+]LibreSSL build regression with PHP 8.5[/+] on Nov 24, 2026
  8. added 5 commits that reference this issue on Nov 24, 2026
    cdbba57
    3a956d9
    686bf38
    6e44b00
    0c6b9e2
  9. added a commit that references this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions