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

Stop renaming main symbol for WASI #3804

Merged
merged 4 commits into from
Oct 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,21 @@ extension BuildParameters {

/// Computes the linker flags to use in order to rename a module-named main function to 'main' for the target platform, or nil if the linker doesn't support it for the platform.
fileprivate func linkerFlagsForRenamingMainFunction(of target: ResolvedTarget) -> [String]? {
var args: [String] = []
var args: [String]?
if self.triple.isDarwin() {
args = ["-alias", "_\(target.c99name)_main", "_main"]
}
else if self.triple.isLinux() {
args = ["--defsym", "main=\(target.c99name)_main"]
}
return args.flatMap { ["-Xlinker", $0] }
else if self.triple.isWASI() {
// wasm-ld doesn't support renaming symbols yet
args = nil
}
else {
args = []
}
kateinoigakukun marked this conversation as resolved.
Show resolved Hide resolved
return args?.flatMap { ["-Xlinker", $0] }
}

/// Returns the scoped view of build settings for a given target.
Expand Down