docker / golang-cross

https://hub.docker.com/r/dockercore/golang-cross
97 stars 38 forks source link

osx fixes for go 1.11 #11

Closed kolyshkin closed 5 years ago

kolyshkin commented 5 years ago

This is a 3-in-1 story. Please have a seat.

Part 1.

Go 1.11 release notes say:

Go 1.11 now requires <...> macOS 10.10 Yosemite or later

So, change the OSX_VERSION_MIN in osxcross to 10.10.

Part 2.

MACOSX SDK tarball that was used before comes without libc++ headers, which are now required by at least crypto/x509 pkg when compiling for Darwin. These include files are part of xcode, which can only be downloaded by someone having Apple Developer ID, which I don't have so this path is not available for me.

An alternative is to reuse the SDK tarball from the https://github.com/multiarch/crossbuild project. Using it fixes the following error:

# crypto/x509
osxcross: error: cannot find libc++ headers

Part 3.

The new tarball, although, misses the libtool package (apparently somehow injected into the tarball that was used earlier) needed to compile miekg/pkcs11 used by cli, which leads to errors like:

# github.com/docker/cli/vendor/github.com/miekg/pkcs11
vendor/github.com/miekg/pkcs11/pkcs11.go:28:10: fatal error: 'ltdl.h' file not found
#include <ltdl.h>
          ^
1 error generated.

To fix this one, libtool for osx need to be installed. Building it from source (with osxcross) requires some other dependencies. Using brew is not possible since it is Linux. Solution: download a binary package from brew repo, cherry pick the needed stuff (lib and include).

Tested to fix docker-cli compilation issues on OSX using Go 1.11.

kolyshkin commented 5 years ago

@vdemeester @thaJeztah PTAL

thaJeztah commented 5 years ago

These include files are part of xcode, which can only be downloaded by someone having Apple Developer ID, which I don't have so this path is not available for me.

@kolyshkin I do have a Mac developer subscription; would it be cleaner to update the package we have at dockerproject.org?

kolyshkin commented 5 years ago

I do have a Mac developer subscription; would it be cleaner to update the package we have at dockerproject.org?

I think we can reuse the one from this PR, it works fine and needs nothing.

It would be awesome though if you can upload it to s3.dockerproject.org. I tried to do it myself, logged in to aws successfully (using kir / docker-core credentials) but accessing S3 gives me "access denied".

andrewhsu commented 5 years ago

i'll put it up (working on getting the cache to play nice)

andrewhsu commented 5 years ago
$ curl -Is https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz | head -1
HTTP/2 200
kolyshkin commented 5 years ago

Updated:

kolyshkin commented 5 years ago

As per @thaJeztah suggestion I rolled back go version to 1.11.0.

The only problem with that is we already have a 1.11.0 tag in this repo. I am not sure how automatic docker image builds work... hope the tag can be just forcefully re-set to a new commit and it will trigger a rebuild. If not, we'll have to use a new tag, say something like 1.11.0-2, and use it, not a big deal either.