Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

go: Allow building the cross-compilers and runtime support for other platforms. #12547

Closed
wants to merge 1 commit into from

Conversation

fd
Copy link
Contributor

@fd fd commented Jun 1, 2012

When the --cross-compile option is used the following runtimes will be build:

  • darwin (386, amd64; with CGO)
  • linux (386, amd64, arm)
  • freebsd (386, amd64)
  • openbsd (386, amd64)
  • plan9 (386)
  • windows (386, amd64)

@MikeMcQuaid
Copy link
Member

Do we really have to build e.g. plan9 cross-compilers? I'd suggest just doing either per-platform or just the common platforms (linux, windows) for now. Thanks!

@fd
Copy link
Contributor Author

fd commented Jun 1, 2012

I could make it like this:

Option 1: --cross-compile-common:

  • darwin (386, amd64; with CGO)
  • linux (386, amd64, arm)
  • windows (386, amd64)

Option 2: --cross-compile-all:

  • darwin (386, amd64; with CGO)
  • linux (386, amd64, arm)
  • freebsd (386, amd64)
  • openbsd (386, amd64)
  • plan9 (386)
  • windows (386, amd64)

@fd
Copy link
Contributor Author

fd commented Jun 7, 2012

pull?

archs.each do |arch|
cgo = opts[:cgo] ? "1" : "0"
allow_fail = opts[:allow_fail] ? "|| true" : ""
system "env GOROOT_FINAL=#{prefix} GOOS=#{os} GOARCH=#{arch} CGO_ENABLED=#{cgo} ./make.bash --no-clean #{allow_fail}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENV['GOROOT_FINAL'] = ...
ENV['GOOS'] = ...
...

system "./make.bash ...

@jacknagel
Copy link
Contributor

This feels overly-complex. @MikeMcQuaid?

@MikeMcQuaid
Copy link
Member

Yes, it's pretty unreadable to me. So you need to rerun make for each available cross-compiler? I still don't think I can really see a need for more than just Linux and Windows cross-compilation and even then if it's going to make a mess I'd rather just leave it out.

You could take the current, default darwin case out of the loop and then just iterate over Windows and Linux archs putting the prefix outside the loop and scrapping CGO_ENABLED for the loop.

@fd
Copy link
Contributor Author

fd commented Jun 13, 2012

  • Yes, you need to run make for each cross-compiler (unless you just want to build the host-compiler).
  • darwin is the default option; no mess there.
  • I need the other cross-compilers; so I added them as options. Otherwise I need to install them anyways, in the GOROOT (which in the Homebrew prefix); this is a far bigger mess.
  • CGO_ENABLED is enabled by default (and should be for Darwin) but it can't be compiled for the cross-compilers. So it needs to be turned off (for the other compilers).

@MikeMcQuaid
Copy link
Member

I think the question is how many other people are going to use how many other cross-compilers? It's very easy to fork and install your own version of this formula so we need to find a balance between what you'll use and what others will.

I'm tempted to just leave this open for a while and see if we get any other people saying "+1" in here with what cross-compilers they want.

@jmibanez
Copy link

jmibanez commented Jul 3, 2012

Related to this: I've been building the cross-compilation stuff manually using ./make.bash inside $GOROOT/src; however, I've had to disable the last step of the install (include.rmtree) (which removes the include fils both in the target and inside $GOROOT). Without that last step, building the cross-compilation toolchain works; with it, you'll have to do the build from the install (just as the pull request). In other words, I also replaced line 31, same as the pull request here.

Maybe just add a caveat describing how to build the cross-compilation toolchain for a particular architecture? Personally, I need just windows-386 and linux-arm and don't care about the other targets.

@fd
Copy link
Contributor Author

fd commented Jul 3, 2012

@jmibanez This pull request also fixes that problem (see #12457) (by building the cross-compilers when installing golang)

@riobard
Copy link
Contributor

riobard commented Aug 23, 2012

Any progress on this one?

@adamv
Copy link
Contributor

adamv commented Aug 31, 2012

Needs to at least be squashed and rebased on master.

…forms.

When the `--cross-compile` option is used the following runtimes will be build:

- darwin  (386, amd64; with CGO)
- linux   (386, amd64, arm)
- freebsd (386, amd64)
- openbsd (386, amd64)
- plan9   (386)
- windows (386, amd64)
@fd
Copy link
Contributor Author

fd commented Sep 14, 2012

@adamv squashed and rebased.

@bjeanes
Copy link
Contributor

bjeanes commented Nov 24, 2012

Since this is still open to gauge support, I'll put my 👍 here. I would need, at minimum, linux (all archs), both BSDs (all archs) and eventually windows.

@MikeMcQuaid
Copy link
Member

I'm happy with this as-is. If no-one has merged later I will; on a train with poor internet.

@adamv adamv closed this in 75e0d30 Nov 25, 2012
@bjeanes
Copy link
Contributor

bjeanes commented Nov 25, 2012

I just tried re-installing Go with --cross-compile-all. It failed with:

$  brew install go --cross-compile-all
==> Downloading http://go.googlecode.com/files/go1.0.3.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.0.3.tar.gz
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
image/draw
image/jpeg
debug/dwarf
crypto/des
index/suffixarray

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

zsh: exit 1     brew install go --cross-compile-all
4:54.51s total, 631.90s user, 106.50s system, 250% cpu

I am yet to find where any additional logs will be to see what actually caused it to fail. I do have a few brew doctor things to look into, but a Go installs successfully without the full cross-compilations.

Can anybody else confirm that things install as they expect?

@bjeanes
Copy link
Contributor

bjeanes commented Nov 25, 2012

Installing with --cross-compile-common just completed successfully. It seems to be just the larger set that is failing (and I am not yet sure why).

Output from successful build:

$ brew install go --cross-compile-common
==> Downloading http://go.googlecode.com/files/go1.0.3.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.0.3.tar.gz
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
/usr/local/Cellar/go/1.0.3: 4204 files, 484M, built in 3.4 minutes
3:23.72s total, 460.18s user, 75.87s system, 263% cpu

@fd
Copy link
Contributor Author

fd commented Nov 26, 2012

It appears that image/jpeg started failing on plan9 after 1.0.3
I will disable plan9 for now

snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this pull request Dec 17, 2012
When the `--cross-compile` option is used the following runtimes will be build:

- darwin  (386, amd64; with CGO)
- linux   (386, amd64, arm)
- freebsd (386, amd64)
- openbsd (386, amd64)
- plan9   (386)
- windows (386, amd64)

Closes Homebrew#12547.

Signed-off-by: Adam Vandenberg <[email protected]>
@joeshaw
Copy link
Contributor

joeshaw commented Feb 11, 2013

Building with --cross-compile-common (and probably also --cross-compile-all) seems to break cgo-required pieces in the class libraries. See issue #17758 about that.

@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants