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