Skip to content

mswin: Add statically linked extension exports to the import library - #18670

Merged
hsbt merged 1 commit into
ruby:masterfrom
hsbt:mswin-import-library-static-ext-exports
Sep 9, 2026
Merged

mswin: Add statically linked extension exports to the import library#18670
hsbt merged 1 commit into
ruby:masterfrom
hsbt:mswin-import-library-static-ext-exports

Conversation

@hsbt

@hsbt hsbt commented Sep 8, 2026

Copy link
Copy Markdown
Member

On mswin an extension built against a --with-static-linked-ext ruby fails to link with error LNK2019: unresolved external symbol rb_digest_wrap_metadata, although the shipped DLL does export it. config.h defines EXTSTATIC for such a build, so ruby/digest.h makes every digest-based extension refer to that symbol directly.

The def file is generated from $(LIBRUBY_A) alone. Whatever a statically linked extension exports with RUBY_FUNC_EXPORTED therefore reaches the DLL through its own /EXPORT: linker directive, but never reaches the import library that ships next to it. win32/mkexports.rb now also reads those directives from the files listed after --, and $(RUBYDEF) passes $(DLDOBJS) there.

Only explicit exports are collected, so the DLL's export table does not change and the dynamic build still produces a byte-identical def file. Reproducing the failure needs ruby/digest#152, without which --with-static-linked-ext does not compile on MSVC.

Generated with Claude Code

The def file is generated from $(LIBRUBY_A) alone, so a symbol that a
statically linked extension exports with RUBY_FUNC_EXPORTED reaches the
DLL through its own linker directive but never reaches the import
library, and an extension built later against that ruby cannot link it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hsbt
hsbt merged commit e80a4e8 into ruby:master Sep 9, 2026
131 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.

1 participant