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: unbootstrapped cross compiler doesn't emit helpful error anymore #9272

Closed
dominikh opened this issue Dec 11, 2014 · 10 comments
Closed
Milestone

Comments

@dominikh
Copy link
Member

In Go 1.4 and before, go build would say $GOOS/$GOARCH must be bootstrapped using make.bash because it would detect missing zasm files.

In tip, we have zgoos files, which are created by go generate, so they always exist for all GOOS/GOARCH combinations. cmd/dist, however, is still responsible for copying textflag.h into the per-GOOS/GOARCH pkg/ directories. Building Go for a single platform and trying to go build for a different platform now won't result in a helpful error, but instead the assembler won't be able to find textflag.h:

Expected output:

dominikh-pc /tmp $ GOOS=darwin go build
go build runtime: darwin/amd64 must be bootstrapped using make.bash

Actual output:

dominikh-pc /tmp $ GOOS=darwin go build
# runtime
/home/dominikh/go/src/runtime/asm.s:6 6a: No such file or directory: textflag.h

Version:

go version devel +3fa5d3a Thu Dec 11 15:23:18 2014 +0000 linux/amd64

This only affects tip, not Go 1.4.

@minux
Copy link
Member

minux commented Dec 11, 2014

Either we teach cmd/go to also copy that file or treat the missing of that
file as an indication
of not bootstrapped.

I'd prefer the former, because cmd/dist no longer generates any files for
the runtime package.

@bradfitz
Copy link
Contributor

I would like to see go build just work for any OS/ARCH pair in Go 1.5, without the user having to do anything. (And regardless of whether their $GOROOT is in $HOME/go or unwritable /usr/, /var/, etc)

@minux
Copy link
Member

minux commented Dec 11, 2014

On Thu, Dec 11, 2014 at 5:06 PM, Brad Fitzpatrick notifications@github.com
wrote:

I would like to see go build just work for any OS/ARCH pair in Go 1.5,
without the user having to do anything. (And regardless of whether their
$GOROOT is in $HOME/go or unwritable /usr/, /var/, etc)

Possible if the user also supplies CC, CXX and other necessary flags
necessary for cross compilation.
Yeah, that will be ideal (though if the GOOS/GOARCH combination has been
installed, each time go build
will build everything from scratch; not that bad if we fix #8893)

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@minux
Copy link
Member

minux commented Dec 31, 2014

could we stop copying textflag.h to $GOROOT/pkg/$GOOS_$GOARCH, and instead put it
in a separate directory in $GOROOT (e.g. $GOROOT/src/internal/runtime), and always
pass -I $GOROOT/src/internal/runtime to the assemblers?

In this way, even if the user can't write to $GOROOT/pkg, they can still use go build to
cross compile for another architecture, and we also save one file copying operation.

@davecheney
Copy link
Contributor

I think it is reasonable if you (the developer) are going to set up a cross
compiling installation you start with the source release. Given you have to
compile the additional architectures on your development machine it doesn't
seem like an undue request to compile the first architecture as well.

On Wed, Dec 31, 2014 at 12:21 PM, Minux Ma notifications@github.com wrote:

could we stop copying textflag.h to $GOROOT/pkg/$GOOS_$GOARCH, and instead
put it
in a separate directory in $GOROOT (e.g. $GOROOT/src/internal/runtime),
and always
pass -I $GOROOT/src/internal/runtime to the assemblers?

In this way, even if the user can't write to $GOROOT/pkg, they can still
use go build to
cross compile for another architecture, and we also save one file copying
operation.


Reply to this email directly or view it on GitHub
#9272 (comment).

@minux
Copy link
Member

minux commented Jan 1, 2015

On Tue, Dec 30, 2014 at 9:35 PM, Dave Cheney notifications@github.com
wrote:

I think it is reasonable if you (the developer) are going to set up a
cross
compiling installation you start with the source release. Given you have
to
compile the additional architectures on your development machine it
doesn't
seem like an undue request to compile the first architecture as well.

What I'm concerned about is not compiling the toolchain programs, but you
need to run make.bash --no-clean for each platform (OS/arch pair) that you
want to cross compile to.

Ideally, once you have the toolchain programs, building a one-shot program
for a new platform should be as easy as:
GOOS=goos GOARCH=goarch go build import/path

Even if you're using binary distributions, you should still be able to cross
compile for the same architecture but different OSes easily (without
modifying
$GOROOT/pkg), that's why I propose that we move the only remaining required
headers files into internal/runtime so that they don't need to be in
$GOROOT/pkg/$GOOS_$GOARCH.

@davecheney
Copy link
Contributor

Fair enough, thanks for clarifying. If it really is as simple as ensuring
the textflag.h files are present (I take no position on a new internal
package) then go build will be able to create everything from the runtime
upwards as required, then go for it.

On Fri, Jan 2, 2015 at 9:41 AM, Minux Ma notifications@github.com wrote:

On Tue, Dec 30, 2014 at 9:35 PM, Dave Cheney notifications@github.com
wrote:

I think it is reasonable if you (the developer) are going to set up a
cross
compiling installation you start with the source release. Given you have
to
compile the additional architectures on your development machine it
doesn't
seem like an undue request to compile the first architecture as well.

What I'm concerned about is not compiling the toolchain programs, but you
need to run make.bash --no-clean for each platform (OS/arch pair) that you
want to cross compile to.

Ideally, once you have the toolchain programs, building a one-shot program
for a new platform should be as easy as:
GOOS=goos GOARCH=goarch go build import/path

Even if you're using binary distributions, you should still be able to
cross
compile for the same architecture but different OSes easily (without
modifying
$GOROOT/pkg), that's why I propose that we move the only remaining required
headers files into internal/runtime so that they don't need to be in
$GOROOT/pkg/$GOOS_$GOARCH.


Reply to this email directly or view it on GitHub
#9272 (comment).

@minux
Copy link
Member

minux commented Jan 2, 2015

We don't need to create a new internal package, I just can't think
of an appropriate directory to put the textflag.h. Ideally we will want
a new directory, so that we can limit the header files that could be
included.

I've also considered always including those macros in cmd/[5689]a
so that no #include is needed. But that means we can't easily modify
textflag.h without also updating the assembler source code. (although
i imagine we can use go generate for that, esp. after we have cmd/asm
in Go.)

@dominikh
Copy link
Member Author

dominikh commented Mar 2, 2015

Does https://go-review.googlesource.com/#/c/6471/ address this?

@minux
Copy link
Member

minux commented Mar 2, 2015

Yes.

@minux minux closed this as completed Mar 2, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

6 participants