Skip to content

Preserve section GC in split mode - #1429

Merged
wjakob merged 1 commit into
wjakob:masterfrom
burgholzer:codex/split-section-gc
Sep 2, 2026
Merged

Preserve section GC in split mode#1429
wjakob merged 1 commit into
wjakob:masterfrom
burgholzer:codex/split-section-gc

Conversation

@burgholzer

Copy link
Copy Markdown
Contributor

Summary

Linked-mode extension targets inherit -ffunction-sections, -fdata-sections, and --gc-sections from nanobind's static library target. Split-mode extensions skip that library target and therefore lose these options.

This PR applies the same optimized-build options directly to split targets on the platforms where nanobind already enables section garbage collection. Add a configure-time check that protects both the compile and link options.

Assisted-by: gpt-5.6-sol with Codex

(This change was prompted by us having to work around this in one of our projects; see https://github.com/munich-quantum-toolkit/core/blob/970b79a55c9fd355df5fa4a9eb8c0c029fa0a733/cmake/AddMQTPythonBinding.cmake#L54-L59)

Linked targets inherit section compile and link flags from the static nanobind library. Split targets skip that library and lose the flags.

Apply the same options directly to split targets.

Assisted-by: Codex
@wjakob
wjakob merged commit 2e57541 into wjakob:master Sep 2, 2026
40 checks passed
@wjakob

wjakob commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

2 participants