Linker command failing for particular go tests involving net/http and time packages

145 views
Skip to first unread message

Rahul Rahul

unread,
Jun 24, 2021, 3:02:56 PM6/24/21
to golang-nuts
I'm running a go test to test a function that pings to websites, and returns which one gives me the faster response. The test file is called 'hello_test.go'. This is the code for the test
hello_test.go
Now, this is how my actual function looks like hello.go (the one giving error). hello_test.go and hello.go are in the same folder. My go mod file looks like this,
         module module
         go 1.16

When I'm trying to test this code by running go test , It is throwing me an error saying,
# runtime/cgo
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libpthread.tbd' for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
FAIL    module [build failed]

The test is working fine when I changed CG_ENABLED=0. I don't know why I need to do this. because until before all the tests involving other library imports are working fine. So what is happening in this case? I have added all the details in this mail and also you can find the same details in this post 

  • This is my go build -x  looks like,

WORK=/var/folders/zc/4r25vdyj4cv3ynjx64633ly40000gn/T/go-build1145672344

mkdir -p $WORK/b084/

cd /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo

TERM='dumb' CGO_LDFLAGS='"-g" "-O2" "-lpthread"' /usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64/cgo -objdir $WORK/b084/ -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false -- -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror ./cgo.go

cd $WORK

x86_64-apple-darwin13.4.0-clang -fno-caret-diagnostics -c -x c - -o /dev/null || true

x86_64-apple-darwin13.4.0-clang -Qunused-arguments -c -x c - -o /dev/null || true

x86_64-apple-darwin13.4.0-clang -fdebug-prefix-map=a=b -c -x c - -o /dev/null || true

x86_64-apple-darwin13.4.0-clang -gno-record-gcc-switches -c -x c - -o /dev/null || true

cd $WORK/b084

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_x001.o -c _cgo_export.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_x002.o -c cgo.cgo2.c

cd /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x003.o -c gcc_context.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x004.o -c gcc_darwin_amd64.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x005.o -c gcc_libinit.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x006.o -c gcc_setenv.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x007.o -c gcc_traceback.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x008.o -c gcc_util.c

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I . -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I $WORK/b084/ -g -O2 -Wno-nullability-completeness -Wall -Werror -o $WORK/b084/_x009.o -c gcc_amd64.S

cd $WORK/b084

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -Wno-nullability-completeness -Wall -Werror -o ./_cgo_main.o -c _cgo_main.c

cd /Users/kavlraghu/hello

TERM='dumb' x86_64-apple-darwin13.4.0-clang -I /usr/local/Cellar/go/1.16.5/libexec/src/runtime/cgo -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b084=/tmp/go-build -gno-record-gcc-switches -fno-common -o $WORK/b084/_cgo_.o $WORK/b084/_cgo_main.o $WORK/b084/_x001.o $WORK/b084/_x002.o $WORK/b084/_x003.o $WORK/b084/_x004.o $WORK/b084/_x005.o $WORK/b084/_x006.o $WORK/b084/_x007.o $WORK/b084/_x008.o $WORK/b084/_x009.o -g -O2 -lpthread

# runtime/cgo

ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64

clang-10: error: linker command failed with exit code 1 (use -v to see invocation)


  • This is how my go env looks like

GO111MODULE=""

GOARCH="amd64"

GOBIN=""

GOCACHE="/Users/kavlraghu/Library/Caches/go-build"

GOENV="/Users/kavlraghu/Library/Application Support/go/env"

GOEXE=""

GOFLAGS=""

GOHOSTARCH="amd64"

GOHOSTOS="darwin"

GOINSECURE=""

GOMODCACHE="/Users/kavlraghu/go/pkg/mod"

GONOPROXY=""

GONOSUMDB=""

GOOS="darwin"

GOPATH="/Users/kavlraghu/go"

GOPRIVATE=""

GOPROXY="https://proxy.golang.org,direct"

GOROOT="/usr/local/Cellar/go/1.16.5/libexec"

GOSUMDB="sum.golang.org"

GOTMPDIR=""

GOTOOLDIR="/usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64"

GOVCS=""

GOVERSION="go1.16.5"

GCCGO="gccgo"

AR="/Users/kavlraghu/opt/anaconda3/bin/x86_64-apple-darwin13.4.0-ar"

CC="x86_64-apple-darwin13.4.0-clang"

CXX="x86_64-apple-darwin13.4.0-clang++"

CGO_ENABLED="1"

GOMOD="/Users/kavlraghu/hello/go.mod"

CGO_CFLAGS="-g -O2"

CGO_CPPFLAGS=""

CGO_CXXFLAGS="-g -O2"

CGO_FFLAGS="-g -O2"

CGO_LDFLAGS="-g -O2"

PKG_CONFIG="pkg-config"

GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zc/4r25vdyj4cv3ynjx64633ly40000gn/T/go-build3328850597=/tmp/go-build -gno-record-gcc-switches -fno-common"


  • The test is working when I run CGO_ENABLED=0 go test -v ./...  
The output is just as expect. So it is working with CGO_ENABLED=0

=== RUN   TestRacer

    hello_test.go:13: got "http://www.facebook.com", want "http://www.quii.co.uk"

--- FAIL: TestRacer (4.44s)

FAIL

FAIL module 4.928s

FAIL

  • I'm running the code on Macbook Air , Intel processor

Thank you

Reply all
Reply to author
Forward
0 new messages