Skip to content

Commit e73697b

Browse files
author
Bryan C. Mills
committed
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 <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent cb674b5 commit e73697b

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

src/cmd/go/testdata/script/build_overlay.txt

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ go build -compiler=gccgo -overlay overlay.json -o main_call_asm_gccgo$GOEXE ./ca
9595
exec ./main_call_asm_gccgo$GOEXE
9696
! stdout .
9797

98-
go install -gccgo -overlay overlay.json ./test_cache
99-
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
100-
stdout '^false$'
101-
cp overlay/test_cache_different.go overlay/test_cache.go
102-
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
103-
stdout '^true$'
10498

10599
-- m/go.mod --
106100
// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly)
@@ -128,7 +122,8 @@ the actual code is in the overlay
128122
"dir2/i.go": "overlay/dir2_i.go",
129123
"printpath/main.go": "overlay/printpath.go",
130124
"printpath/other.go": "overlay2/printpath2.go",
131-
"call_asm/asm.s": "overlay/asm_file.s",
125+
"call_asm/asm_gc.s": "overlay/asm_gc.s",
126+
"call_asm/asm_gccgo.s": "overlay/asm_gccgo.s",
132127
"test_cache/main.go": "overlay/test_cache.go",
133128
"cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h",
134129
"cgo_hello_replace/hello.c": "overlay/hello.c",
@@ -242,25 +237,35 @@ void say_hello();
242237
#include <stdio.h>
243238

244239
void say_hello() { puts("hello cgo\n"); fflush(stdout); }
245-
-- m/overlay/asm_file.s --
240+
-- m/overlay/asm_gc.s --
241+
// +build !gccgo
242+
246243
TEXT ·foo(SB),0,$0
247244
RET
248245

246+
-- m/overlay/asm_gccgo.s --
247+
// +build gccgo
248+
249+
.globl main.foo
250+
.text
251+
main.foo:
252+
ret
253+
249254
-- m/overlay/test_cache.go --
250255
package foo
251256

252257
import "fmt"
253258

254259
func bar() {
255-
fmt.Println("something")
260+
fmt.Println("something")
256261
}
257262
-- m/overlay/test_cache_different.go --
258263
package foo
259264

260265
import "fmt"
261266

262267
func bar() {
263-
fmt.Println("different")
268+
fmt.Println("different")
264269
}
265270
-- m/cgo_hello_quote/hello.c --
266271
#include <stdio.h>
@@ -275,29 +280,29 @@ void say_hello() { puts("hello cgo\n"); fflush(stdout); }
275280
package main
276281

277282
import (
278-
"fmt"
279-
"io/ioutil"
280-
"log"
281-
"os"
282-
"strings"
283+
"fmt"
284+
"io/ioutil"
285+
"log"
286+
"os"
287+
"strings"
283288
)
284289

285290
func main() {
286-
compiledGoFilesArg := os.Args[1]
287-
b, err := ioutil.ReadFile(compiledGoFilesArg)
288-
if err != nil {
289-
log.Fatal(err)
290-
}
291-
compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n")
292-
for _, f := range compiledGoFiles {
293-
b, err := ioutil.ReadFile(f)
294-
if err != nil {
295-
log.Fatal(err)
296-
}
297-
for _, line := range strings.Split(string(b), "\n") {
298-
if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") {
299-
fmt.Println(line)
300-
}
301-
}
302-
}
291+
compiledGoFilesArg := os.Args[1]
292+
b, err := ioutil.ReadFile(compiledGoFilesArg)
293+
if err != nil {
294+
log.Fatal(err)
295+
}
296+
compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n")
297+
for _, f := range compiledGoFiles {
298+
b, err := ioutil.ReadFile(f)
299+
if err != nil {
300+
log.Fatal(err)
301+
}
302+
for _, line := range strings.Split(string(b), "\n") {
303+
if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") {
304+
fmt.Println(line)
305+
}
306+
}
307+
}
303308
}

0 commit comments

Comments
 (0)