refactor: reuse OptLevel() to get the opt level

Этот коммит содержится в:
Rado M 2023-11-20 15:36:41 +02:00 коммит произвёл Ron Evans
родитель d4189feca6
коммит 9b896dc981

Просмотреть файл

@ -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