mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Avoid duplicate build rules
On Windows, the cli and phpdbg SAPIs have variants (cli-win32 and phpdbgs, respectively) which are build by default. However, the variants share some files, what leads to duplicate build rules in the generated Makefile. NMake throws warning U4004[1], but proceeds happily, ignoring the second build rule. That means that different flags for duplicate rules are ignored, hinting at a potential problem. We solve this by introducing an additional (optional) argument to `SAPI()` and `ADD_SOURCES()` which can be used to avoid such duplicate build rules. It's left to the SAPI maintainers to make sure that appropriate rules are created. We fix this for phpdbgs right away, which currently couldn't be build without phpdbg due to the missing define; we remove the unused `PHP_PHPDBG_EXPORTS` flag altogether. [1] <https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/nmake-warning-u4004> Closes GH-17545.
This commit is contained in:
parent
8deca2838c
commit
3955b01653
4 changed files with 47 additions and 34 deletions
|
@ -24,6 +24,13 @@ PHP 8.5 INTERNALS UPGRADE NOTES
|
|||
2. Build system changes
|
||||
========================
|
||||
|
||||
- Windows build system changes
|
||||
. SAPI() and ADD_SOURCES() now suport the optional `duplicate_sources`
|
||||
parameter. If truthy, no rules to build the object files are generated.
|
||||
This allows to build additional variants of SAPIs (e.g. a DLL and EXE)
|
||||
without duplicate build rules. It is up to the SAPI maintainers to ensure
|
||||
that appropriate build rules are created.
|
||||
|
||||
========================
|
||||
3. Module changes
|
||||
========================
|
||||
|
|
|
@ -4,7 +4,8 @@ ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes');
|
|||
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
|
||||
|
||||
if (PHP_CLI == "yes") {
|
||||
SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
ADD_SOURCES(configure_module_dirname, 'php_cli_process_title.c ps_title.c', 'cli');
|
||||
ADD_FLAG("LIBS_CLI", "ws2_32.lib");
|
||||
ADD_FLAG("LIBS_CLI", "shell32.lib");
|
||||
ADD_FLAG("LDFLAGS_CLI", "/stack:67108864");
|
||||
|
@ -17,7 +18,8 @@ if (PHP_CLI == "yes") {
|
|||
}
|
||||
|
||||
if (PHP_CLI_WIN32 == "yes") {
|
||||
SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
SAPI('cli_win32', 'cli_win32.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
ADD_SOURCES(configure_module_dirname, ' php_cli_process_title.c ps_title.c', 'cli_win32', undefined, PHP_CLI == "yes");
|
||||
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
|
||||
ADD_FLAG("LIBS_CLI_WIN32", "shell32.lib");
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ if (PHP_PHPDBG == "yes") {
|
|||
}
|
||||
|
||||
if (PHP_PHPDBGS == "yes") {
|
||||
SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS');
|
||||
SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, PHPDBG_CFLAGS, undefined, PHP_PHPDBG == "yes");
|
||||
ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib");
|
||||
ADD_FLAG("CFLAGS_PHPDBGS", "/D YY_NO_UNISTD_H");
|
||||
|
||||
|
|
|
@ -1189,7 +1189,7 @@ function is_pgo_desired(mod)
|
|||
return eval("!!" + varname);
|
||||
}
|
||||
|
||||
function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
|
||||
function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir, duplicate_sources)
|
||||
{
|
||||
var SAPI = sapiname.toUpperCase();
|
||||
var ldflags;
|
||||
|
@ -1213,7 +1213,7 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
|
|||
ADD_FLAG('CFLAGS_' + SAPI, cflags);
|
||||
}
|
||||
|
||||
ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir);
|
||||
ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir, duplicate_sources);
|
||||
MFO.WriteBlankLines(1);
|
||||
MFO.WriteLine("# SAPI " + sapiname);
|
||||
MFO.WriteBlankLines(1);
|
||||
|
@ -1550,7 +1550,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
|
|||
extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static', false];
|
||||
}
|
||||
|
||||
function ADD_SOURCES(dir, file_list, target, obj_dir)
|
||||
function ADD_SOURCES(dir, file_list, target, obj_dir, duplicate_sources)
|
||||
{
|
||||
var i;
|
||||
var tv;
|
||||
|
@ -1654,8 +1654,10 @@ function ADD_SOURCES(dir, file_list, target, obj_dir)
|
|||
srcs_by_dir[build_dir].push(i);
|
||||
}
|
||||
|
||||
if (!duplicate_sources) {
|
||||
/* Create makefile build targets and dependencies. */
|
||||
MFO.WriteLine(objs_line + ": " + srcs_line);
|
||||
}
|
||||
|
||||
/* Create target subdirs if any and produce the compiler calls, /mp is respected if enabled. */
|
||||
for (var k in srcs_by_dir) {
|
||||
|
@ -1736,6 +1738,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir)
|
|||
}
|
||||
}
|
||||
|
||||
if (!duplicate_sources) {
|
||||
if (PHP_MP_DISABLED) {
|
||||
for (var j in srcs_by_dir[k]) {
|
||||
src = file_list[srcs_by_dir[k][j]];
|
||||
|
@ -1771,6 +1774,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE(sym, tv);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue