Skip to content

[static-stdlib] Explicit autolink for RegexParser in StringProcessing #60319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kateinoigakukun
Copy link
Member

_RegexParser is used only in StringProcessing and it's imported with
@_implementationOnly.
Modules imported with @_implementationOnly are not autolinked, so build
system let the importer module how to link it. When building a shared
library, _RegexParser is already linked into StringProcessing. But when
building a static library, it's not. So we need to add autolink entry
explicitly.

Without this patch, compilation of source using regex feature with -static-stdlib would fail with the following error:

$ echo '_ = try Regex("x")' | swiftc - -static-stdlib
error: link command failed with exit code 1 (use -v to see invocation)
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing5RegexV5MatchV6outputxvg: error: undefined reference to '$s12_RegexParser16TypeConstructionO5tuple2ofypxn_tSKRzyp7ElementRtzlFZ'
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser3ASTV14QuantificationV6AmountOMa'
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser3ASTV5GroupV4KindOMa'
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser11CaptureListVMa'
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser11UnsupportedVMa'
/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser11UnsupportedVMa'
...

@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

_RegexParser is used only in StringProcessing and it's imported with
@_implementationOnly.
Modules imported with @_implementationOnly are not autolinked, so build
system let the importer module how to link it. When building a shared
library, _RegexParser is already linked into StringProcessing. But when
building a static library, it's not. So we need to add autolink entry
explicitly.
@kateinoigakukun kateinoigakukun force-pushed the katei/fix-static-regex-link branch from 69072e7 to 5f0a195 Compare July 31, 2022 02:11
@kateinoigakukun
Copy link
Member Author

@swift-ci Please smoke test

@kateinoigakukun kateinoigakukun requested a review from rxwei July 31, 2022 11:47
@rxwei rxwei requested review from milseman and Azoy and removed request for rxwei August 1, 2022 18:40
Copy link
Contributor

@Azoy Azoy left a comment

Choose a reason for hiding this comment

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

Thanks!

@MaxDesiatov
Copy link
Contributor

@Azoy would you mind if this is merged, or should we wait for more approvals?

@Azoy
Copy link
Contributor

Azoy commented Aug 16, 2022

I’m fine with this being merged 🙂

@MaxDesiatov MaxDesiatov merged commit 8bf745b into swiftlang:main Aug 16, 2022
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