Match the linkage of rb_digest_wrap_metadata on MSVC - #152
Merged
Conversation
digest.h declared it plain while digest.c defines it as
RUBY_FUNC_EXPORTED, which cl.exe rejects, so a build with
--with-static-linked-ext failed:
ext/digest/digest.c(547): error C2375: 'rb_digest_wrap_metadata': redefinition; different linkage
Keeping the attribute on the definition is what exports the symbol from
libruby when extensions are linked statically.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A ruby built with
--with-static-linked-exton MSVC cannot compile this extension.digest.hdeclares the function plain underEXTSTATICwhiledigest.cdefines it asRUBY_FUNC_EXPORTED, and cl.exe refuses a__declspec(dllexport)definition of a function that was already declared without it. Dropping the attribute is not an option becausewin32/mkexports.rbbuilds the export list from$(LIBRUBY_A), which holds no extension archives, so the attribute is the only thing that puts the symbol in libruby for extensions compiled later. Both sites now go through one macro thatdigest.coverrides.Verified on VS BuildTools 2026 (
x64-mswin64_140). A static-ext ruby builds,btestand the digest tests pass,rb_digest_wrap_metadatais still exported from the libruby DLL, andrake compile,rake build,rake testandrake checkpass. On Linux gcc 13 accepts both branches of the header.Generated with Claude Code