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

     1  # Check that if the PATH directory containing the C compiler has a space,
     2  # we can still use that compiler with cgo.
     3  # Verifies #43808.
     4  [!cgo] skip
     5  
     6  # Set CC explicitly to something that requires a PATH lookup.
     7  # Normally, the default is gcc or clang, but if CC was set during make.bash,
     8  # that becomes the default.
     9  [exec:clang] env CC=clang
    10  [exec:gcc] env CC=gcc
    11  [!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
    12  
    13  [!windows] chmod 0755 $WORK/'program files'/clang
    14  [!windows] chmod 0755 $WORK/'program files'/gcc
    15  [!windows] exists -exec $WORK/'program files'/clang
    16  [!windows] exists -exec $WORK/'program files'/gcc
    17  [!windows] env PATH=$WORK/'program files':$PATH
    18  [windows] exists -exec $WORK/'program files'/gcc.bat
    19  [windows] exists -exec $WORK/'program files'/clang.bat
    20  [windows] env PATH=$WORK\'program files';%PATH%
    21  
    22  ! exists $WORK/log.txt
    23  ? go build -x
    24  exists $WORK/log.txt
    25  rm $WORK/log.txt
    26  
    27  # TODO(#41400, #43078): when CC is set explicitly, it should be allowed to
    28  # contain spaces separating arguments, and it should be possible to quote
    29  # arguments with spaces (including the path), as in CGO_CFLAGS and other
    30  # variables. For now, this doesn't work.
    31  [!windows] env CC=$WORK/'program files'/gcc
    32  [windows] env CC=$WORK\'program files'\gcc.bat
    33  ! go build -x
    34  ! exists $WORK/log.txt
    35  
    36  -- go.mod --
    37  module m
    38  
    39  -- m.go --
    40  package m
    41  
    42  // #define X 1
    43  import "C"
    44  
    45  -- $WORK/program files/gcc --
    46  #!/bin/sh
    47  
    48  echo ok >$WORK/log.txt
    49  -- $WORK/program files/clang --
    50  #!/bin/sh
    51  
    52  echo ok >$WORK/log.txt
    53  -- $WORK/program files/gcc.bat --
    54  echo ok >%WORK%\log.txt
    55  -- $WORK/program files/clang.bat --
    56  echo ok >%WORK%\log.txt
    57  

View as plain text