github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/link_syso_issue33139.txt (about)

     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  [!exec:cc] 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  # External linking is not supported on linux/riscv64.
    12  # See: https://github.com/golang/go/issues/36739
    13  [linux] [riscv64] skip
    14  
    15  # External linking is not supported on darwin/386 (10.14+).
    16  # See: https://github.com/golang/go/issues/31751
    17  [darwin] [386] skip
    18  
    19  cc -c -o syso/objTestImpl.syso syso/src/objTestImpl.c
    20  go build -ldflags='-linkmode=external' ./cmd/main.go
    21  
    22  -- syso/objTest.s --
    23  #include "textflag.h"
    24  
    25  TEXT ·ObjTest(SB), NOSPLIT, $0
    26  	// We do not actually execute this function in the test above, thus
    27  	// there is no stack frame setup here.
    28  	// We only care about Go build and/or link errors when referencing
    29  	// the objTestImpl symbol in the syso file.
    30  	JMP objTestImpl(SB)
    31  
    32  -- syso/pkg.go --
    33  package syso
    34  
    35  func ObjTest()
    36  
    37  -- syso/src/objTestImpl.c --
    38  void objTestImpl() { /* Empty */ }
    39  
    40  -- cmd/main.go --
    41  package main
    42  
    43  import "syso"
    44  
    45  func main() {
    46  	syso.ObjTest()
    47  }