go-fuzz icon indicating copy to clipboard operation
go-fuzz copied to clipboard

fuzz doesn't work with the new fortran linker

Open btracey opened this issue 8 years ago • 4 comments

I am trying to fuzz some Go code against the (suposedly) equivalent fortran code. I am seeing a linker error with go-fuzz-build that I am not seeing with go build

brendan:~/Documents/mygo/src$ go version
go version devel +7177cb9 Tue Mar 22 17:30:30 2016 +0000 darwin/amd64
brendan:~/Documents/mygo/src$ go get -u -t github.com/dvyukov/go-fuzz/go-fuzz
brendan:~/Documents/mygo/src$ go get -u -t github.com/dvyukov/go-fuzz/go-fuzz-build
brendan:~/Documents/mygo/src$ go build github.com/btracey/amosfuzz/amos/amostest/fuzz/
brendan:~/Documents/mygo/src$ go-fuzz-build github.com/btracey/amosfuzz/amos/amostest/fuzz/
failed to execute go build: exit status 2
# go.fuzz.main
/var/folders/s0/2lsmv0jd7x37kkxmc_q6wyj80000gn/T/go-fuzz-build517577423/src/go.fuzz.main/main.go:5: non-canonical import path "github.com/btracey/amosfuzz/amos/amostest/fuzz/" (should be "github.com/btracey/amosfuzz/amos/amostest/fuzz")
/var/folders/s0/2lsmv0jd7x37kkxmc_q6wyj80000gn/T/go-fuzz-build517577423/src/go.fuzz.main/main.go:5: can't find import: "github.com/btracey/amosfuzz/amos/amostest/fuzz/"

I do not think this is a duplicate of #101 . I have somewhat equivalent code (though with c wrappers) at github.com/btracey/blasfuzz and it works just fine.

btracey avatar Mar 23 '16 15:03 btracey

Sorry, one moment, that's a different error.

btracey avatar Mar 23 '16 15:03 btracey

I'm not sure what's happening in that code snippet, but this is what I see with almost equivalent code in a different place

brendan:~/Documents/mygo/src$ go build blah.com/mathext/amos/airytest/fuzz/
brendan:~/Documents/mygo/src$ go-fuzz-build blah.com/mathext/amos/airytest/fuzz
failed to execute go build: exit status 2
# blah.com/mathext/amos/airytest
Undefined symbols for architecture x86_64:
  "_zs1s2_", referenced from:
      __cgo_4cc63b68db0e_Cfunc_zs1s2_ in fortran.cgo2.o
     (maybe you meant: __cgo_4cc63b68db0e_Cfunc_zs1s2_)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

btracey avatar Mar 23 '16 15:03 btracey

Ah, I see, the original code snippet had a trailing / that is evidently allowed with go build but not go fuzz build

Here is the correct report. Sorry for the noise.

brendan:~/Documents/mygo/src$ go version
go version devel +7177cb9 Tue Mar 22 17:30:30 2016 +0000 darwin/amd64
brendan:~/Documents/mygo/src$ go get -u -t github.com/dvyukov/go-fuzz/go-fuzz
brendan:~/Documents/mygo/src$ go get -u -t github.com/dvyukov/go-fuzz/go-fuzz-build
brendan:~/Documents/mygo/src$ go build github.com/btracey/amosfuzz/amos/amostest/fuzz
brendan:~/Documents/mygo/src$ go-fuzz-build github.com/btracey/amosfuzz/amos/amostest/fuzz
failed to execute go build: exit status 2
# github.com/btracey/amosfuzz/amos/amostest
Undefined symbols for architecture x86_64:
  "_zs1s2_", referenced from:
      __cgo_89d2cf6f37ae_Cfunc_zs1s2_ in fortran.cgo2.o
     (maybe you meant: __cgo_89d2cf6f37ae_Cfunc_zs1s2_)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

btracey avatar Mar 23 '16 16:03 btracey

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/brendan/Documents/mygo"
GORACE=""
GOROOT="/Users/brendan/gover/go"
GOTOOLDIR="/Users/brendan/gover/go/pkg/tool/darwin_amd64"
CC="gcc-5"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/var/folders/s0/2lsmv0jd7x37kkxmc_q6wyj80000gn/T/go-build627340727=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="g++-5"
CGO_ENABLED="1"

btracey avatar Mar 23 '16 16:03 btracey