1 # Test that we can use the external linker with a host syso file that is
2 # embedded in a package, that is referenced by a Go assembly function.
3 # See issue 33139.
4 [!gc] skip
5 [!cgo] skip
6
7 # External linking is not supported on linux/ppc64.
8 # See: https://github.com/golang/go/issues/8912
9 [linux] [ppc64] skip
10
11 cc -c -o syso/objTestImpl.syso syso/src/objTestImpl.c
12 go build -ldflags='-linkmode=external' ./cmd/main.go
13
14 -- go.mod --
15 module m
16
17 go 1.16
18 -- syso/objTest.s --
19 #include "textflag.h"
20
21 TEXT ·ObjTest(SB), NOSPLIT, $0
22 // We do not actually execute this function in the test above, thus
23 // there is no stack frame setup here.
24 // We only care about Go build and/or link errors when referencing
25 // the objTestImpl symbol in the syso file.
26 JMP objTestImpl(SB)
27
28 -- syso/pkg.go --
29 package syso
30
31 func ObjTest()
32
33 -- syso/src/objTestImpl.c --
34 void objTestImpl() { /* Empty */ }
35
36 -- cmd/main.go --
37 package main
38
39 import "m/syso"
40
41 func main() {
42 syso.ObjTest()
43 }
44
View as plain text