Bug #79092 [NEW]: Building with clang+lld-9 results in a broken PHP binary

From: Date: Fri, 10 Jan 2020 04:47:15 +0000
Subject: Bug #79092 [NEW]: Building with clang+lld-9 results in a broken PHP binary
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224821@lists.php.net to get a copy of this message
From: mike at tedder dot cc Operating system: Ubuntu 19.10 PHP version: 7.4.1 Package: *Compile Issues Bug Type: Bug Bug description:Building with clang+lld-9 results in a broken PHP binary Description: ------------ When building PHP 7.4.1 with clang/llvm-9 and using the lld linker, executing the built php binary results in the following error: /opt/php/bin/php: error while loading shared libraries: cannot apply additional memory protection after relocation: Cannot allocate memory I've traced the cause of this to be due to added support for alignment of segments on huge page boundaries, which passes two extra page-size flags to the linker. This was added to configure.ac in git commit 62ded6e here ( https://github.com/php/php-src/commit/62ded6efbcb41e24a505117f8de5b70d56a98f57 ): EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152" If both of these page-size flags are removed, the resulting PHP binary successfully executes as expected. At this time, I don't know if this is a bug in lld, or if these values are incorrect in some form (possibly GNU ld specific?) and shouldn't be passed by PHP. Below is a Dockerfile to reproduce this issue: ======================================================= FROM ubuntu:19.10 RUN apt-get update && \ apt-get install -y \ autoconf curl gnupg2 lsb-release make \ software-properties-common wget WORKDIR /root RUN wget https://apt.llvm.org/llvm.sh && \ chmod +x llvm.sh && \ ./llvm.sh 9 ARG PHP_VERSION="php-7.4.1" RUN curl -sL https://www.php.net/distributions/${PHP_VERSION}.tar.xz | tar xJv WORKDIR /root/${PHP_VERSION} # uncomment to disable alignment of segments on huge page boundaries in configure.ac to work with clang/lld-9 #RUN sed -i 's/-Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152//g' ./configure.ac && ./buildconf --force ARG CFLAGS="-Oz" ARG LDFLAGS="-fuse-ld=lld-9" RUN CC="clang-9" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure --prefix=/opt/php --disable-cgi --disable-all && \ make -j $(nproc) && \ make install RUN echo "<?php phpinfo();" | /opt/php/bin/php ======================================================= -- Edit bug report at https://bugs.php.net/bug.php?id=79092&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79092&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79092&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79092&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79092&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79092&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79092&r=support Expected behavior: https://bugs.php.net/fix.php?id=79092&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79092&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79092&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79092&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79092&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79092&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79092&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79092&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79092&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79092&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79092&r=mysqlcfg

« previous php.bugs (#224821) next »