Skip to content

Commit 6ce446c

Browse files
committed
perf: switched to jom for windows builds
1 parent b74e0f7 commit 6ce446c

6 files changed

Lines changed: 84 additions & 8 deletions

File tree

.github/actions/setup-windows/action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ name: Setup
22
runs:
33
using: composite
44
steps:
5+
- name: Setup jom
6+
shell: pwsh
7+
run: |
8+
$jomDirectory = Join-Path $env:RUNNER_TEMP "jom"
9+
$jomArchive = Join-Path $env:RUNNER_TEMP "jom.zip"
10+
Invoke-WebRequest https://download.qt.io/official_releases/jom/jom_1_1_7.zip -OutFile $jomArchive
11+
if ((Get-FileHash $jomArchive -Algorithm SHA256).Hash -ne "4C8AF345586A9A08FBFD2F613FCAC748226D91A75627AA3581B297DD513046FE") {
12+
throw "Unexpected jom archive checksum"
13+
}
14+
Expand-Archive $jomArchive -DestinationPath $jomDirectory
15+
$jomDirectory | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
516
- name: Setup MySQL
617
shell: cmd
718
run: |

.github/matrix.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
['name' => 'PHP-8.2', 'ref' => 'PHP-8.2', 'version' => [8, 2]],
99
];
1010

11+
// Temporary while profiling Windows CI builds. Remove after this work is complete.
12+
const WINDOWS_ONLY_CI = true;
13+
1114
function get_branch_commit_cache_file_path(): string {
1215
return dirname(__DIR__) . '/branch-commit-cache.json';
1316
}
@@ -180,13 +183,16 @@ function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $re
180183

181184
$labels = json_decode($argv[4] ?? '[]', true) ?? [];
182185
$labels = array_column($labels, 'name');
183-
$all_variations = $nightly || in_array('CI: All variations', $labels, true);
186+
$all_variations = WINDOWS_ONLY_CI || $nightly || in_array('CI: All variations', $labels, true);
184187

185188
$repository = $argv[5] ?? null;
186189

187190
foreach ($branches as &$branch) {
188191
$php_version = $branch['version'][0] . '.' . $branch['version'][1];
189192
$branch['jobs'] = select_jobs($repository, $trigger, $nightly, $labels, $php_version, $branch['ref'], $all_variations);
193+
if (WINDOWS_ONLY_CI) {
194+
$branch['jobs'] = array_intersect_key($branch['jobs'], ['WINDOWS' => true]);
195+
}
190196
$branch['config']['ubuntu_version'] = version_compare($php_version, '8.5', '>=') ? '24.04' : '22.04';
191197
}
192198

.github/scripts/windows/build_task.bat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if "%CLANG_TOOLSET%" equ "1" (
4141

4242
cmd /c configure.bat ^
4343
--enable-snapshot-build ^
44+
--enable-parallel-build ^
4445
--disable-debug-pack ^
4546
--without-analyzer ^
4647
--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
@@ -49,9 +50,9 @@ cmd /c configure.bat ^
4950
--disable-test-ini
5051
if %errorlevel% neq 0 exit /b 3
5152

52-
nmake /NOLOGO
53+
jom /NOLOGO
5354
if %errorlevel% neq 0 exit /b 3
54-
nmake /NOLOGO comtest.dll
55+
jom /NOLOGO comtest.dll
5556
if %errorlevel% neq 0 exit /b 3
5657

5758
exit /b 0

win32/build/Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,36 @@ DEBUGGER_ARGS=
5454

5555
all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS) test_helpers
5656

57+
!if "$(PARALLEL_BUILD)" == "yes"
58+
BUILD_DIR_TARGET=build_dirs
59+
!else
5760
build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV)
61+
BUILD_DIR_TARGET=$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV)
62+
!endif
5863

5964
!if $(RE2C) == ""
65+
!if "$(PARALLEL_BUILD)" == "yes"
66+
generated_files: build_dirs .SYNC \
67+
Zend\zend_ini_parser.c .SYNC Zend\zend_ini_parser.h .SYNC \
68+
Zend\zend_language_parser.c .SYNC \
69+
sapi\phpdbg\phpdbg_parser.c .SYNC \
70+
$(PHPDEF) .SYNC $(MCFILE)
71+
!else
6072
generated_files: build_dirs \
6173
Zend\zend_ini_parser.c Zend\zend_ini_parser.h \
6274
Zend\zend_language_parser.c \
6375
sapi\phpdbg\phpdbg_parser.c \
6476
$(PHPDEF) $(MCFILE)
77+
!endif
78+
!else
79+
!if "$(PARALLEL_BUILD)" == "yes"
80+
generated_files: build_dirs .SYNC \
81+
Zend\zend_ini_parser.c .SYNC Zend\zend_ini_parser.h .SYNC \
82+
Zend\zend_language_parser.c .SYNC \
83+
Zend\zend_ini_scanner.c .SYNC Zend\zend_ini_scanner_defs.h .SYNC \
84+
Zend\zend_language_scanner.c .SYNC Zend\zend_language_scanner_defs.h .SYNC \
85+
sapi\phpdbg\phpdbg_parser.c .SYNC sapi\phpdbg\phpdbg_lexer.c .SYNC \
86+
$(PHPDEF) .SYNC $(MCFILE)
6587
!else
6688
generated_files: build_dirs \
6789
Zend\zend_ini_parser.c Zend\zend_ini_parser.h \
@@ -71,6 +93,7 @@ generated_files: build_dirs \
7193
sapi\phpdbg\phpdbg_parser.c sapi\phpdbg\phpdbg_lexer.c \
7294
$(PHPDEF) $(MCFILE)
7395
!endif
96+
!endif
7497

