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

     1  # Test cross-compiling a cgo-binding binary to aix/ppc64.
     2  
     3  [short] skip
     4  
     5  # Cross-compiling a cgo-binding binary to aix/ppc64 without a working AIX C
     6  # toolchain produces a clear error, while a working CC cross-compiler links.
     7  cd aixbind
     8  env CGO_ENABLED=bindings
     9  env GOOS=aix
    10  env GOARCH=ppc64
    11  env GOEXPERIMENT=$GOEXPERIMENT,runtimecgopurego,cgobindings
    12  # On an AIX host, the default CC is a working AIX toolchain.
    13  [!GOOS:aix] env CC=
    14  [!GOOS:aix] ! go build -o $devnull .
    15  [!GOOS:aix] stderr 'cgo bindings on aix/ppc64 require an external linker'
    16  env CC=$WORK${/}nonexistent
    17  ! go build -o $devnull .
    18  stderr 'cgo bindings on aix/ppc64 require an external linker'
    19  [GOOS:windows] stop
    20  [!exec:sh] stop
    21  chmod 0755 $WORK/gopath/src/fake-aix-cc.sh
    22  env CC=$WORK/gopath/src/fake-aix-cc.sh
    23  go build -o $WORK/aix.exe .
    24  exists $WORK/aix.exe
    25  
    26  -- fake-aix-cc.sh --
    27  #!/bin/sh
    28  for arg in "$@"; do
    29  	case "$arg" in
    30  	-Wl,-V)
    31  		echo "/usr/bin/ld: LD 7.2.2(1/1/19)"
    32  		echo "ld: 0711-317 ERROR: Undefined symbol: .main"
    33  		exit 1
    34  		;;
    35  	--print-file-name=*)
    36  		echo "/lib/${arg#--print-file-name=}"
    37  		exit 0
    38  		;;
    39  	esac
    40  done
    41  prev=""
    42  for arg in "$@"; do
    43  	if [ "$prev" = "-o" ]; then : > "$arg"; exit 0; fi
    44  	prev="$arg"
    45  done
    46  exit 0
    47  
    48  -- aixbind/go.mod --
    49  module aixbind
    50  
    51  go 1.28
    52  
    53  -- aixbind/main.go --
    54  package main
    55  
    56  import "C"
    57  
    58  //cgo:func puts puts libc
    59  func puts(s *byte) int32
    60  
    61  func main() {
    62  	puts(nil)
    63  }
    64  

View as plain text