Skip to content

Commit

Permalink
all: rip out actually calling wizer; just leave runtime patches
Browse files Browse the repository at this point in the history
  • Loading branch information
dgryski committed Jun 6, 2024
1 parent 59e92ac commit 3ce9cb2
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 71 deletions.
31 changes: 0 additions & 31 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,37 +854,6 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
}
}

if config.Options.WizerInit {
var args []string

resultWizer := result.Executable + "-wizer"

args = append(args,
"--allow-wasi",
"--wasm-bulk-memory=true",
"-f", "runtime.wizerInit",
result.Executable,
"-o", resultWizer,
)

if config.Options.PrintCommands != nil {
config.Options.PrintCommands(goenv.Get("WIZER"), args...)
}

cmd := exec.Command(goenv.Get("WIZER"), args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

err := cmd.Run()
if err != nil {
return fmt.Errorf("wizer failed: %w", err)
}

if err := os.Rename(resultWizer, result.Executable); err != nil {
return fmt.Errorf("rename failed: %w", err)
}
}

// Print code size if requested.
if config.Options.PrintSizes == "short" || config.Options.PrintSizes == "full" {
packagePathMap := make(map[string]string, len(lprogram.Packages))
Expand Down
1 change: 0 additions & 1 deletion compileopts/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type Options struct {
Monitor bool
BaudRate int
Timeout time.Duration
WizerInit bool
}

// Verify performs a validation on the given options, raising an error if options are not valid.
Expand Down
28 changes: 0 additions & 28 deletions goenv/goenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,34 +160,6 @@ func Get(name string) string {

return findWasmOpt()

case "WIZER":
if path := os.Getenv("WIZER"); path != "" {
wizerBin := "wizer"
if runtime.GOOS == "windows" {
wizerBin += ".exe"
}

_, err := exec.LookPath(wizerBin)
if err != nil {
fmt.Fprintf(os.Stderr, "cannot use %q as wasm-opt (from WASMOPT environment variable): %s", path, err.Error())
os.Exit(1)
}

return path
}

wizerBin := "wizer"
if runtime.GOOS == "windows" {
wizerBin += ".exe"
}

path, err := exec.LookPath(wizerBin)
if err != nil {
fmt.Fprintf(os.Stderr, "cannot use %q as wizer: %s", path, err.Error())
os.Exit(1)
}
return path

default:
return ""
}
Expand Down
7 changes: 0 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,6 @@ func main() {
cpuprofile := flag.String("cpuprofile", "", "cpuprofile output")
monitor := flag.Bool("monitor", false, "enable serial monitor")
baudrate := flag.Int("baudrate", 115200, "baudrate of serial monitor")
wizerInit := flag.Bool("wizer-init", false, "use wizer for package initialization")

// Internal flags, that are only intended for TinyGo development.
printIR := flag.Bool("internal-printir", false, "print LLVM IR")
Expand Down Expand Up @@ -1513,11 +1512,6 @@ func main() {
ocdCommands = strings.Split(*ocdCommandsString, ",")
}

if *wizerInit && *target != "wasip1" {
fmt.Fprintf(os.Stderr, "-wizer-init only makes sense with -target=wasip1, got -target=%q\n", *target)
os.Exit(1)
}

options := &compileopts.Options{
GOOS: goenv.Get("GOOS"),
GOARCH: goenv.Get("GOARCH"),
Expand Down Expand Up @@ -1550,7 +1544,6 @@ func main() {
Monitor: *monitor,
BaudRate: *baudrate,
Timeout: *timeout,
WizerInit: *wizerInit,
}

if *printCommands {
Expand Down
7 changes: 3 additions & 4 deletions src/runtime/runtime_wasip1.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func _start() {
run()
}

//export runtime.wizerInit
//export runtime.initialize
func runtimeInitialize() {
if runtimeInitialized {
// Second time initialization is happening. Refresh environment
Expand All @@ -32,10 +32,9 @@ func runtimeInitialize() {
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
initHeap()
initAll()
if hasScheduler {
go initAll()
} else {
initAll()
go func() {}()
}
runtimeInitialized = true
}
Expand Down

0 comments on commit 3ce9cb2

Please sign in to comment.