2014-12-22 16:26:21 -07:00
|
|
|
// +build !nacl,!windows
|
2012-02-16 21:49:59 -07:00
|
|
|
// run
|
2011-10-03 15:46:36 -06:00
|
|
|
|
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Test that compiling with optimization turned on produces faster code.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-12-18 11:34:12 -07:00
|
|
|
"fmt"
|
2011-10-03 15:46:36 -06:00
|
|
|
"os"
|
2014-12-18 11:34:12 -07:00
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
2011-10-03 15:46:36 -06:00
|
|
|
)
|
|
|
|
|
2014-12-18 11:34:12 -07:00
|
|
|
func main() {
|
2015-05-21 11:28:17 -06:00
|
|
|
err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir"))
|
2014-12-18 11:34:12 -07:00
|
|
|
check(err)
|
|
|
|
|
2015-05-21 11:28:17 -06:00
|
|
|
run("go", "tool", "compile", "-N", "-o", "slow.o", "pkg.go")
|
|
|
|
run("go", "tool", "compile", "-o", "fast.o", "pkg.go")
|
|
|
|
run("go", "tool", "compile", "-o", "main.o", "main.go")
|
|
|
|
run("go", "tool", "link", "-o", "a.exe", "main.o")
|
2014-12-18 11:34:12 -07:00
|
|
|
run("." + string(filepath.Separator) + "a.exe")
|
|
|
|
|
2015-05-21 11:28:17 -06:00
|
|
|
os.Remove("slow.o")
|
|
|
|
os.Remove("fast.o")
|
|
|
|
os.Remove("main.o")
|
2014-12-18 11:34:12 -07:00
|
|
|
os.Remove("a.exe")
|
2011-10-03 15:46:36 -06:00
|
|
|
}
|
|
|
|
|
2014-12-18 11:34:12 -07:00
|
|
|
func run(name string, args ...string) {
|
|
|
|
cmd := exec.Command(name, args...)
|
|
|
|
out, err := cmd.CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(string(out))
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
2011-10-03 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-18 11:34:12 -07:00
|
|
|
func check(err error) {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
2011-10-03 15:46:36 -06:00
|
|
|
}
|
|
|
|
}
|