Skip to content

Commit 5a1fd1f

Browse files
authored
Merge branch 'v3' into v3c/artifact-static-helpers
2 parents 91cf4f8 + 48d6e9e commit 5a1fd1f

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

src/StaticPHP/Doctor/Item/LinuxMuslCheck.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,20 @@ public function fixMusl(): bool
7373
$prefix = 'sudo ';
7474
logger()->warning('Current user is not root, using sudo for running command');
7575
}
76+
$sysEnv = ['CC' => 'gcc', 'CXX' => 'g++', 'AR' => 'ar', 'LD' => 'ld', 'RANLIB' => 'ranlib'];
77+
$envFlags = '';
78+
foreach ($sysEnv as $k => $v) {
79+
$envFlags .= "{$k}={$v} ";
80+
}
81+
$envFlags = rtrim($envFlags);
7682
$shell = shell()->cd(SOURCE_PATH . '/musl-wrapper')
77-
->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper')
78-
->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j');
83+
->setEnv($sysEnv)
84+
->exec('./configure --disable-gcc-wrapper')
85+
->exec('make -j');
7986
if ($prefix !== '') {
80-
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
87+
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && {$envFlags} {$prefix}make install");
8188
} else {
82-
$shell->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
89+
$shell->exec("{$prefix}make install");
8390
}
8491
return true;
8592
}

src/globals/functions.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,30 @@ function clean_spaces(string $string): string
256256
*/
257257
function deduplicate_flags(string $flags): string
258258
{
259-
$tokens = preg_split('/\s+/', trim($flags));
259+
// Flags that take their value as a separate token.
260+
static $paired = [
261+
'-Xclang', '-Xpreprocessor', '-Xlinker', '-Xassembler',
262+
'-framework', '-arch', '-target',
263+
'-include', '-imacros', '-isystem', '-isysroot', '-iquote', '-idirafter',
264+
'-MT', '-MF', '-MQ',
265+
];
266+
267+
$tokens = preg_split('/\s+/', trim($flags)) ?: [];
268+
269+
// Group paired flag+value into a single atom before dedup.
270+
$atoms = [];
271+
$n = count($tokens);
272+
for ($i = 0; $i < $n; ++$i) {
273+
if (in_array($tokens[$i], $paired, true) && $i + 1 < $n) {
274+
$atoms[] = $tokens[$i] . ' ' . $tokens[$i + 1];
275+
++$i;
276+
} else {
277+
$atoms[] = $tokens[$i];
278+
}
279+
}
260280

261281
// Reverse, unique, reverse back - keeps last occurrence of duplicates
262-
$deduplicated = array_reverse(array_unique(array_reverse($tokens)));
282+
$deduplicated = array_reverse(array_unique(array_reverse($atoms)));
263283

264284
return implode(' ', $deduplicated);
265285
}

src/globals/patch/spc_fix_avx512_cache_before_80400.patch‎ renamed to src/globals/patch/spc_fix_avx512_cache_before_80400.patch

File renamed without changes.

0 commit comments

Comments
 (0)