Skip to content
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

undefined symbols (RegexParser) #5580

Open
svanimpe opened this issue Apr 18, 2024 · 2 comments
Open

undefined symbols (RegexParser) #5580

svanimpe opened this issue Apr 18, 2024 · 2 comments

Comments

@svanimpe
Copy link

Steps to reproduce:

  • Create a new package with swift package init --type executable
  • Add JavaScriptKit as a dependency. My Package.swift file is as follows:
    // swift-tools-version: 5.9
    // The swift-tools-version declares the minimum version of Swift required to build this package.
    
    import PackageDescription
    
    let package = Package(
      name: "RegexParserIssue",
      dependencies: [
          .package(url: "https://github.com/swiftwasm/JavaScriptKit", from: "0.19.0")
      ],
      targets: [
          .executableTarget(
              name: "RegexParserIssue",
              dependencies: [
                  .product(name: "JavaScriptKit", package: "JavaScriptKit")
              ]
          ),
      ]
    )
    
  • Build using:
    swift build --triple wasm32-unknown-wasi -Xswiftc -static-stdlib -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=__main_argc_argv
    

This results in a long list of errors like:

wasm-ld: error: /Users/steven/Library/Developer/Toolchains/swift-wasm-6.0-SNAPSHOT-2024-04-16-a.xctoolchain/usr/lib/swift_static/wasi/libswift_StringProcessing.a(_StringProcessing.o): undefined symbol: $s12_RegexParser3ASTV28GlobalMatchingOptionSequenceVMn
wasm-ld: error: /Users/steven/Library/Developer/Toolchains/swift-wasm-6.0-SNAPSHOT-2024-04-16-a.xctoolchain/usr/lib/swift_static/wasi/libswift_StringProcessing.a(_StringProcessing.o): undefined symbol: $s12_RegexParser13PrettyPrinterVMn
wasm-ld: error: /Users/steven/Library/Developer/Toolchains/swift-wasm-6.0-SNAPSHOT-2024-04-16-a.xctoolchain/usr/lib/swift_static/wasi/libswift_StringProcessing.a(_StringProcessing.o): undefined symbol: $s12_RegexParser9_TreeNodeMp
wasm-ld: error: /Users/steven/Library/Developer/Toolchains/swift-wasm-6.0-SNAPSHOT-2024-04-16-a.xctoolchain/usr/lib/swift_static/wasi/libswift_StringProcessing.a(_StringProcessing.o): undefined symbol: $s12_RegexParser9_TreeNodeP8childrenSayxGSgvgTq
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Workaround:

Add import _RegexParser in a Swift file.

Environment:

swift-wasm-6.0-SNAPSHOT-2024-04-16-a-macos_x86_64

@svanimpe
Copy link
Author

svanimpe commented Apr 19, 2024

I've also encountered this issue when using JSONEncoder from Foundation, in a project that doesn't use JavaScriptKit.

@kateinoigakukun
Copy link
Member

https://github.com/kateinoigakukun/swiftwasm-issue-gh-5580

I finally could reproduce the issue and it's already incidentally fixed by --gc-sections support in the main branch. So it's reproducible with 6.0 snapshot.

But the root cause is still unclear... There should be something wrong in incremental compilation of swift-driver, so it might happen again

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

No branches or pull requests

2 participants