php / php/php-src

mysqlnd depends on openssl when build shared

Open
#18,003 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Category: Build System Extension: mysqlnd Extension: openssl
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

I am building every PHP extension shared like

./configure
   --enable-mysqlnd=shared \
  --with-openssl=shared \
...

When I now load only PHP + mysqlnd, I get the following errors

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd.so' (tried: /usr/lib/php/modules/mysqlnd.so (/usr/lib/php/modules/mysqlnd.so: undefined symbol: EVP_PKEY_CTX_new), /usr/lib/php/modules/mysqlnd.so.so (/usr/lib/php/modules/mysqlnd.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

This seems to happen because of https://github.com/php/php-src/blob/master/ext/mysqlnd/config9.m4#L12-L20

I think here are two ways how this can be fixed:

Don't enable that option when openssl is shared or link mysqlnd to libcrypto.so because LD_PRELOAD=/usr/lib/libcrypto.so.3 php -v fixes it to fix up the implict library

PHP Version

PHP 8.3.17

Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ext/mysqlnd/config9.m4, especially the lines linked in the issue, and reproduce the shared-extension build using --enable-mysqlnd=shared and --with-openssl=shared. Inspect the resulting mysqlnd.so dependencies and loader error. Done means PHP can load only PHP plus mysqlnd without the undefined EVP_PKEY_CTX_new symbol, without relying on LD_PRELOAD.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.