Opened 2 years ago

Closed 8 months ago

#64758 closed defect (fixed)

php* +universal: php-config* differs and cannot be merged

Reported by: claviola (Carlos Laviola) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc: kencu (Ken)
Port: php

Description

--->  Building php80
--->  Staging php80 into destroot
Error: Failed to destroot php80: php-config80 differs in /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-arm64//opt/local/bin and /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-ppc-intel//opt/local/bin and cannot be merged
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port php80 failed
❯ diff -urN /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-arm64//opt/local/bin/php-config80 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-ppc-intel//opt/local/bin/php-config80
--- /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-arm64//opt/local/bin/php-config80        2022-03-02 21:16:24.000000000 +0100
+++ /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php80/work/destroot-ppc-intel//opt/local/bin/php-config80 2022-03-02 21:16:15.000000000 +0100
@@ -17,7 +17,7 @@
 exe_extension=""
 php_cli_binary=NONE
 php_cgi_binary=NONE
-configure_options=" '--prefix=/opt/local' '--mandir=/opt/local/share/man' '--infodir=/opt/local/share/info' '--program-suffix=80' '--includedir=/opt/local/include/php80' '--libdir=/opt/local/lib/php80' '--with-config-file-path=/opt/local/etc/php80' '--with-config-file-scan-dir=/opt/local/var/db/php80' '--disable-all' '--enable-bcmath' '--enable-ctype' '--enable-dom' '--enable-filter' '--enable-json' '--enable-pdo' '--enable-session' '--enable-simplexml' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-bz2=/opt/local' '--with-mhash=/opt/local' '--with-zlib=/opt/local' '--disable-cgi' '--enable-cli' '--with-libxml' '--with-external-pcre=/opt/local' '--enable-fileinfo' '--enable-phar' '--disable-fpm' '--with-password-argon2=/opt/local' '--without-valgrind' '--with-libedit' '--host=aarch64-apple-darwin21.3.0' 'host_alias=aarch64-apple-darwin21.3.0'"
+configure_options=" '--prefix=/opt/local' '--mandir=/opt/local/share/man' '--infodir=/opt/local/share/info' '--program-suffix=80' '--includedir=/opt/local/include/php80' '--libdir=/opt/local/lib/php80' '--with-config-file-path=/opt/local/etc/php80' '--with-config-file-scan-dir=/opt/local/var/db/php80' '--disable-all' '--enable-bcmath' '--enable-ctype' '--enable-dom' '--enable-filter' '--enable-json' '--enable-pdo' '--enable-session' '--enable-simplexml' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-bz2=/opt/local' '--with-mhash=/opt/local' '--with-zlib=/opt/local' '--disable-cgi' '--enable-cli' '--with-libxml' '--with-external-pcre=/opt/local' '--enable-fileinfo' '--enable-phar' '--disable-fpm' '--with-password-argon2=/opt/local' '--without-valgrind' '--with-libedit' '--host=x86_64-apple-darwin21.3.0' 'host_alias=x86_64-apple-darwin21.3.0'"
 php_sapis=" cli phpdbg"
 ini_dir="/opt/local/var/db/php80"
 ini_path="/opt/local/etc/php80"

as mentioned in the summary, also happens to php74. I've also tried building as +universal to no avail.

Attachments (1)

