Text file src/cmd/go/testdata/script/link_syso_issue33139.txt

     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  
    13  cc -c -o syso/objTestImpl.syso syso/src/objTestImpl.c
    14  go build -ldflags='-linkmode=external' ./cmd/main.go
    15  
    16  -- go.mod --
    17  module m
    18  
    19  go 1.16
    20  -- syso/objTest.s --
    21  #include "textflag.h"
    22  
    23  TEXT ·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 --
    31  package syso
    32  
    33  func ObjTest()
    34  
    35  -- syso/src/objTestImpl.c --
    36  void objTestImpl() { /* Empty */ }
    37  
    38  -- cmd/main.go --
    39  package main
    40  
    41  import "m/syso"
    42  
    43  func main() {
    44  	syso.ObjTest()
    45  }
    46  

View as plain text