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

doc: document how to build a release from source (with race libraries, etc) #22372

Open
phemmer opened this issue Oct 21, 2017 · 10 comments

Comments

@phemmer
Copy link

commented Oct 21, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.9.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/home/phemmer/.go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/phemmer/.go:/tmp/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build939950170=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Tried to build a package with go build --race

What did you expect to see?

successful build

What did you see instead?

go install container/heap: open /usr/lib/go/pkg/linux_amd64_race/container/heap.a: permission denied
go install encoding/csv: open /usr/lib/go/pkg/linux_amd64_race/encoding/csv.a: permission denied
go install html: open /usr/lib/go/pkg/linux_amd64_race/html.a: permission denied
go install database/sql/driver: mkdir /usr/lib/go/pkg/linux_amd64_race/database: permission denied
go install expvar: open /usr/lib/go/pkg/linux_amd64_race/expvar.a: permission denied
go install archive/tar: mkdir /usr/lib/go/pkg/linux_amd64_race/archive/: permission denied
go install text/template/parse: mkdir /usr/lib/go/pkg/linux_amd64_race/text/template/: permission denied

Additional information

It appears this is because the standard source installation (as documented here: https://golang.org/doc/install/source) does not install the race detector enabled versions of several standard lib packages:

# ls /usr/lib/go/pkg/linux_amd64_race/container/
list.a

However when I download the pre-built release (https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz from https://golang.org/dl/), the libs are present:

# ls go/pkg/linux_amd64_race/container/
heap.a  list.a  ring.a
@davecheney

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2017

Hi @phemmer it looks to me like there is some problems with your go installation. I suspect that you may have overwritten one install with another, or have GOROOT set and pointing to a version of Go that you didn't build from source.

You are correct that the source build does not build the race version by default. Once you've sorted out the permission errors from your current install, you can build the race version with this command

go install -race -a std

But, please fix the problems with your source install first.

@phemmer

This comment has been minimized.

Copy link
Author

commented Oct 21, 2017

I neither overwrote one version with another, nor have GOROOT set to a different version. The issue is that /usr/lib/go is a system-wide installation. Normal users do not have permissions to write to this path. The reason why go is even trying to write to this path is why this issue is created. If those files were present, go build --race would not be trying to create them.

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2017

@phemmer

This comment has been minimized.

Copy link
Author

commented Oct 21, 2017

export GOROOT_FINAL=/usr/lib/go
export GOROOT_BOOTSTRAP=/usr/lib/go
cd go/src
./all.bash
sudo mv /usr/lib/go{,.old}
sudo cp -r ../ /usr/lib/go
@davecheney

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2017

@phemmer

This comment has been minimized.

Copy link
Author

commented Oct 21, 2017

Shouldn't either the documentation explain this, or the all.bash build these files?
Some OS distributions follow the build documentation which is how I hit this issue. And then when I went to reproduce by building manually I still hit the issue.
It is confusing to follow the "building from source" documentation and end up with something different than the binary release.

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2017

@barthalion

This comment has been minimized.

Copy link

commented Nov 6, 2017

@davecheney Yes, that would be really appreciated. I wouldn't mind other pointers either, for example a link to how official Go binaries are built or which distributions are the closest to your artifacts.

(I'm the maintainer of Go in Arch.)

@ALTree ALTree added the NeedsDecision label Nov 6, 2017

@bradfitz bradfitz added this to the Unplanned milestone Nov 6, 2017

@bradfitz bradfitz changed the title Installing go from source is missing race libs doc: document how to build a release from source (with race libraries, etc) Nov 6, 2017

@rsc rsc removed the NeedsDecision label Nov 6, 2017

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2017

It may be much better to just suggest that people don't overwrite an existing install. Create a fresh one (move the old one out of the way, etc). We should probably update the docs to make that clear.

@barthalion

This comment has been minimized.

Copy link

commented Dec 10, 2017

For the record, Arch ships shared and race libraries now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.