...

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

Documentation: cmd/go/testdata/script

     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[!GOOS:windows] chmod 0755 $WORK/'program files'/clang
    14[!GOOS:windows] chmod 0755 $WORK/'program files'/gcc
    15[!GOOS:windows] exists -exec $WORK/'program files'/clang
    16[!GOOS:windows] exists -exec $WORK/'program files'/gcc
    17[!GOOS:windows] env PATH=$WORK/'program files':$PATH
    18[GOOS:windows] exists -exec $WORK/'program files'/gcc.bat
    19[GOOS:windows] exists -exec $WORK/'program files'/clang.bat
    20[GOOS:windows] env PATH=$WORK\'program files';%PATH%
    21
    22! exists $WORK/log.txt
    23? go build -x
    24exists $WORK/log.txt
    25rm $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[!GOOS:windows] env CC=$WORK/'program files'/gcc
    32[GOOS:windows] env CC=$WORK\'program files'\gcc.bat
    33! go build -x
    34! exists $WORK/log.txt
    35
    36-- go.mod --
    37module m
    38
    39-- m.go --
    40package m
    41
    42// #define X 1
    43import "C"
    44
    45-- $WORK/program files/gcc --
    46#!/bin/sh
    47
    48echo ok >$WORK/log.txt
    49-- $WORK/program files/clang --
    50#!/bin/sh
    51
    52echo ok >$WORK/log.txt
    53-- $WORK/program files/gcc.bat --
    54echo ok >%WORK%\log.txt
    55-- $WORK/program files/clang.bat --
    56echo ok >%WORK%\log.txt

View as plain text