7598
$(BUILD_DIR)\$(PHPDLL).def: $(PHP_DLL_DEF_SOURCES)
7699
type $(PHP_DLL_DEF_SOURCES) > $(BUILD_DIR)\$(PHPDLL).def
@@ -138,7 +161,7 @@ $(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EX
138161

139162
$(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL)
140163

141-
$(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV):
164+
$(BUILD_DIR_TARGET):
142165
@echo Recreating build dirs
143166
@if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
144167
@cd $(BUILD_DIR)

win32/build/config.w32

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ DEFINE('PHP_PREFIX', PHP_PREFIX);
6262

6363
DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext ");
6464

65+
ARG_ENABLE('parallel-build', 'Generate independent object targets for a parallel NMAKE-compatible tool', 'no');
66+
DEFINE('PARALLEL_BUILD', PHP_PARALLEL_BUILD);
67+
6568
toolset_setup_common_cflags();
6669

6770
if (VS_TOOLSET) {
6871
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
6972
var PHP_MP_DISABLED = true;
7073

71-
if (PHP_MP != 'disable') {
74+
if (PHP_PARALLEL_BUILD == 'yes') {
75+
STDOUT.WriteLine('Using make-level parallel compilation');
76+
} else if (PHP_MP != 'disable') {
7277
if(PHP_DEBUG == 'yes') {
7378
STDOUT.WriteLine('WARNING: Debug builds cannot be built using multi processing');
7479
} else {

win32/build/confutils.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir, duplicate_sources)
16131613
var i;
16141614
var tv;
16151615
var src, obj, sym, flags;
1616+
var parallel_build = typeof PHP_PARALLEL_BUILD != "undefined" && PHP_PARALLEL_BUILD == "yes";
16161617

16171618
if (target == null) {
16181619
target = "php";
@@ -1712,7 +1713,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir, duplicate_sources)
17121713
srcs_by_dir[build_dir].push(i);
17131714
}
17141715

1715-
if (!duplicate_sources) {
1716+
if (!duplicate_sources && !parallel_build) {
17161717
/* Create makefile build targets and dependencies. */
17171718
MFO.WriteLine(objs_line + ": " + srcs_line);
17181719
}
@@ -1730,7 +1731,7 @@ function ADD_SOURCES(dir, file_list, target, obj_dir, duplicate_sources)
17301731
var mangle_dir = k.replace(new RegExp("[\\\\/.-]", "g"), "_");
17311732
var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();
17321733

1733-
if (VS_TOOLSET) {
1734+
if (VS_TOOLSET && !parallel_build) {
17341735
ADD_FLAG(bd_flags_name, "/Fd" + sub_build + d);
17351736
}
17361737

@@ -1797,7 +1798,36 @@ function ADD_SOURCES(dir, file_list, target, obj_dir, duplicate_sources)
17971798
}
17981799

17991800
if (!duplicate_sources) {
1800-
if (PHP_MP_DISABLED) {
1801+
if (parallel_build) {
1802+
for (var j in srcs_by_dir[k]) {
1803+
src = file_list[srcs_by_dir[k][j]];
1804+
1805+
var _tmp = src.split("\\");
1806+
var filename = _tmp.pop();
1807+
obj = sub_build + d + filename.replace(re, ".obj");
1808+
1809+
/* A parallel make needs one recipe owner per output. Generated files are
1810+
* an explicit prerequisite instead of relying on nmake's serial order. */
1811+
MFO.WriteLine(obj + ": generated_files " + dir + "\\" + src);
1812+
1813+
var pdb_flag = "";
1814+
if (VS_TOOLSET) {
1815+
/* Concurrent cl.exe processes must not share a PDB/IDB file. */
1816+
pdb_flag = " /Fd" + sub_build + d + filename.replace(re, ".pdb");
1817+
}
1818+
1819+
MFO.WriteLine("\t" + CMD_MOD1 + "$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ")" + pdb_flag + " /c " + dir + "\\" + src + " /Fo" + obj);
1820+
1821+
if ("clang" == PHP_ANALYZER) {
1822+
MFO.WriteLine("\t" + CMD_MOD1 + "\"$(CLANG_CL)\" " + analyzer_base_args + " $(" + flags + "_ANALYZER) $(CFLAGS_ANALYZER) $(" + bd_flags_name + "_ANALYZER) " + dir + "\\" + src);
1823+
} else if ("cppcheck" == PHP_ANALYZER) {
1824+
MFO.WriteLine("\t\"" + CMD_MOD1 + "$(CPPCHECK)\" " + analyzer_base_args + " $(" + flags + "_ANALYZER) $(CFLAGS_ANALYZER) $(" + bd_flags_name + "_ANALYZER) " + analyzer_base_flags + " " + dir + "\\" + src);
1825+
} else if (PHP_ANALYZER == "pvs") {
1826+
MFO.WriteLine("\t" + CMD_MOD1 + "\"$(PVS_STUDIO)\" --cl-params $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ")" + pdb_flag + " /c " + dir + "\\" + src + " --source-file " + dir + "\\" + src
1827+
+ " --cfg PVS-Studio.conf --errors-off \"V122 V117 V111\" ");
1828+
}
1829+
}
1830+
} else if (PHP_MP_DISABLED) {
18011831
for (var j in srcs_by_dir[k]) {
18021832
src = file_list[srcs_by_dir[k][j]];
18031833

0 commit comments

Comments
 (0)