muniversal.diff (3.2 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 2 years ago by claviola (Carlos Laviola)

Summary: php74/php80: php-config80 differs and cannot be mergedphp74/php80: php-config differs and cannot be merged

comment:2 Changed 2 years ago by claviola (Carlos Laviola)

Port: php81 added
Summary: php74/php80: php-config differs and cannot be mergedphp74/php80/php81: php-config differs and cannot be merged

comment:3 Changed 2 years ago by jmroot (Joshua Root)

Owner: set to ryandesign
Status: newassigned

comment:4 Changed 2 years ago by claviola (Carlos Laviola)

Note that this was built using +universal. Without it there's no issues building.

comment:5 Changed 2 years ago by kencu (Ken)

usually I just strip out those host differences, as nothing uses them anyway.

see here in ICU where I did that:

https://github.com/macports/macports-ports/blob/e7b89383ad2f042fbab7b5c9622e46a4beef7e91/devel/icu/Portfile#L105

comment:6 Changed 9 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: kencu added
Port: php added; php74 php80 php81 removed
Summary: php74/php80/php81: php-config differs and cannot be mergedphp* +universal: php-config* differs and cannot be merged

Ken, I see that you added code to the muniversal portgroups to automatically strip these differences from scripts. Your code adds rules that:

  1. remove all characters starting from --host= until the next space or end of line,
  2. remove all characters starting from host_alias= until the next space or end of line, and
  3. collapse all runs of two or more spaces into a single space.

Unfortunately this does not take into account two peculiarities of the way these flags are put into the php-config scripts:

  • They are enclosed in single quotation marks
  • One of them is at the end of the string right before the closing quotation mark

See above where the line that begins with configure_options=" ends with '--with-libedit' '--host=aarch64-apple-darwin21.3.0' 'host_alias=aarch64-apple-darwin21.3.0'".

If we apply your first rule, that replaces --host=aarch64-apple-darwin21.3.0' with nothing, leaving us with '--with-libedit' ' 'host_alias=aarch64-apple-darwin21.3.0'". If we apply your second rule, that replaces host_alias=aarch64-apple-darwin21.3.0'" with nothing leaving us with '--with-libedit' ' '. There is now no closing quotation mark on this string, resulting in a syntax error when we try to run the script. However since the same processing was applied to the files of both architectures, the resulting files are the same, and muniversal allows the merge to proceed. The user has now successfully installed a php with the universal variant but the php-config script is broken. All the php module ports that depend on php use the php-config script, so they all now fail to install with a confusing error. This is what happened in #67898.

I was unable to reproduce the issue on my own system because I have an Intel Mac. On my Intel Mac, only the php-config file for the cross-compiled architecture (arm64) got the --host and host_alias flags, so there was still a difference between the files after processing and the merge failed. Only users on Apple Silicon Macs will get a successful erroneous install of php +universal because in an attempt to help broken pre-Apple Silicon config.guess scripts bundled with old software muniversal uses the --host and host_alias flags even for the non-cross-compiled architecture on arm64.

I am also concerned about your third rule. I don't think we should be indiscriminately collapsing multiple spaces into one throughout these merged files. It's true that for shell scripts there's no syntactical difference between one space and multiple spaces, but this replacement happens not only for shell scripts but for any file whose first two characters are #!. This could include python scripts; whitespace is very significant in python. Also, multiple spaces might have been used in user-facing messages for alignment purposes. Taking php-config82 as an example, here is what a properly-working script outputs when you run it:

% php-config82
Usage: /opt/local/bin/php-config82 [OPTION]
Options:
  --prefix            [/opt/local]
  --includes          [-I/opt/local/include/php82/php -I/opt/local/include/php82/php/main -I/opt/local/include/php82/php/TSRM -I/opt/local/include/php82/php/Zend -I/opt/local/include/php82/php/ext -I/opt/local/include/php82/php/ext/date/lib -I/opt/local/include]
  --ldflags           [ -L/opt/local/lib]
  --libs              [  -lresolv -lncurses -lbz2 -lnetwork -lm  -lxml2 -lpcre2-8 -lz -lxml2 -ledit -lxml2 -largon2 -lxml2 -lxml2 -lxml2 -lz ]
  --extension-dir     [/opt/local/lib/php82/extensions/no-debug-non-zts-20220829]
  --include-dir       [/opt/local/include/php82/php]
  --man-dir           [/opt/local/share/man]
  --php-binary        [/opt/local/bin/php82]
  --php-sapis         [ cli phpdbg]
  --ini-path          [/opt/local/etc/php82]
  --ini-dir           [/opt/local/var/db/php82]
  --configure-options [--prefix=/opt/local --mandir=/opt/local/share/man --infodir=/opt/local/share/info --program-suffix=82 --includedir=/opt/local/include/php82 --libdir=/opt/local/lib/php82 --with-config-file-path=/opt/local/etc/php82 --with-config-file-scan-dir=/opt/local/var/db/php82 --disable-all --enable-bcmath --enable-ctype --enable-dom --enable-filter --enable-json --enable-pdo --enable-session --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-zlib=/opt/local --disable-cgi --enable-cli --with-libxml --with-external-pcre=/opt/local --enable-fileinfo --enable-phar --disable-fpm --with-password-argon2=/opt/local --without-valgrind --with-libedit]
  --version           [8.2.8]
  --vernum            [80208]

If I fix the closing quotation mark issue in a php-config82 that has gone through the merging procedure, its output is clearly less desirable:

% sh ./php-config82-broken2
Usage: ./php-config82-broken2 [OPTION]
Options:
 --prefix [/opt/local]
 --includes [-I/opt/local/include/php82/php -I/opt/local/include/php82/php/main -I/opt/local/include/php82/php/TSRM -I/opt/local/include/php82/php/Zend -I/opt/local/include/php82/php/ext -I/opt/local/include/php82/php/ext/date/lib -I/opt/local/include]
 --ldflags [ -L/opt/local/lib]
 --libs [ -lresolv -lncurses -lbz2 -lnetwork -lm -lxml2 -lpcre2-8 -lz -lxml2 -ledit -lxml2 -largon2 -lxml2 -lxml2 -lxml2 -lz ]
 --extension-dir [/opt/local/lib/php82/extensions/no-debug-non-zts-20220829]
 --include-dir [/opt/local/include/php82/php]
 --man-dir [/opt/local/share/man]
 --php-binary [/opt/local/bin/php82]
 --php-sapis [ cli phpdbg]
 --ini-path [/opt/local/etc/php82]
 --ini-dir [/opt/local/var/db/php82]
 --configure-options [--prefix=/opt/local --mandir=/opt/local/share/man --infodir=/opt/local/share/info --program-suffix=82 --includedir=/opt/local/include/php82 --libdir=/opt/local/lib/php82 --with-config-file-path=/opt/local/etc/php82 --with-config-file-scan-dir=/opt/local/var/db/php82 --disable-all --enable-bcmath --enable-ctype --enable-dom --enable-filter --enable-json --enable-pdo --enable-session --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-zlib=/opt/local --disable-cgi --enable-cli --with-libxml --with-external-pcre=/opt/local --enable-fileinfo --enable-phar --disable-fpm --with-password-argon2=/opt/local --without-valgrind --with-libedit]
 --version [8.2.8]
 --vernum [80208]

Changed 9 months ago by ryandesign (Ryan Carsten Schmidt)

Attachment: muniversal.diff added

comment:7 Changed 9 months ago by ryandesign (Ryan Carsten Schmidt)

How does this potential fix look to you? It does the right thing for me for the php82 port, but I haven't tested it on other ports.

comment:8 Changed 9 months ago by kencu (Ken)

LGTM.

comment:9 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

In 3688b879dc21908c240a0ecdad8b28669731b269/macports-ports (master):

muniversal: Remove quoted arch flags correctly

When removing architecture-specific flags, account for the fact that
sometimes (as in php-config) they are in quotation marks.

Also, do not collapse multiple spaces into one because that could result
in erroneous presentation of output (as in php-config) or an
IndentationError (in the case of python scripts).

Fixes and partially reverts c9a6e03fc195486bbc91148a44393ae9f333f109.

Closes: #64758
Closes: #67898

Note: See TracTickets for help on using tickets.