Skip to content

Commit 20f95ef

Browse files
authored
fix(xlswriter): fix macOS build with modern Clang (C23) (crazywhalecc#1086)
2 parents d411fac + fb77309 commit 20f95ef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/SPC/builder/extension/xlswriter.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SPC\builder\Extension;
88
use SPC\store\SourcePatcher;
99
use SPC\util\CustomExt;
10+
use SPC\util\GlobalEnvManager;
1011

1112
#[CustomExt('xlswriter')]
1213
class xlswriter extends Extension
@@ -28,6 +29,13 @@ public function getWindowsConfigureArg(bool $shared = false): string
2829
public function patchBeforeMake(): bool
2930
{
3031
$patched = parent::patchBeforeMake();
32+
33+
// Remove when https://github.com/viest/php-ext-xlswriter/pull/560 is merged
34+
if (PHP_OS_FAMILY !== 'Windows') {
35+
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -std=gnu17');
36+
$patched = true;
37+
}
38+
3139
if (PHP_OS_FAMILY === 'Windows') {
3240
// fix windows build with openssl extension duplicate symbol bug
3341
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
@@ -40,4 +48,10 @@ public function patchBeforeMake(): bool
4048
}
4149
return $patched;
4250
}
51+
52+
// Remove when https://github.com/viest/php-ext-xlswriter/pull/560 is merged
53+
protected function getExtraEnv(): array
54+
{
55+
return ['CFLAGS' => '-std=gnu17'];
56+
}
4357
}

0 commit comments

Comments
 (0)