Issues with using 5.7 `Regex` on Linux

I'm running into some issues when trying to use the new Regex type on Linux:

Example link failure output

/usr/bin/ error: /home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswiftCore.a(UnicodeScalarProps.cpp.o): multiple definition of '_swift_stdlib_getScript'
/usr/bin/ /home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswift_StringProcessing.a(UnicodeScalarProps.c.o): previous definition here
/usr/bin/ error: /home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswiftCore.a(UnicodeScalarProps.cpp.o): multiple definition of '_swift_stdlib_getScriptExtensions'
/usr/bin/ /home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswift_StringProcessing.a(UnicodeScalarProps.c.o): previous definition here
/home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing5RegexV5MatchV6outputxvg: error: undefined reference to '$s12_RegexParser16TypeConstructionO5tuple2ofypxn_tSKRzyp7ElementRtzlFZ'
/home/patrick/.swiftly/toolchains/5.7.0/usr/lib/swift_static/linux/libswift_StringProcessing.a(_StringProcessing.o):_StringProcessing.o:function $s17_StringProcessing8CompilerC11ByteCodeGenV8emitNode33_39AB0CA4F16DF29C6C8E2960922072B7LLyAA8TypedIntVyAA14_ValueRegisterOGSgAA7DSLTreeV0H0OKF: error: undefined reference to '$s12_RegexParser3ASTV14QuantificationV6AmountOMa'
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
[4/5] Linking swift-regex

Are these behaviors expected? And if not, are they related / will they be fixed together?

1 Like

A few weeks ago I tested this and at least the first one was fixed on the latest nightly build at the time. I'd take this as an indication that it will be fixed in 5.8, unless for some reason it's broken again in the current nightly build.

Oh, 5.7.1 has actually already been released with the fix for the first one. Confirmed that enable-bare-slash and _StringProcessing are no longer required.

The second part still seems broken both on 5.7.1 and on the latest main snapshot. Clean builds seem to sometimes work okay, but any subsequent ones will fail.


Do you mind filing a bug report for the second issue if you haven't already? It ought to be pretty easy to fix.

Filed here: Executable fails to link when using `Regex` with `--static-swift-stdlib` (Linux) · Issue #62034 · apple/swift · GitHub