Skip to content

feat: guard get_module export for statically linked extensions - #764

Merged
ptondereau merged 5 commits into
extphprs:masterfrom
ptondereau:feat/guard-get-module-763
Aug 20, 2026
Merged

ptondereau merged 5 commits into
extphprs:masterfrom
ptondereau:feat/guard-get-module-763

Conversation

@ptondereau

Copy link
Copy Markdown
Member

Description

Closes #763.

A statically linked ext-php-rs extension always exported get_module, so it collided at link time with any other extension exporting the same symbol, like a C extension missing the #ifdef COMPILE_DL_ext guard. #[php_module] now also exports a crate-prefixed <crate>_get_module, and building with EXT_PHP_RS_STATIC_EXT=1 drops the unprefixed export while keeping the function callable from Rust. The static-glue shim calls the prefixed symbol, derived from the library target name rather than --ext-name. The variable replaces the unreleased EXT_PHP_RS_STATIC_TSRMLS_CACHE and also enables the static TSRMLS cache, so static builds need a single switch. Verified end to end on a two-pass PHP 8.5 ZTS build: linking next to an unguarded C extension failed with multiple definition of 'get_module' before, and links and runs with both modules loaded after. CI now asserts the symbol gating with nm on the hello_world cdylib.

Checklist

@ptondereau

Copy link
Copy Markdown
Member Author

@TobiasBengtsson @okhoshi did my best, and some CI tests are ugly, but let's have some feedbacks

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 32383225875

Coverage increased (+0.1%) to 66.98%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 7 uncovered changes across 1 file (53 of 60 lines covered, 88.33%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
crates/cli/src/static_glue.rs 14 7 50.0%
Total (2 files) 60 53 88.33%

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
crates/cli/src/static_glue.rs 2 46.67%

Coverage Stats

Coverage Status
Relevant Lines: 13501
Covered Lines: 9043
Line Coverage: 66.98%
Coverage Strength: 43.0 hits per line

💛 - Coveralls

@github-actions

Copy link
Copy Markdown

🐰 Bencher Report

Projectext-php-rs
Branchfeat/guard-get-module-763
TestbedPHP 8.4.24 (cli) (built: Jul 29 2026 09:44:18) (NTS)

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

@ptondereau
ptondereau marked this pull request as ready for review August 20, 2026 15:27

@okhoshi okhoshi left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I haven't tried yet however.

But thank you for jumping on so quickly 🚀

Comment thread crates/cli/src/static_glue.rs
@ptondereau
ptondereau enabled auto-merge (squash) August 20, 2026 17:01
@ptondereau
ptondereau disabled auto-merge August 20, 2026 17:01
@ptondereau
ptondereau merged commit 645bffc into extphprs:master Aug 20, 2026
68 checks passed
@ptondereau
ptondereau deleted the feat/guard-get-module-763 branch August 20, 2026 17:02
@Xenira Xenira mentioned this pull request Aug 20, 2026
ptondereau pushed a commit that referenced this pull request Aug 21, 2026
…ll (#765)

Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>

Follow-up on #764, which made the library name always derive from the library target name through cargo metadata, reintroducing a new flag to skip the cargo metadata call.
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.

Guard get_module in static builds to avoid symbol collisions

3 participants