fix(xlswriter): fix macOS build with modern Clang (C23)#1086
fix(xlswriter): fix macOS build with modern Clang (C23)#1086henderkes merged 3 commits intocrazywhalecc:mainfrom
Conversation
… minizip The bundled minizip in xlswriter (pinned at libxlsxwriter RELEASE_1.0.0) uses a K&R-style function declaration in mztools.c. Modern Clang on macOS (defaulting to C23) rejects this as a hard syntax error since K&R declarations were removed from the C23 standard. The upstream libxlsxwriter has already fixed this on their main branch. This patch applies the same fix during the build process. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the xlswriter extension build patching step to fix a macOS build failure with modern Clang/C23 by converting a K&R-style unzRepair declaration in bundled minizip to an ANSI C prototype.
Changes:
- Add a
patchBeforeMake()replacement targetinglibxlsxwriter/third_party/minizip/mztools.cto rewrite the K&R-styleunzRepairsignature into an ANSI C declaration. - Import and use
SPC\store\FileSystemto perform the in-file string replacement.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
It sounds like it makes sense, but I'm building on Linux in C23 mode with Clang, too. I would like to understand why it only fails on mac. |
|
It's an Apple-specific change: Apple Clang (shipped with Xcode 16 on the macos-15 runners) defaults to C23, while upstream LLVM Clang on Linux still defaults to -std=gnu17 even in recent versions. |
|
Using main branch I have no build error on my machine (macOS 15) but only if I use And looks like |
|
I think the better course of action here is to explicitly pin to std=c17 until it's fixed upstream: viest/php-ext-xlswriter#559 |
The bundled minizip in xlswriter has K&R C function declarations in multiple files (mztools.c, ioapi.c). Apple Clang (Xcode 16+) defaults to C23, which removed K&R from the standard, causing hard build errors. Instead of patching individual files, downgrade the C standard to gnu17 for the whole build when xlswriter is enabled. This covers all K&R occurrences in the bundled code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@crazywhalecc @henderkes You're right, I've also opened a PR upstream to update libxlsxwriter: viest/php-ext-xlswriter#560 — once that's merged, this |
Co-authored-by: Marc <m@pyc.ac>
|
|
||
| // Remove when https://github.com/viest/php-ext-xlswriter/pull/560 is merged | ||
| if (PHP_OS_FAMILY !== 'Windows') { | ||
| GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -std=gnu17'); |
There was a problem hiding this comment.
Should we use gnu17 here instead of c17?
Summary
RELEASE_1.0.0) uses a K&R-style function declaration inmztools.cmainbranch already has the ANSI C fix; the PECL extension just pins an old releasepatchBeforeMake(), matching the upstream fixError
Test plan
🤖 Generated with Claude Code