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

Can't build #145

Closed
kkebo opened this issue Jan 11, 2025 · 7 comments · Fixed by swiftlang/swift-syntax#2944
Closed

Can't build #145

kkebo opened this issue Jan 11, 2025 · 7 comments · Fixed by swiftlang/swift-syntax#2944
Assignees
Labels
bug Something isn't working

Comments

@kkebo
Copy link
Owner

kkebo commented Jan 11, 2025

Description

swiftlang#2925 broke WASI build.

The latest implementation is swiftlang#2934.

Steps to Reproduce

https://github.com/kkebo/swift-syntax/actions/runs/12723180378/job/35468017064

@kkebo kkebo added the bug Something isn't working label Jan 11, 2025
@kkebo kkebo self-assigned this Jan 11, 2025
@rintaro
Copy link

rintaro commented Jan 20, 2025

error: link command failed with exit code 1 (use -v to see invocation)
wasm-ld: error: /__w/swift-syntax/swift-syntax/.build/wasm32-unknown-wasi/release/_SwiftSyntaxCShims.build/PlatformMutex.c.o: undefined symbol: pthread_mutex_init
wasm-ld: error: /__w/swift-syntax/swift-syntax/.build/wasm32-unknown-wasi/release/_SwiftSyntaxCShims.build/PlatformMutex.c.o: undefined symbol: pthread_mutex_lock
wasm-ld: error: /__w/swift-syntax/swift-syntax/.build/wasm32-unknown-wasi/release/_SwiftSyntaxCShims.build/PlatformMutex.c.o: undefined symbol: pthread_mutex_unlock
wasm-ld: error: /__w/swift-syntax/swift-syntax/.build/wasm32-unknown-wasi/release/_SwiftSyntaxCShims.build/PlatformMutex.c.o: undefined symbol: pthread_mutex_destroy

Does this mean pthread.h does exist, but it actually don't have the library? That doesn't sound ideal.
But anyway, pthread is only used here https://github.com/swiftlang/swift-syntax/blob/main/Sources/_SwiftSyntaxCShims/PlatformMutex.c

If the target is not a multi-thread environment, feel free to add something like

#elif <CONDITION>
PlatformMutex swiftsyntax_platform_mutex_create() {
  PlatformMutex m;
  m.opaque = 0;
  return m;
}
void swiftsyntax_platform_mutex_lock(PlatformMutex m) {}
void swiftsyntax_platform_mutex_unlock(PlatformMutex m) {}
void swiftsyntax_platform_mutex_destroy(PlatformMutex m) {}

(before #elif __has_include(<pthread.h>))

Since I personally don't know the preprocessor macro for WASI, contribution is appreciated.

@rintaro
Copy link

rintaro commented Jan 20, 2025

Oooh, I thought here is swiftlang/swift-syntax sorry for the noise 😅

@kkebo
Copy link
Owner Author

kkebo commented Jan 20, 2025

@rintaro Thank you for your comment and suggestion.

Yes, wasm32-unknown-wasi is not a multi-thread environment. However, wasm32-unknown-wasip1-threads is.

The description of the following PR is helpful.

swiftlang/swift-cmark#75

I'll try to contribute, but I may be busy for a month or so and may not get around to it.

@kkebo
Copy link
Owner Author

kkebo commented Jan 20, 2025

I could have created an issue in swiftlang/swift-syntax, but I wasn't sure if they had officially supported WASI or not, so I created an issue here for now.

@rintaro
Copy link

rintaro commented Jan 20, 2025

Sounds good. Here is the PR swiftlang#2944
Untested, I'd appreciate if you can test it.

@kkebo
Copy link
Owner Author

kkebo commented Jan 20, 2025

Thank you so much!

kkebo/swift-syntax's tests have passed.

#148

I'll trigger kkebo/swift-format's tests later too.

@kkebo
Copy link
Owner Author

kkebo commented Jan 20, 2025

@kkebo kkebo closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants