-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go env
discards all but the first word of $CC
#15457
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
Comments
This is what I did to find that b38fa89 was the commit that changed behavior.
where check.sh contains:
|
See also #11685 |
go env
discards all but the first word of $CCgo env
discards all but the first word of $CC
Ian - Thanks - |
@davmaz I have not looked into this at all. As far as I know it only affects In any case it appears that a simple workaround for now is to store your command line in an executable shell script, and set CC to that shell script. |
I guess I'll have to find a way. But it does not just effect "go env", it changes the compiler calls (ignores the exported values after the first) and puts in new ones that wreck the cross-compile. I'm surprised more user haven't complained, but I understand. I'll just have to find a way around it if I want to stay current with the latest go version. |
@davmaz This issue just talks about |
Ian, I've got the OpenBLAS make to cross-compile the library by doing this:
The make runs to completion and I can install the ARM OpenBLAS library. I followed similar steps to get FFTW to cross-compile if anyone is interested. Next, installing go for cross-compiling I did this:
Notice the GOGCCFLAGS get mangled (see golang go issues 8161). I can work around that by specifying GOGCCFLAGS on the command line: However, when I copy this to the arm system, it does not run: Any ideas why this won't run? From: Ian Lance Taylor [notifications@github.com] @davmazhttps://github.com/davmaz This issue just talks about go env. If this affects more than that, can you show the problem in detail, or open a new issue for the problem you are having? Thanks. — |
@davmaz Let's please take that part of the conversation to a forum (see https://golang.org/wiki/Questions) or a separate issue, rather than complicating this issue. Thanks. |
Sorry Ian. I didn't know how to get back there. Thanks for the link. From: Ian Lance Taylor [notifications@github.com] @davmazhttps://github.com/davmaz Let's please take that part of the conversation to a forum (see https://golang.org/wiki/Questions) or a separate issue, rather than complicating this issue. Thanks. — |
It now requires an installation of go 1.4.x to bootstrap the build. We set CGO_ENABLED=0 when building the bootstrap go compiler because go 1.4.3 won't build with a newer GNU toolchain: golang/go#13114. It didn't cause a problem for me on Ubuntu 14.04, but this will prevent it from breaking in the future. We don't need cgo in the bootstrap compiler. The other change is that the go build system no longer allows us to pass a command with arguments for CC_FOR_TARGET. I opened a ticket for it: golang/go#15457. We need -I and -L arguments in the mac build so that gcc gan find its headers and libraries. So we wrap up the arguments in a shell script and use the shell script as CC_FOR_TARGET.
It now requires an installation of go 1.4.x to bootstrap the build. We set CGO_ENABLED=0 when building the bootstrap go compiler because go 1.4.3 won't build with a newer GNU toolchain: golang/go#13114. It didn't cause a problem for me on Ubuntu 14.04, but this will prevent it from breaking in the future. We don't need cgo in the bootstrap compiler. The other change is that the go build system no longer allows us to pass a command with arguments for CC_FOR_TARGET. I opened a ticket for it: golang/go#15457. We need -I and -L arguments in the mac build so that gcc gan find its headers and libraries. So we wrap up the arguments in a shell script and use the shell script as CC_FOR_TARGET.
/cc @quentinmit |
CL https://golang.org/cl/33293 mentions this issue. |
Remove workaround for fixed upstream bug, GitHub #17732 (__MAC_OS_X_VERSION_MAX_ALLOWED). I wasn't able to remove the cc-for-target workaround for GitHub #15457 (CC_FOR_TARGET). Even though according to golang/go#15457 it has been been fixed, make.bash still seems to lose all but the first argument of CC_FOR_TARGET somewhere.
Remove workaround for fixed upstream bug, GitHub #17732 (__MAC_OS_X_VERSION_MAX_ALLOWED). I wasn't able to remove the cc-for-target workaround for GitHub #15457 (CC_FOR_TARGET). Even though according to golang/go#15457 it has been been fixed, make.bash still seems to lose all but the first argument of CC_FOR_TARGET somewhere. tor-browser-bundle.git author: David Fifield <david@bamsoftware.com> tor-browser-bundle.git commit: 9d546f20ae711e7df9c574d9bdfccf34ddf1b650
go version
)?go1.6.2
go env
)?linux/386
If you try to stuff extra arguments into the CC environment variable,
go env
will throw them away (here,bar
is discarded):Earlier releases, for example 1.4.3, also remove arguments from CC, but keep them in a separate variable, GOGCCFLAGS:
The code responsible for this shuffling lies in the
mkEnv
function in env.go:https://github.com/golang/go/blob/go1.4.3/src/cmd/go/env.go#L55-L56
(Indices 1 and 2 are skipped because they are inserted by
ccompilerCmd
in build.go.) Note thatmkEnv
ignores any previous value of GOGCCFLAGS.b38fa89 is the commit that caused the behvior to change, by calling
mkEnv
an extra time and overwriting environment variables with its output. Since one application ofmkEnv
does this:two applications have the effect of discarding CC[1:]:
Why this matters to me: I'm cross-compiling using a specially installed GCC that needs extra -I and -L flags to find its files. (Specifically, I'm doing a cross build from linux to darwin for Tor Browser; see here for details.) I'm running this command, which worked with 1.4.3:
(
$CC
is the cross compiler.) But because make.bash callsdist env
, the necessary$CFLAGS and $LDFLAGS
disappear and the build fails somewhere in cgo because the compiler cannot find errno.h.#13377 is a related issue, particularly this comment that talks about "only using the first word of $CC." As a workaround I'm using a suggestion from that ticket: I'm making a shell script called cc-for-target that contains
exec $CC $CFLAGS $LDFLAGS "$@"
and invoking make.bash withCC_FOR_TARGET=cc-for-target
.The text was updated successfully, but these errors were encountered: