Skip to content

build: compile the C extension with hidden symbol visibility - #899

Merged
ntamas merged 2 commits into
igraph:mainfrom
szhorvat:build/hidden-visibility
Nov 29, 2026
Merged

ntamas merged 2 commits into
igraph:mainfrom
szhorvat:build/hidden-visibility

Conversation

@szhorvat

Copy link
Copy Markdown
Member

Only PyInit__igraph needs to be exported from the extension module, but GCC and Clang exported every non-static function, such as all igraphmodule_* helpers. Exported names can clash with symbols from other libraries and invite external code to depend on internals; abi3audit --strict also flags exported names with reserved prefixes. MSVC already exports nothing by default.

Pass -fvisibility=hidden on non-MSVC compilers, and declare the module init function with PyMODINIT_FUNC so that it stays exported.

Assisted-by: Claude Opus 5.5

Only PyInit__igraph needs to be exported from the extension module, but
GCC and Clang exported every non-static function, such as all
igraphmodule_* helpers. Exported names can clash with symbols from other
libraries and invite external code to depend on internals; abi3audit
--strict also flags exported names with reserved prefixes. MSVC already
exports nothing by default.

Pass -fvisibility=hidden on non-MSVC compilers, and declare the module
init function with PyMODINIT_FUNC so that it stays exported.

Assisted-by: Claude Opus 5.5
@szhorvat

Copy link
Copy Markdown
Member Author

@vtraag Are you aware of a reason NOT to do this? I believe leidenalg will be fine, or will it not?

@szhorvat
szhorvat requested review from ntamas and vtraag November 28, 2026 15:04
@vtraag

vtraag commented Nov 28, 2026

Copy link
Copy Markdown
Member

I believe it will be fine indeed. There are no internal functions that it relies, if I'm not mistaken.

@ntamas
ntamas merged commit b2abfef into igraph:main Nov 29, 2026
14 checks passed
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