Skip to content

Commit

Permalink
Merge pull request #18428 from rockstar/fix/add-support-for-macos-builds
Browse files Browse the repository at this point in the history
fix: add support for macOS cross-compilation
  • Loading branch information
rockstar authored Jun 10, 2020
2 parents db68634 + 500395e commit 8c59c06
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
19 changes: 17 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,36 @@ commands:
This will install the cross compilers necessary to build release binaries.
steps:
- run:
name: Install cross compilers
name: Install linux cross compilers
command: >
sudo apt-get install -y --no-install-recommends
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
gcc-aarch64-linux-gnu libc6-dev-arm64-cross
- run:
name: Install macOS cross compilers
command: |
sudo apt-get install libxml2-dev libssl-dev zlib1g-dev
mkdir -p /opt/osxcross
cd /opt
git clone https://github.com/tpoechtrager/osxcross.git
cd osxcross
git checkout c2ad5e859d12a295c3f686a15bd7181a165bfa82
curl -L -o \
./tarballs/MacOSX10.11.sdk.tar.xz \
https://macos-sdks.s3.amazonaws.com/MacOSX10.11.sdk.tar.xz
UNATTENDED=1 PORTABLE=true ./build.sh
- run:
name: Install additional rust targets
command: |
rustup target add aarch64-unknown-linux-gnu \
arm-unknown-linux-gnueabihf \
armv7-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabihf \
x86_64-apple-darwin
echo 'export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc' >> $HOME/.cargo/env
echo 'export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc' >> $HOME/.cargo/env
echo 'export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc' >> $HOME/.cargo/env
echo 'export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >> $HOME/.cargo/env
echo 'export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=o64-clang' >> $HOME/.cargo/env
- run:
name: Install pkg-config wrapper
command: go build -o /go/bin/pkg-config github.com/influxdata/pkg-config
Expand Down
12 changes: 4 additions & 8 deletions .goreleaser-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ builds:
- id: influx
goos:
- linux
# Darwin cross compilation involves installing
# a compiler toolchain for it.
# https://github.com/influxdata/flux/issues/2654
# - darwin
- darwin
goarch:
- amd64
- arm64
Expand All @@ -16,15 +13,13 @@ builds:
- CGO_ENABLED=1
- CC=xcc
- PKG_CONFIG=$GOPATH/bin/pkg-config
- MACOSX_DEPLOYMENT_TARGET=10.11
ldflags: -s -w -X main.version=nightly -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influx
- id: influxd
goos:
- linux
# Darwin cross compilation involves installing
# a compiler toolchain for it.
# https://github.com/influxdata/flux/issues/2654
# - darwin
- darwin
goarch:
- amd64
- arm64
Expand All @@ -36,6 +31,7 @@ builds:
- CGO_ENABLED=1
- CC=xcc
- PKG_CONFIG=$GOPATH/bin/pkg-config
- MACOSX_DEPLOYMENT_TARGET=10.11
ldflags: -s -w -X main.version=nightly -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influxd
hooks:
Expand Down
12 changes: 4 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ builds:
- id: influx
goos:
- linux
# Darwin cross compilation involves installing
# a compiler toolchain for it.
# https://github.com/influxdata/flux/issues/2654
# - darwin
- darwin
goarch:
- amd64
- arm64
Expand All @@ -16,15 +13,13 @@ builds:
- CGO_ENABLED=1
- CC=xcc
- PKG_CONFIG=$GOPATH/bin/pkg-config
- MACOSX_DEPLOYMENT_TARGET=10.11
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influx
- id: influxd
goos:
- linux
# Darwin cross compilation involves installing
# a compiler toolchain for it.
# https://github.com/influxdata/flux/issues/2654
# - darwin
- darwin
goarch:
- amd64
- arm64
Expand All @@ -36,6 +31,7 @@ builds:
- CGO_ENABLED=1
- CC=xcc
- PKG_CONFIG=$GOPATH/bin/pkg-config
- MACOSX_DEPLOYMENT_TARGET=10.11
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influxd
hooks:
Expand Down
1 change: 1 addition & 0 deletions xcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ case "${GOOS}_${GOARCH}" in
linux_amd64) CC=clang ;;
linux_arm64) CC=aarch64-linux-gnu-gcc ;;
linux_arm) CC=arm-linux-gnueabihf-gcc ;;
darwin_amd64) CC=o64-clang ;;
*) die "No cross-compiler set for ${GOOS}_${GOARCH}" ;;
esac

Expand Down

0 comments on commit 8c59c06

Please sign in to comment.