Skip to content

Conversation

mizunashi-mana
Copy link
Contributor

@mizunashi-mana mizunashi-mana commented Oct 18, 2018

resolve https://bugs.php.net/bug.php?id=77011

From Mojave (macOS 10.14), it was deprecated /usr/include and we should use SDK paths explicitly: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624.
Although we can restore /usr/include by /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg,

In a future release, this package will no longer be provided.

Therefore, we should support SDK paths for users building PHP from sources (e.g. Homebrew, php-build, phpbrew and etc.) Because the shared libraries of SDK paths use .tbd as file extension, we also should support new extension; .tbd.

This patch includes .tbd and SDK paths support and some fixes to resolve prefix correctly.

I tested this patch in some situations:

On macOS Mojave with configure options of php-build:

brew update && brew install pkg-config autoconf \
  openssl \
  icu4c \
  re2c \
  bison \
  libzip
export PATH="$(brew --prefix bison)/bin:$PATH"
make clean
./buildconf --force
./configure \
  --without-pear \
  --enable-bcmath \
  --enable-cgi \
  --enable-exif \
  --enable-fpm \
  --enable-ftp \
  --enable-intl \
  --enable-mbstring \
  --enable-pcntl \
  --enable-phpdbg \
  --enable-shmop \
  --enable-soap \
  --enable-sockets \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-xmlreader \
  --enable-zip \
  --disable-debug \
  --with-bz2 \
  --with-curl \
  --with-freetype-dir \
  --with-gd \
  --with-jpeg-dir \
  --with-kerberos \
  --with-libzip \
  --with-mysqli=mysqlnd \
  --with-openssl=$(brew --prefix openssl) \
  --with-pdo-mysql=mysqlnd \
  --with-pdo-sqlite \
  --with-tidy \
  --with-webp-dir \
  --with-xmlrpc \
  --with-xpm-dir \
  --with-xsl \
  --with-zlib \
  --with-zlib-dir \
  --with-libedit \
  --with-png-dir \
  --with-icu-dir=$(brew --prefix icu4c)
make

On macOS Mojave with configure options of Homebrew's php formula:

brew update && brew install pkg-config autoconf \
  openssl \
  re2c \
  bison \
  httpd \
  argon2 \
  aspell \
  freetds \
  freetype \
  gettext \
  gmp \
  icu4c \
  libpq \
  libsodium \
  openldap \
  unixodbc
export PATH="$(brew --prefix bison)/bin:$PATH"
make clean
./buildconf --force
./configure \
  --enable-bcmath \
  --enable-calendar \
  --enable-dba \
  --enable-dtrace \
  --enable-exif \
  --enable-ftp \
  --enable-fpm \
  --enable-intl \
  --enable-mbregex \
  --enable-mbstring \
  --enable-mysqlnd \
  --enable-opcache-file \
  --enable-pcntl \
  --enable-phpdbg \
  --enable-phpdbg-webhelper \
  --enable-shmop \
  --enable-soap \
  --enable-sockets \
  --enable-sysvmsg \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-wddx \
  --enable-zip \
  --with-apxs2=$(brew --prefix httpd)/bin/apxs \
  --with-bz2 \
  --with-fpm-user=_www \
  --with-fpm-group=_www \
  --with-freetype-dir=$(brew --prefix freetype) \
  --with-gd \
  --with-gettext=$(brew --prefix gettext) \
  --with-gmp=$(brew --prefix gmp) \
  --with-icu-dir=$(brew --prefix icu4c) \
  --with-jpeg-dir \
  --with-kerberos \
  --with-layout=GNU \
  --with-ldap=$(brew --prefix openldap) \
  --with-ldap-sasl \
  --with-libxml-dir \
  --with-libedit \
  --with-libzip \
  --with-mhash \
  --with-mysql-sock=/tmp/mysql.sock \
  --with-mysqli=mysqlnd \
  --with-ndbm \
  --with-openssl=$(brew --prefix openssl) \
  --with-password-argon2=$(brew --prefix argon2) \
  --with-pdo-dblib=$(brew --prefix freetds) \
  --with-pdo-mysql=mysqlnd \
  --with-pdo-odbc=unixODBC,$(brew --prefix unixodbc) \
  --with-pdo-pgsql=$(brew --prefix libpq) \
  --with-pdo-sqlite \
  --with-pgsql=$(brew --prefix libpq) \
  --with-pic \
  --with-png-dir \
  --with-pspell=$(brew --prefix aspell) \
  --with-sodium=$(brew --prefix libsodium) \
  --with-sqlite3 \
  --with-unixODBC=$(brew --prefix unixodbc) \
  --with-webp-dir \
  --with-xmlrpc \
  --with-xsl \
  --with-zlib \
  --with-curl \
  --with-iconv
