php.extensions.readline: Actually use readline
Building readline extension would say: checking for libedit readline replacement... yes, shared even when configuring `--without-libedit`. This is because `PHP_ARG_WITH(libedit, …)`, internally calls `PHP_ALWAYS_SHARED`, which in `phpize`-generated `configure.ac` is defined as always forcing the value to shared. This will prevent `PHP_ARG_WITH(readline, …)` from being invoked so `READLINE_DIR` variable will never be defined. This was not an issue before we split the extension out of php.unwrapped in282337799b
, as `PHP_ALWAYS_SHARED` is empty there. ----- Additionally, because the build script passed `-L$READLINE_DIR/lib` as a flag to the compiler on PHP < 7.4 (built by the nix-phps repository), this ended up with a FHS-like path being passed to the linker. And once we bumped GCC to 11 in52f8cf58a4
, the linker would fail: gcc -shared .libs/readline.o .libs/readline_cli.o -Wl,--rpath -Wl,/lib -L/lib -ledit -lncurses -Wl,-soname -Wl,readline.so -o .libs/readline.so impure path `/lib' used in link collect2: error: ld returned 1 exit status This no longer happens with PHP ≥ 7.4, since they switched to getting the linker flags from pkg-config inb537203d20
. ---- As a compromise, let’s make the `PHP_ALWAYS_SHARED` function force `shared` status but only for flags that are not disabled. That will allow us to remove the libedit dependency and also the nasty patch for configure script due to `--with-libedit` not being passed (which would be required for PHP < 7.4 to be able to find readline.h from libedit). Thanks to Pol Dellaiera for both bisections.
This commit is contained in:
parent
03e31c533c
commit
9cdbd72004
|
@ -19,7 +19,6 @@
|
|||
, html-tidy
|
||||
, icu64
|
||||
, libXpm
|
||||
, libedit
|
||||
, libffi
|
||||
, libiconv
|
||||
, libjpeg
|
||||
|
@ -542,10 +541,23 @@ lib.makeScope pkgs.newScope (self: with self; {
|
|||
{ name = "pspell"; configureFlags = [ "--with-pspell=${aspell}" ]; }
|
||||
{
|
||||
name = "readline";
|
||||
buildInputs = [ libedit readline ];
|
||||
configureFlags = [ "--with-readline=${readline.dev}" ];
|
||||
postPhpize = lib.optionalString (lib.versionOlder php.version "7.4") ''
|
||||
substituteInPlace configure --replace 'as_fn_error $? "Please reinstall libedit - I cannot find readline.h" "$LINENO" 5' ':'
|
||||
buildInputs = [
|
||||
readline
|
||||
];
|
||||
configureFlags = [
|
||||
"--with-readline=${readline.dev}"
|
||||
];
|
||||
postPatch = ''
|
||||
# Fix `--with-readline` option not being available.
|
||||
# `PHP_ALWAYS_SHARED` generated by phpize enables all options
|
||||
# without the possibility to override them. But when `--with-libedit`
|
||||
# is enabled, `--with-readline` is not registered.
|
||||
echo '
|
||||
AC_DEFUN([PHP_ALWAYS_SHARED],[
|
||||
test "[$]$1" != "no" && ext_shared=yes
|
||||
])dnl
|
||||
' | cat - ext/readline/config.m4 > ext/readline/config.m4.tmp
|
||||
mv ext/readline/config.m4{.tmp,}
|
||||
'';
|
||||
doCheck = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue