Skip to content

Commit 124d93b

Browse files
committed
all: rip out actually calling wizer; just leave runtime patches
1 parent 59e92ac commit 124d93b

File tree

5 files changed

+3
-72
lines changed

5 files changed

+3
-72
lines changed

builder/build.go

-31
Original file line numberDiff line numberDiff line change
@@ -854,37 +854,6 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
854854
}
855855
}
856856

857-
if config.Options.WizerInit {
858-
var args []string
859-
860-
resultWizer := result.Executable + "-wizer"
861-
862-
args = append(args,
863-
"--allow-wasi",
864-
"--wasm-bulk-memory=true",
865-
"-f", "runtime.wizerInit",
866-
result.Executable,
867-
"-o", resultWizer,
868-
)
869-
870-
if config.Options.PrintCommands != nil {
871-
config.Options.PrintCommands(goenv.Get("WIZER"), args...)
872-
}
873-
874-
cmd := exec.Command(goenv.Get("WIZER"), args...)
875-
cmd.Stdout = os.Stdout
876-
cmd.Stderr = os.Stderr
877-
878-
err := cmd.Run()
879-
if err != nil {
880-
return fmt.Errorf("wizer failed: %w", err)
881-
}
882-
883-
if err := os.Rename(resultWizer, result.Executable); err != nil {
884-
return fmt.Errorf("rename failed: %w", err)
885-
}
886-
}
887-
888857
// Print code size if requested.
889858
if config.Options.PrintSizes == "short" || config.Options.PrintSizes == "full" {
890859
packagePathMap := make(map[string]string, len(lprogram.Packages))

compileopts/options.go

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ type Options struct {
5353
Monitor bool
5454
BaudRate int
5555
Timeout time.Duration
56-
WizerInit bool
5756
}
5857

5958
// Verify performs a validation on the given options, raising an error if options are not valid.

goenv/goenv.go

-29
Original file line numberDiff line numberDiff line change
@@ -159,35 +159,6 @@ func Get(name string) string {
159159
}
160160

161161
return findWasmOpt()
162-
163-
case "WIZER":
164-
if path := os.Getenv("WIZER"); path != "" {
165-
wizerBin := "wizer"
166-
if runtime.GOOS == "windows" {
167-
wizerBin += ".exe"
168-
}
169-
170-
_, err := exec.LookPath(wizerBin)
171-
if err != nil {
172-
fmt.Fprintf(os.Stderr, "cannot use %q as wasm-opt (from WASMOPT environment variable): %s", path, err.Error())
173-
os.Exit(1)
174-
}
175-
176-
return path
177-
}
178-
179-
wizerBin := "wizer"
180-
if runtime.GOOS == "windows" {
181-
wizerBin += ".exe"
182-
}
183-
184-
path, err := exec.LookPath(wizerBin)
185-
if err != nil {
186-
fmt.Fprintf(os.Stderr, "cannot use %q as wizer: %s", path, err.Error())
187-
os.Exit(1)
188-
}
189-
return path
190-
191162
default:
192163
return ""
193164
}

main.go

-7
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,6 @@ func main() {
14401440
cpuprofile := flag.String("cpuprofile", "", "cpuprofile output")
14411441
monitor := flag.Bool("monitor", false, "enable serial monitor")
14421442
baudrate := flag.Int("baudrate", 115200, "baudrate of serial monitor")
1443-
wizerInit := flag.Bool("wizer-init", false, "use wizer for package initialization")
14441443

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

1516-
if *wizerInit && *target != "wasip1" {
1517-
fmt.Fprintf(os.Stderr, "-wizer-init only makes sense with -target=wasip1, got -target=%q\n", *target)
1518-
os.Exit(1)
1519-
}
1520-
15211515
options := &compileopts.Options{
15221516
GOOS: goenv.Get("GOOS"),
15231517
GOARCH: goenv.Get("GOARCH"),
@@ -1550,7 +1544,6 @@ func main() {
15501544
Monitor: *monitor,
15511545
BaudRate: *baudrate,
15521546
Timeout: *timeout,
1553-
WizerInit: *wizerInit,
15541547
}
15551548

15561549
if *printCommands {

src/runtime/runtime_wasip1.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func _start() {
1919
run()
2020
}
2121

22-
//export runtime.wizerInit
22+
//export runtime.initialize
2323
func runtimeInitialize() {
2424
if runtimeInitialized {
2525
// Second time initialization is happening. Refresh environment
@@ -32,10 +32,9 @@ func runtimeInitialize() {
3232
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
3333
heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
3434
initHeap()
35+
initAll()
3536
if hasScheduler {
36-
go initAll()
37-
} else {
38-
initAll()
37+
go func() {}()
3938
}
4039
runtimeInitialized = true
4140
}

0 commit comments

Comments
 (0)