mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
refactor: reuse OptLevel() to get the opt level
This commit is contained in:
+2
-15
@@ -807,21 +807,8 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
|
|||||||
|
|
||||||
// Run wasm-opt for wasm binaries
|
// Run wasm-opt for wasm binaries
|
||||||
if arch := strings.Split(config.Triple(), "-")[0]; arch == "wasm32" {
|
if arch := strings.Split(config.Triple(), "-")[0]; arch == "wasm32" {
|
||||||
var opt string
|
optLevel, _, _ := config.OptLevel()
|
||||||
switch config.Options.Opt {
|
opt := "-" + optLevel
|
||||||
case "none", "0":
|
|
||||||
opt = "-O0"
|
|
||||||
case "1":
|
|
||||||
opt = "-O1"
|
|
||||||
case "2":
|
|
||||||
opt = "-O2"
|
|
||||||
case "s":
|
|
||||||
opt = "-Os"
|
|
||||||
case "z":
|
|
||||||
opt = "-Oz"
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unknown opt level: %q", config.Options.Opt)
|
|
||||||
}
|
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user