-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add initial WebAssembly toolchain implementation #315
Conversation
|
@swift-ci please test |
| // On ELF/WASM platforms there's no built in autolinking mechanism, so we | ||
| // pull the info we need from the .o files directly and pass them as an | ||
| // argument input file to the linker. | ||
| // FIXME: Also handle Cygwin and MinGW | ||
| guard inputs.count > 0 && targetTriple.objectFormat == .elf && lto == nil else { | ||
| guard inputs.count > 0 && | ||
| [.elf, .wasm].contains(targetTriple.objectFormat) && | ||
| lto == nil else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand we probably won't need autolink-extract for Wasm long-term, but this is pretty harmless in the meantime
| public func makeLinkerOutputFilename(moduleName: String, type: LinkOutputType) -> String { | ||
| switch type { | ||
| case .executable: | ||
| return moduleName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this should always have the .wasm extension
|
cc @kateinoigakukun and @MaxDesiatov too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thank you for implementing this!
|
@swift-ci please test |
|
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah, cool! Splitting this out from the generic Unix toolchain seems to make sense here
|
The latest push fixes a small merge conflict, but otherwise there aren't any changes @swift-ci please test |
This is an initial implementation of a WebAssembly toolchain. It shares a lot of similarities with the GenericUnixToolchain, but it doesn't support dynamic libraries and other features like sanitizers, profiling, etc. Overall, there are enough differences that trying to subclass GenericUnixToolchain seemed potentially error-prone.
The functionality in this PR goes a bit beyond the current Wasm support in the main Swift repo. I tested this change by installing swift-driver into a toolchain snapshot from the SwiftWasm fork and then verifying I could compile a basic working program.