aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDamian Gryski <[email protected]>2024-05-30 21:01:50 -0700
committerDamian Gryski <[email protected]>2024-05-31 11:20:04 -0700
commit272fea13e71b677c4fa40a0315c89cf97cbd84d7 (patch)
treee48a1ab1529b8efac1ac731651c3a84683fcfc08
parentb6fd0c818e1fa0393cd667183f453a638ea6fdf6 (diff)
downloadtinygo-272fea13e71b677c4fa40a0315c89cf97cbd84d7.tar.gz
tinygo-272fea13e71b677c4fa40a0315c89cf97cbd84d7.zip
builder: keep un-wasm-opt'd .wasm if -work was passed
-rw-r--r--builder/build.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/builder/build.go b/builder/build.go
index 940439667..e415781fe 100644
--- a/builder/build.go
+++ b/builder/build.go
@@ -825,10 +825,18 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
args = append(args, "--asyncify")
}
+ exeunopt := result.Executable
+
+ if config.Options.Work {
+ // Keep the work direction around => don't overwrite the .wasm binary with the optimized version
+ exeunopt += ".pre-wasm-opt"
+ os.Rename(result.Executable, exeunopt)
+ }
+
args = append(args,
opt,
"-g",
- result.Executable,
+ exeunopt,
"--output", result.Executable,
)