Skip to content

Commit f9df77a

Browse files
committed
Use build-time OS information; expose only compiler major version
1 parent 4ad3a0a commit f9df77a

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,16 @@ AC_ARG_VAR([PHP_UNAME],
14121412
AS_VAR_IF([PHP_UNAME],, [PHP_UNAME=$(uname -a | xargs)])
14131413
AC_DEFINE_UNQUOTED([PHP_UNAME], ["$PHP_UNAME"], [The 'uname -a' output.])
14141414

1415+
AC_ARG_VAR([PHP_UNAME_S],
1416+
[Operating system name (defaults to the 'uname -s' output)])
1417+
AS_VAR_IF([PHP_UNAME_S],, [PHP_UNAME_S=$(uname -s | xargs)])
1418+
AC_DEFINE_UNQUOTED([PHP_UNAME_S], ["$PHP_UNAME_S"], [The 'uname -s' output.])
1419+
1420+
AC_ARG_VAR([PHP_UNAME_R],
1421+
[Operating system version (defaults to the 'uname -r' output)])
1422+
AS_VAR_IF([PHP_UNAME_R],, [PHP_UNAME_R=$(uname -r | xargs)])
1423+
AC_DEFINE_UNQUOTED([PHP_UNAME_R], ["$PHP_UNAME_R"], [The 'uname -r' output.])
1424+
14151425
PHP_OS=$(uname | xargs)
14161426
AC_DEFINE_UNQUOTED([PHP_OS], ["$PHP_OS"], [The 'uname' output.])
14171427

main/main.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,9 @@ ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void)
121121

122122
PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
123123
{
124-
zend_string *os = php_get_uname('s');
125-
zend_string *os_version = php_get_uname('r');
126-
127124
smart_string version_info = {0};
128125
smart_string_append_printf(&version_info,
129-
"PHP %s (%s) (built: %s) (%s) (%s %s%s)\n",
126+
"PHP %s (%s) (built: %s) (%s)\n",
130127
PHP_VERSION, sapi_module->name, php_build_date,
131128
#ifdef ZTS
132129
"ZTS"
@@ -144,25 +141,23 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
144141
#else
145142
" Unknown arch"
146143
#endif
147-
,
148-
ZSTR_VAL(os),
149-
ZSTR_VAL(os_version),
144+
);
145+
smart_string_appends(&version_info, "Copyright (c) The PHP Group\n");
146+
smart_string_append_printf(&version_info, "Built %s\n",
147+
#ifdef PHP_BUILD_PROVIDER
148+
"by " PHP_BUILD_PROVIDER
149+
#else
150+
"on " PHP_UNAME_S " " PHP_UNAME_R
151+
#endif
150152
#ifdef PHP_BUILD_COMPILER
151-
" " PHP_BUILD_COMPILER
153+
" (" PHP_BUILD_COMPILER ")"
152154
#else
153-
" Unknown compiler"
155+
""
154156
#endif
155157
);
156-
smart_string_appends(&version_info, "Copyright (c) The PHP Group\n");
157-
if (php_build_provider()) {
158-
smart_string_append_printf(&version_info, "Built by %s\n", php_build_provider());
159-
}
160158
smart_string_appends(&version_info, get_zend_version());
161159
smart_string_0(&version_info);
162160

163-
zend_string_free(os);
164-
zend_string_free(os_version);
165-
166161
return version_info.c;
167162
}
168163

main/php_main.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ PHPAPI bool php_tsrm_startup(void);
8989
#define PHP_OS_STR PHP_OS
9090
#endif
9191

92+
#define _PHP_STRINGIFY(s) #s
93+
#define PHP_STRINGIFY(s) _PHP_STRINGIFY(s)
94+
9295
#ifndef PHP_BUILD_COMPILER
9396
# if defined(__clang__)
94-
/* __VERSION__ contains the compiler name */
95-
# define PHP_BUILD_COMPILER __VERSION__
97+
# define PHP_BUILD_COMPILER "Clang " PHP_STRINGIFY(__clang_major__)
9698
# elif defined(__GNUC__)
97-
/* __VERSION__ does not contain the compiler name */
98-
# define PHP_BUILD_COMPILER "GCC " __VERSION__
99+
# define PHP_BUILD_COMPILER "GCC " PHP_STRINGIFY(__GNUC__)
99100
# endif
100101
#endif
101102

win32/build/confutils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ extension_module_ptrs = "";
133133
var oss = wmiservice.ExecQuery("Select * from Win32_OperatingSystem");
134134
var os = oss.ItemIndex(0);
135135
AC_DEFINE("PHP_BUILD_SYSTEM", os.Caption + " [" + os.Version + "]", "The system that PHP was built on.");
136+
AC_DEFINE("PHP_UNAME_S", os.Caption, "The system name that PHP was built on.");
137+
AC_DEFINE("PHP_UNAME_R", os.Version, "The system version that PHP was built on.");
136138
var build_provider = WshShell.Environment("Process").Item("PHP_BUILD_PROVIDER");
137139
if (build_provider) {
138140
AC_DEFINE("PHP_BUILD_PROVIDER", build_provider, "The PHP build provider information.");

0 commit comments

Comments
 (0)