fix: check needStart by libc name
This commit is contained in:
@@ -839,15 +839,16 @@ func isWasmTarget(goos string) bool {
|
||||
return slices.Contains([]string{"wasi", "js", "wasip1"}, goos)
|
||||
}
|
||||
|
||||
func needStart(conf *Config) bool {
|
||||
if conf.Target == "" {
|
||||
return !isWasmTarget(conf.Goos)
|
||||
func needStart(ctx *context) bool {
|
||||
if ctx.buildConf.Target == "" {
|
||||
return !isWasmTarget(ctx.buildConf.Goos)
|
||||
}
|
||||
switch conf.Target {
|
||||
switch ctx.buildConf.Target {
|
||||
case "wasip2":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
// since newlib-esp32 provides _start, we don't need to provide a fake _start function
|
||||
return ctx.crossCompile.Libc != "newlib-esp32"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,10 +905,10 @@ define weak void @_start() {
|
||||
}
|
||||
`
|
||||
mainDefine := "define i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
||||
if !needStart(ctx.buildConf) && isWasmTarget(ctx.buildConf.Goos) {
|
||||
if !needStart(ctx) && isWasmTarget(ctx.buildConf.Goos) {
|
||||
mainDefine = "define hidden noundef i32 @__main_argc_argv(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
||||
}
|
||||
if true {
|
||||
if !needStart(ctx) {
|
||||
startDefine = ""
|
||||
}
|
||||
mainCode := fmt.Sprintf(`; ModuleID = 'main'
|
||||
|
||||
Reference in New Issue
Block a user