Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: misplaced compiler directive for standard library #40852

Closed
tdewolff opened this issue Aug 18, 2020 · 9 comments
Closed

cmd/compile: misplaced compiler directive for standard library #40852

tdewolff opened this issue Aug 18, 2020 · 9 comments

Comments

@tdewolff
Copy link

@tdewolff tdewolff commented Aug 18, 2020

What version of Go are you using (go version)?

$ go version
go version go1.15 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/taco/.cache/go-build"
GOENV="/home/taco/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/taco/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/taco/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/taco/go/src/github.com/tdewolff/minify/tests/js/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build929567383=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Running go-fuzz-build for my fuzz tests.

What did you expect to see?

I expected it to compile.

What did you see instead?

It seems the standard library is throwing errors with the new "misplaced compiler directive" error. In particular, the following errors were thrown, but to me these compiler directives seem to be used correctly?

/usr/lib/go/src/vendor/golang.org/x/crypto/poly1305/sum_amd64.go:9: misplaced compiler directive
/usr/lib/go/src/crypto/sha256/sha256block_decl.go:9: misplaced compiler directive
/usr/lib/go/src/reflect/value.go:1432: misplaced compiler directive
@randall77
Copy link
Contributor

@randall77 randall77 commented Aug 18, 2020

They all look fine to me as well.

I'm confused as to how you're getting these errors. Running all.bash works fine. What is go-fuzz-build? How is it different from other tools? Can you run with -x or the equivalent and show us what command is generating the errors?

The compiler and the cover tool can both generate that error text. Maybe it is the cover tool? That probably isn't run during all.bash. Does go-fuzz-build use the cover tool?

@josharian
Copy link
Contributor

@josharian josharian commented Aug 18, 2020

go-fuzz-build does a source to source translation and then builds. I thought it did the right thing with compiler directives, but it wouldn't surprise me to learn that there are bugs. Would you mind filing an issue at github.com/dvyukov/go-fuzz and closing this one? Thanks.

@tdewolff
Copy link
Author

@tdewolff tdewolff commented Aug 18, 2020

You're right, I should've filed there first. I thought it was a Go 1.15 issue but sounds more like a Go fuzz issue. Thanks and sorry for the trouble.

@tdewolff tdewolff closed this Aug 18, 2020
@kirk-baird
Copy link

@kirk-baird kirk-baird commented Aug 18, 2020

I too have just started having this issue when building go-fuzz on go 1.15 problem was solved by downgrading to 1.14. Worth raising an issue on the go-fuzz repo :)

@tdewolff
Copy link
Author

@tdewolff tdewolff commented Aug 18, 2020

This will be tracked in dvyukov/go-fuzz#294

@dgryski
Copy link
Contributor

@dgryski dgryski commented Aug 18, 2020

I thought it was an issue with go/printer ? #40546

@oraluben
Copy link

@oraluben oraluben commented Aug 19, 2020

Hi @kirk-baird , would you provide a repro for the 1.14-working source? Here it's happening on all version.

@kirk-baird
Copy link

@kirk-baird kirk-baird commented Aug 19, 2020

Hi @kirk-baird , would you provide a repro for the 1.14-working source? Here it's happening on all version.

Sure, this fuzz target works for 1.14 but will fail for me when i upgrade to 1.15 https://github.com/kirk-baird/drand/blob/fuzz/fuzz/fuzz.go.

The compile error is

└> go-fuzz-build
failed to execute go build: exit status 2
# crypto/sha256
/usr/lib/go/src/crypto/sha256/sha256block_decl.go:9: misplaced compiler directive
# vendor/golang.org/x/crypto/poly1305
/usr/lib/go/src/vendor/golang.org/x/crypto/poly1305/sum_amd64.go:9: misplaced compiler directive
@oraluben
Copy link

@oraluben oraluben commented Aug 19, 2020

Sure, this fuzz target works for 1.14 but will fail for me when i upgrade to 1.15 https://github.com/kirk-baird/drand/blob/fuzz/fuzz/fuzz.go.

Thanks for that! I found that at least the go/printer issue exists in both version, but it's interesting why 1.14 didn't raise an error. I assume it's something related to compilation.

go-fuzz-build generated file:

...
//line /Users/yyc/go/go1.14.7/src/vendor/golang.org/x/crypto/poly1305/sum_amd64.go:7
package poly1305

//line /Users/yyc/go/go1.14.7/src/vendor/golang.org/x/crypto/poly1305/sum_amd64.go:7
import

//go:noescape
//line /Users/yyc/go/go1.14.7/src/vendor/golang.org/x/crypto/poly1305/sum_amd64.go:7
_go_fuzz_dep_ "go-fuzz-dep"
...

As for the go/printer issue, I don't think it's a bug 100%, and a workaround could be patched in go-fuzz. I will update what I've found at #40546 and dvyukov/go-fuzz#294.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.