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

On TrueOS/FreeBSD "go install -a" tries to overwrite ${GOROOT} libraries #22638

Closed
hxw opened this issue Nov 9, 2017 · 2 comments
Closed

On TrueOS/FreeBSD "go install -a" tries to overwrite ${GOROOT} libraries #22638

hxw opened this issue Nov 9, 2017 · 2 comments

Comments

@hxw
Copy link

hxw commented Nov 9, 2017

On FreeBSD the option -a is not usable with the install command since it attempts to overwrite libraries in ${GOROOT}(/usr/local/go).

What did you do?

% cat main.go
package main
import "fmt"
func main() {
	fmt.Printf("abc\n")
}
% go install -a -v .
runtime/internal/sys
go install runtime/internal/sys: open /usr/local/go/pkg/freebsd_amd64/runtime/internal/sys.a: permission denied

What did you expect to see?

all required modules from ${GOPATH} listed as in go build -a, but excluding any ${GOROOT} modules; and the program compiled and installed in ~/${GOPATH}/bin

What did you see instead?

attempt to rewrite file in ${GOROOT} which failed as all files there are owned by root.

Does this issue reproduce with the latest release (go1.9.2)?

I used pkg to install the go14 bootstrap and the FreeBSD port (lang/go) to compile and upgrade:

% go version
go version go1.9.2 freebsd/amd64
% go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH="/usr/home/hsw/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build714242629=/tmp/go-build -gno-record-gcc-switches"
CXX="clang++"
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"
% go install -a -v .                                       
runtime/internal/sys
go install runtime/internal/sys: open /usr/local/go/pkg/freebsd_amd64/runtime/internal/sys.a: permission denied

Result is the same; tries to overwrite ${GOROOT} file

System details

go version go1.8.1 freebsd/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH="/usr/home/hsw/gocode"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build135192314=/tmp/go-build -gno-record-gcc-switches"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
GOROOT/bin/go version: go version go1.8.1 freebsd/amd64
GOROOT/bin/go tool compile -V: compile version go1.8.1 X:framepointer
uname -v: FreeBSD 12.0-CURRENT #66 ac2f0aa3b(trueos-stable)-dirty: Wed Jun 21 01:09:23 UTC 2017     root@gauntlet:/usr/obj/usr/src/sys/GENERIC
lldb --version: lldb version 4.0.0
  clang revision 297347
@ianlancetaylor
Copy link
Contributor

Thanks for the report. This is fixed on tip by https://golang.org/cl/75850, and the fix will be in the future Go 1.10 release. Closing this issue because at this point we aren't going to change anything in earlier releases. The workaround is to not use -a; it rarely does what you want anyhow.

@hxw
Copy link
Author

hxw commented Nov 9, 2017

Thank you for the clarification

@golang golang locked and limited conversation to collaborators Nov 9, 2018
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