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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arnaud-lb
Copy link
Member

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:

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

@@ -121,26 +121,36 @@ ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void)

PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
{
zend_string *os = php_get_uname('s');
Copy link
Member

Choose a reason for hiding this comment

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

Can you not use the PHP_OS_FAMILY C macro constant here?


#ifndef PHP_BUILD_ARCH
# if defined(__x86_64__)
# define PHP_BUILD_ARCH "x86_64"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# define PHP_BUILD_ARCH "x86_64"
# define PHP_BUILD_ARCH "x64"

@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

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.

4 participants