diff --git a/Dockerfile b/Dockerfile index 9008897087..1da56180db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,14 @@ FROM ubuntu:14.04 MAINTAINER Tianon Gravi (@tianon) +# add zfs ppa RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys E871F18B51E0147C77796AC81196BA81F6B0FC61 RUN echo deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main > /etc/apt/sources.list.d/zfs.list +# add llvm repo +RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 15CF4D18AF4F7421 +RUN echo deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main > /etc/apt/sources.list.d/llvm.list + # Packaged dependencies RUN apt-get update && apt-get install -y \ apparmor \ @@ -37,6 +42,7 @@ RUN apt-get update && apt-get install -y \ bash-completion \ btrfs-tools \ build-essential \ + clang-3.8 \ createrepo \ curl \ dpkg-sig \ @@ -58,7 +64,9 @@ RUN apt-get update && apt-get install -y \ ubuntu-zfs \ xfsprogs \ libzfs-dev \ - --no-install-recommends + --no-install-recommends \ + && ln -snf /usr/bin/clang-3.8 /usr/local/bin/clang \ + && ln -snf /usr/bin/clang++-3.8 /usr/local/bin/clang++ # Get lvm2 source for compiling statically RUN git clone -b v2_02_103 https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 @@ -105,6 +113,15 @@ RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint && (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \ && go install -v github.com/golang/lint/golint +# Configure the container for OSX cross compilation +ENV OSX_SDK MacOSX10.11.sdk +RUN set -x \ + && export OSXCROSS_PATH="/osxcross" \ + && git clone --depth 1 https://github.com/tpoechtrager/osxcross.git $OSXCROSS_PATH \ + && curl -sSL https://s3.dockerproject.org/darwin/${OSX_SDK}.tar.xz -o "${OSXCROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" \ + && UNATTENDED=yes OSX_VERSION_MIN=10.6 ${OSXCROSS_PATH}/build.sh +ENV PATH /osxcross/target/bin:$PATH + # Install registry ENV REGISTRY_COMMIT ec87e9b6971d831f0eff752ddb54fb64693e51cd RUN set -x \ diff --git a/hack/make/binary b/hack/make/binary index 55a54d1e13..7066eb6cb2 100644 --- a/hack/make/binary +++ b/hack/make/binary @@ -25,8 +25,15 @@ if [ "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" == "windows/amd64" ] && [ "$(go e export LDFLAGS_STATIC_DOCKER="$LDFLAGS_STATIC_DOCKER -linkmode=internal" fi -if [ "$IAMSTATIC" == "true" ]; then - export BUILDFLAGS=( "${BUILDFLAGS[@]/pkcs11 /}" ) # we cannot dlopen in pkcs11 in a static binary +if [ "$IAMSTATIC" == "true" ] && [ "$(go env GOHOSTOS)" == "linux" ] && [ "$DOCKER_EXPERIMENTAL" ]; then + if [ "${GOOS}/${GOARCH}" == "darwin/amd64" ]; then + export CGO_ENABLED=1 + export CC=o64-clang + export LDFLAGS='-linkmode external -s' + export LDFLAGS_STATIC_DOCKER='-extld='${CC} + else + export BUILDFLAGS=( "${BUILDFLAGS[@]/pkcs11 /}" ) # we cannot dlopen in pkcs11 in a static binary + fi fi echo "Building: $DEST/$BINARY_FULLNAME"