make

On docker debian stable(stretch) image with configure options of php-build:

apt update && apt install -y make autoconf gcc g++ pkg-config \
  libc-dev \
  bison \
  re2c \
  libbz2-dev \
  libcurl4-openssl-dev \
  libedit-dev \
  libfreetype6-dev \
  libicu-dev \
  libjpeg62-turbo-dev \
  libpng-dev \
  libsqlite3-dev \
  libssl-dev \
  libtidy-dev \
  libwebp-dev \
  libxml2-dev \
  libxpm-dev \
  libxslt1-dev \
  libzip-dev \
  zlib1g-dev
make clean
./buildconf --force
./configure \
  --without-pear \
  --enable-bcmath \
  --enable-cgi \
  --enable-exif \
  --enable-fpm \
  --enable-ftp \
  --enable-intl \
  --enable-mbstring \
  --enable-pcntl \
  --enable-phpdbg \
  --enable-shmop \
  --enable-soap \
  --enable-sockets \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-xmlreader \
  --enable-zip \
  --disable-debug \
  --with-bz2 \
  --with-curl \
  --with-freetype-dir \
  --with-gd \
  --with-jpeg-dir \
  --with-kerberos \
  --with-libzip \
  --with-mysqli=mysqlnd \
  --with-openssl \
  --with-pdo-mysql=mysqlnd \
  --with-pdo-sqlite \
  --with-tidy \
  --with-webp-dir \
  --with-xmlrpc \
  --with-xpm-dir \
  --with-xsl \
  --with-zlib \
  --with-zlib-dir \
  --with-libedit \
  --with-png-dir
make

@php-pulls
Copy link

Comment on behalf of petk at php.net:

Labelling... Thank you for the pull request @mizunashi-mana

@mizunashi-mana
Copy link
Contributor Author

P.S.
Apple released XCode 10.1 . This includes re Unix-style shared library support; restoring /usr/include.
I updated XCode, so, I lost test instances for this PR.

@javian
Copy link

javian commented Nov 24, 2018

@mizunashi-mana that seems to have been a temporary glitch by Apple and it shouldn't happen anymore from what I've heard

@carusogabriel
Copy link
Contributor

I guess this one will also fix https://bugs.php.net/bug.php?id=77342.

@nikic
Copy link
Member

nikic commented Feb 19, 2019

We are currently porting library detection code to rely exclusively on pkg-config (not all extensions are ported yet). I believe that will also resolve this issue, right?

@mizunashi-mana
Copy link
Contributor Author

@nikic I agree and that is better solution.

@petk
Copy link
Member

petk commented Sep 8, 2019

Hello. So, currently on macOS systems PHP can be installed thanks to the awesome brew packages which contain patches to bypass these annoyances. Otherwise, the default macOS installation goes through with minor adjustments for the PHP 7.4 (via configure options). And in the future macOS versions (Catalina) this won't work anymore if I'm not mistaken due to not using the /usr/include at all?

I'd suggest to apply something like https://github.com/kabel/php-src/commit/0e000cc9ab94008f5554514ef5014ef892c3279b to PHP-7.4+ but with a bit more automation behind (using a configure option is a nice trick but a bit redundant if such location can be determined by the build system). Maybe what this pull request does. We'll need to adjust only few extensions now due to the pkg-config usage except the ones where include path needs change.

As irresponsible as it sounds, I wouldn't patch PHP 7.3 and 7.2 due to already good patches in the brew system and too messy code in there that can break everything even with a minor fix...

Thank you @kabel and @javian for helping out here with current pull requests and bug reports in this direction... Let me check what I can come up with here.

@GrahamCampbell
Copy link
Contributor

Ping.

@nikic
Copy link
Member

nikic commented Dec 13, 2019

@GrahamCampbell What's the current state of this issue? pkg-config migration should have obsoleted the majority of this patch, but I don't know what is still relevant here.

@mizunashi-mana
Copy link
Contributor Author

Sorry, I have less time now...

There are many changes from this PR. We should survey current status for this problem with PHP 7.4+ before discussion how to patch completely. However, I can't do...

@krakjoe
Copy link
Member

krakjoe commented May 11, 2021

Our current position is that this is better solved on a case by case basis using the improved pkg-config support we use/have, in addition this appears to have gone stale, and the author backed out because of time constraints, so closing now.

@krakjoe krakjoe closed this May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants