Skip to content

Expose os, compiler, arch in php -v #19328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Jul 31, 2025

See #19256

The bug system requires the output of php -v when reporting bugs. Exposing more information in php -v can be useful.

PHP_BUILD_COMPILER and PHP_BUILD_ARCH are always defined in Windows build, or when defined in the environment during the build (#5834). In other cases I determine these from compiler macros.

Output examples: #19328 (comment)

Outdated examples
PHP 8.5.0-dev (cli) (built: Jul 31 2025 11:18:32) (NTS DEBUG x86_64) (Linux 6.15.8-200.fc42.x86_64 Clang 20.1.8 (Fedora 20.1.8-1.fc42))
Copyright (c) The PHP Group
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies
PHP 8.5.0-dev (cli) (built: Jul 31 2025 11:29:06) (ZTS DEBUG x64) (Windows NT 10.0 Visual C++ 2022)
Copyright (c) The PHP Group
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

@remicollet
Copy link
Member

remicollet commented Jul 31, 2025

Can be confusing to report both

  • build-time information (GCC, ...)
  • run-time information (from uname)

This information already in php -i

System => Linux builder.remirepo.net 6.15.8-100.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:25:37 UTC 2025 x86_64
Build Date => Jul 29 2025 15:48:33
Build System => Fedora release 41 (Forty One)
Build Provider => Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine
Compiler => gcc (GCC) 14.3.1 20250523 (Red Hat 14.3.1-1)

Notice PHP_BUILD_COMPILER can be very long, which is OK in phpinfo, but not in php -v (I use a local patch to only display "GCC" there)

IMHO, PHP_BUILD_PROVIDER (Fedora ...) when set is more useful that uname output (Linux... ), and both can be long

@arnaud-lb
Copy link
Member Author

Can be confusing to report both

* build-time information (GCC, ...)
* run-time information (from uname)

Agreed. I've updated the branch to use only build-time information.

This information already in php -i

I feel this is less convenient than php -v for the purpose of bug reporting. The full output of php -i is very large, and may expose too much, so it must be filtered / edited.

Notice PHP_BUILD_COMPILER can be very long, which is OK in phpinfo, but not in php -v (I use a local patch to only display "GCC" there)

The compiler version can be useful to analyze bugs, as some features may only be enabled on some versions. This is the primary reason I'm interested in making this change. Just the major version would be fine, however.

IMHO, PHP_BUILD_PROVIDER (Fedora ...) when set is more useful that uname output (Linux... ), and both can be long

I've updated the output of php -v as follows:

Without PHP_BUILD_PROVIDER:

PHP 8.5.0-dev (cli) (built: Aug  4 2025 11:29:59) (NTS DEBUG x64)
Copyright (c) The PHP Group
Built on Linux 6.15.9-201.fc42.x86_64 (GCC 15)
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

With PHP_BUILD_PROVIDER:

PHP 8.5.0-dev (cli) (built: Aug  4 2025 11:31:50) (NTS DEBUG x64)
Copyright (c) The PHP Group
Built by Fedora Project (Clang 20)
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

@remicollet
Copy link
Member

With PHP_BUILD_PROVIDER:

Sorry, I was wrong in my previous comment, I think we need to use PHP_BUILD_SYSTEM (ie "Fedora release 42") not PHP_BUILD_PROVIDER (Fedora project)

Provider is already part on php -v
So a new line for build system, ex:

PHP 8.5.0-dev (cli) (built: Aug  4 2025 11:31:50) (NTS DEBUG x64)
Copyright (c) The PHP Group
Built on Fedora release 41 (Forty One) using gcc (GCC) 14.3.1 20250523 (Red Hat 14.3.1-1)      <= this is System and Compiler
Built by Fedora Project         <= this is the provider
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

main/main.c Outdated
}
smart_string_append_printf(&version_info, "Built %s\n",
#ifdef PHP_BUILD_PROVIDER
"by " PHP_BUILD_PROVIDER
Copy link
Member

@remicollet remicollet Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP_BUILD_PROVIDER should always be there (built by)

And condition for PHP_BUILD_SYSTEM or PHP_UNAME_S + PHP_UNAME_R (built on)

@arnaud-lb
Copy link
Member Author

arnaud-lb commented Aug 4, 2025

Sorry I've just pushed an update before seeing your latest comments: I've updated the branch to use only information provided by the compiler, rather than by uname (event at build time), as the latter would be wrong when cross-compiling (including when compiling for x86 on a x64 machine):

PHP 8.5.0-dev (cli) (built: Aug  4 2025 14:19:05) (NTS DEBUG x64 Linux GCC 15)
Copyright (c) The PHP Group
Built by Fedora Project
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

This is also a bit shorter, less detailed but always correct.

One issue with PHP_BUILD_SYSTEM is that it really reflects the system used to build, rather than the target system. So when cross compiling (or just compiling for x86 on a x64 machine) it will be wrong.

Edit: Adding "Built on $PHP_BUILD_SYSTEM" would be correct, as we say "Built on". I'm fine adding this line in addition to the rest.

@remicollet
Copy link
Member

Edit: Adding "Built on $PHP_BUILD_SYSTEM" would be correct, as we say "Built on". I'm fine adding this line in addition to the rest.

Probably not mandatory, php -v is already long (and we have php -i)

@NattyNarwhal
Copy link
Member

NattyNarwhal commented Aug 4, 2025

FWIW, at least with users I support, they seem to use php -v more than phpinfo/-i for reporting things. For example, I added the build provider bit, because they saw Zend Engine in the output and thought they were using builds provided by Zend. For the sake of our bug tracker, -v is a lot more frequently used, and it's quicker to go through.

@arnaud-lb arnaud-lb marked this pull request as ready for review August 5, 2025 07:43
@arnaud-lb arnaud-lb requested a review from bukka as a code owner August 5, 2025 07:43
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.

5 participants