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

     1  [!cgo] skip
     2  
     3  # Require that CC is something that requires a PATH lookup.
     4  # Normally, the default is gcc or clang, but if CC was set during make.bash,
     5  # that becomes the default.
     6  [!cc:clang] [!cc:gcc] skip 'C compiler is not gcc or clang'
     7  
     8  env GOCACHE=$WORK/gocache  # Looking for compile flags, so need a clean cache.
     9  [!GOOS:windows] env PATH=.:$PATH
    10  [!GOOS:windows] chmod 0755 p/gcc p/clang
    11  [!GOOS:windows] exists -exec p/gcc p/clang
    12  [GOOS:windows] exists -exec p/gcc.bat p/clang.bat
    13  ! exists p/bug.txt
    14  ! go build -x
    15  stderr '^cgo: C compiler "(clang|gcc)" not found: exec: "(clang|gcc)": cannot run executable found relative to current directory'
    16  ! exists p/bug.txt
    17  
    18  -- go.mod --
    19  module m
    20  
    21  -- m.go --
    22  package m
    23  
    24  import _ "m/p"
    25  
    26  -- p/p.go --
    27  package p
    28  
    29  // #define X 1
    30  import "C"
    31  
    32  -- p/gcc --
    33  #!/bin/sh
    34  echo ran gcc >bug.txt
    35  -- p/clang --
    36  #!/bin/sh
    37  echo ran clang >bug.txt
    38  -- p/gcc.bat --
    39  echo ran gcc >bug.txt
    40  -- p/clang.bat --
    41  echo ran clang >bug.txt
    42  

View as plain text