mirror of https://github.com/golang/go.git
cmd/go: fix failing gccgo cases in TestScript/build_overlay
The 'go install' command does not support the -gccgo flag. (I'm not sure why, but it doesn't.) gccgo also uses system-native assembly syntax instead of cmd/compile's Plan 9 derivative. I've added an assembly file that seems to work on Linux, but I haven't tested it on other platforms; if it fails on other platforms, we can refine the test as needed. Fixes #42688 Change-Id: I0693a6a9eb58975f20cdc4160ef5f9a948563c88 Reviewed-on: https://go-review.googlesource.com/c/go/+/270978 Trust: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
cb674b5c13
commit
e73697b710
|
|
@ -95,12 +95,6 @@ go build -compiler=gccgo -overlay overlay.json -o main_call_asm_gccgo$GOEXE ./ca
|
||||||
exec ./main_call_asm_gccgo$GOEXE
|
exec ./main_call_asm_gccgo$GOEXE
|
||||||
! stdout .
|
! stdout .
|
||||||
|
|
||||||
go install -gccgo -overlay overlay.json ./test_cache
|
|
||||||
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
|
||||||
stdout '^false$'
|
|
||||||
cp overlay/test_cache_different.go overlay/test_cache.go
|
|
||||||
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
|
||||||
stdout '^true$'
|
|
||||||
|
|
||||||
-- m/go.mod --
|
-- m/go.mod --
|
||||||
// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly)
|
// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly)
|
||||||
|
|
@ -128,7 +122,8 @@ the actual code is in the overlay
|
||||||
"dir2/i.go": "overlay/dir2_i.go",
|
"dir2/i.go": "overlay/dir2_i.go",
|
||||||
"printpath/main.go": "overlay/printpath.go",
|
"printpath/main.go": "overlay/printpath.go",
|
||||||
"printpath/other.go": "overlay2/printpath2.go",
|
"printpath/other.go": "overlay2/printpath2.go",
|
||||||
"call_asm/asm.s": "overlay/asm_file.s",
|
"call_asm/asm_gc.s": "overlay/asm_gc.s",
|
||||||
|
"call_asm/asm_gccgo.s": "overlay/asm_gccgo.s",
|
||||||
"test_cache/main.go": "overlay/test_cache.go",
|
"test_cache/main.go": "overlay/test_cache.go",
|
||||||
"cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h",
|
"cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h",
|
||||||
"cgo_hello_replace/hello.c": "overlay/hello.c",
|
"cgo_hello_replace/hello.c": "overlay/hello.c",
|
||||||
|
|
@ -242,17 +237,27 @@ void say_hello();
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void say_hello() { puts("hello cgo\n"); fflush(stdout); }
|
void say_hello() { puts("hello cgo\n"); fflush(stdout); }
|
||||||
-- m/overlay/asm_file.s --
|
-- m/overlay/asm_gc.s --
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
TEXT ·foo(SB),0,$0
|
TEXT ·foo(SB),0,$0
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
-- m/overlay/asm_gccgo.s --
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
.globl main.foo
|
||||||
|
.text
|
||||||
|
main.foo:
|
||||||
|
ret
|
||||||
|
|
||||||
-- m/overlay/test_cache.go --
|
-- m/overlay/test_cache.go --
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func bar() {
|
func bar() {
|
||||||
fmt.Println("something")
|
fmt.Println("something")
|
||||||
}
|
}
|
||||||
-- m/overlay/test_cache_different.go --
|
-- m/overlay/test_cache_different.go --
|
||||||
package foo
|
package foo
|
||||||
|
|
@ -260,7 +265,7 @@ package foo
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func bar() {
|
func bar() {
|
||||||
fmt.Println("different")
|
fmt.Println("different")
|
||||||
}
|
}
|
||||||
-- m/cgo_hello_quote/hello.c --
|
-- m/cgo_hello_quote/hello.c --
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -275,29 +280,29 @@ void say_hello() { puts("hello cgo\n"); fflush(stdout); }
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
compiledGoFilesArg := os.Args[1]
|
compiledGoFilesArg := os.Args[1]
|
||||||
b, err := ioutil.ReadFile(compiledGoFilesArg)
|
b, err := ioutil.ReadFile(compiledGoFilesArg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n")
|
compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n")
|
||||||
for _, f := range compiledGoFiles {
|
for _, f := range compiledGoFiles {
|
||||||
b, err := ioutil.ReadFile(f)
|
b, err := ioutil.ReadFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, line := range strings.Split(string(b), "\n") {
|
for _, line := range strings.Split(string(b), "\n") {
|
||||||
if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") {
|
if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") {
|
||||||
fmt.Println(line)
|
fmt.Println(line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue