Skip to content

Add Linux support for GLFW extension and fix macOS C++ linking#1061

Closed
hmennen90 wants to merge 2 commits intocrazywhalecc:mainfrom
hmennen90:visu-patches
Closed

Add Linux support for GLFW extension and fix macOS C++ linking#1061
hmennen90 wants to merge 2 commits intocrazywhalecc:mainfrom
hmennen90:visu-patches

Conversation

@hmennen90
Copy link

What does this PR do?

Adds Linux support for the GLFW extension (php-glfw) and fixes macOS C++ linking.

Changes

config/ext.json — Set GLFW Linux support from "no" to "yes"

config/lib.json — Added static-libs-linux and headers entries for GLFW

src/SPC/builder/linux/library/glfw.php — New Linux GLFW library builder (mirrors the existing macOS version). Builds GLFW from the vendored source in php-glfw with X11 backend (Wayland disabled).

src/SPC/builder/extension/glfw.php — Added -lc++ to macOS EXTRA_LIBS. The php-glfw extension includes ogt_vox_c_wrapper.cpp which requires the C++ standard library for linking.

Notes

  • Linux builds require X11 development headers (libx11-dev, libxrandr-dev, libxinerama-dev, libxcursor-dev, libxi-dev) installed on the host and symlinked into buildroot/ since the musl
    toolchain restricts header search to that directory.
  • Tested locally on macOS arm64 (native build). Linux and Windows builds tested via GitHub Actions.

Checklist before merging

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:sort-config
  • If it's an extension or dependency update, please ensure the following:
    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

Hendrik Mennen and others added 2 commits March 14, 2026 23:59
- Enable GLFW on Linux in ext.json (was "no", now "yes")
- Add Linux-specific static libs to lib.json
- Create Linux GLFW library builder (builds from vendor/glfw with X11)
- Add -lc++ to macOS builds for ogt_vox_c_wrapper.cpp

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eplacement

The previous approach tried to patch the configure script string which
was fragile and didn't work on all platforms. Now uses the proper
builder option mechanism (same pattern as iconv extension).

Uses -lc++ on macOS (Clang) and -lstdc++ on Linux (GCC/musl).
@henderkes
Copy link
Collaborator

This is not suitable for a linux musl build. It has to be restricted to glibc or musl -dynamic (zig). Furthermore, instead of symlinking into buildroot, it should directly use the pkg configs of the operating system (user must set PKG_CONFIG_PATH=/usr/lib64/pkgconfig for e.g. RHEL 10).

Because this is poorly supported on v2 I'm against merging this in its current form. It will be better in v3 where we will allow linking a selection of libraries as shared libs.

@crazywhalecc
Copy link
Owner

crazywhalecc commented Mar 15, 2026

I've implemented on v3 version, but v3 is still under development. You could try the latest dev branch that not merged one https://github.com/crazywhalecc/static-php-cli/tree/v3-refactor/new-extensions but there is no any guarantee it's stable. We also haven't implemented full features yet.

We are currently generally fixing bugs and issues affecting short-term builds on the v2 branch only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants