decision _start generation by target, add some fake variables
This commit is contained in:
@@ -663,6 +663,18 @@ func isWasmTarget(goos string) bool {
|
|||||||
return slices.Contains([]string{"wasi", "js", "wasip1"}, goos)
|
return slices.Contains([]string{"wasi", "js", "wasip1"}, goos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func needStart(conf *Config) bool {
|
||||||
|
if conf.Target == "" {
|
||||||
|
return !isWasmTarget(conf.Goos)
|
||||||
|
}
|
||||||
|
switch conf.Target {
|
||||||
|
case "wasip2":
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func genMainModuleFile(ctx *context, rtPkgPath string, pkg *packages.Package, needRuntime, needPyInit bool) (path string, err error) {
|
func genMainModuleFile(ctx *context, rtPkgPath string, pkg *packages.Package, needRuntime, needPyInit bool) (path string, err error) {
|
||||||
var (
|
var (
|
||||||
pyInitDecl string
|
pyInitDecl string
|
||||||
@@ -717,8 +729,10 @@ define weak void @_start() {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
mainDefine := "define i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
mainDefine := "define i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
||||||
if isWasmTarget(ctx.buildConf.Goos) {
|
if !needStart(ctx.buildConf) && isWasmTarget(ctx.buildConf.Goos) {
|
||||||
mainDefine = "define hidden noundef i32 @__main_argc_argv(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
mainDefine = "define hidden noundef i32 @__main_argc_argv(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr"
|
||||||
|
}
|
||||||
|
if !needStart(ctx.buildConf) {
|
||||||
startDefine = ""
|
startDefine = ""
|
||||||
}
|
}
|
||||||
mainCode := fmt.Sprintf(`; ModuleID = 'main'
|
mainCode := fmt.Sprintf(`; ModuleID = 'main'
|
||||||
|
|||||||
Reference in New Issue
Block a user