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/go: go build fails in module mode when all source files are symlinks #31703

Closed
y3llowcake opened this issue Apr 26, 2019 · 3 comments
Closed

Comments

@y3llowcake
Copy link

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

% go version
go version go1.12.2 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cy/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/cy/go"
GOPROXY=""
GORACE=""
GOROOT="/home/cy/go/go1.12.2"
GOTMPDIR=""
GOTOOLDIR="/home/cy/go/go1.12.2/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/cy/tmp/gobuildsymlinks/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-build527931708=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When I have a directory that contains only symlinks to .go source files, and I am in module mode, go build fails.

Not using module mode, or adding a single non-symlink file as a workaround, fixes the issue.

% ls -laR
.:
total 16
drwxrwxr-x  4 cy cy 4096 Apr 26 15:01 .
drwxrwxr-x 38 cy cy 4096 Apr 26 14:58 ..
drwxrwxr-x  2 cy cy 4096 Apr 26 14:59 real
drwxrwxr-x  2 cy cy 4096 Apr 26 15:00 sym

./real:
total 12
drwxrwxr-x 2 cy cy 4096 Apr 26 14:59 .
drwxrwxr-x 4 cy cy 4096 Apr 26 15:01 ..
-rw-rw-r-- 1 cy cy   66 Apr 26 14:59 main.go

./sym:
total 8
drwxrwxr-x 2 cy cy 4096 Apr 26 15:00 .
drwxrwxr-x 4 cy cy 4096 Apr 26 15:01 ..
lrwxrwxrwx 1 cy cy   15 Apr 26 15:00 main.go -> ../real/main.go

% go build -o /dev/null ./sym

% go mod init gobuildsymlinks
go: creating new go.mod: module gobuildsymlinks

% go build -o /dev/null ./sym
build gobuildsymlinks/sym: cannot load gobuildsymlinks/sym: no Go source files

% echo "package main" >> ./sym/hack.go

% go build -o /dev/null ./sym  

What did you expect to see?

go build successfully produces a binary.

What did you see instead?

fails with: cannot load <package>: no Go source files

@y3llowcake
Copy link
Author

I did not correctly test with the latest release, looks like it was fixed in 3726d91

@y3llowcake
Copy link
Author

Reopening now that I've confirmed this reproduces in the latest release (go1.12.4), but is fixed at HEAD.

Would it be possible to cherrypick this fix into a minor release?

@katiehockman
Copy link
Contributor

Closing as a duplicate of #28107, but will request the cherrypick (backport) from that issue.

@golang golang locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants