Skip to content

Commit

Permalink
xgo 1.16 darwin/amd64 - increase base sdk version (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
techknowlogick committed Feb 18, 2021
1 parent b33106d commit 6a603af
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: build base image
uses: docker/build-push-action@v2
# if: steps.base_build.outputs.value != '0'
if: true
if: false
with:
context: docker/base/
tags: techknowlogick/xgo:base
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: build base image
uses: docker/build-push-action@v2
# if: steps.base_build.outputs.value == '0'
if: true
# if: steps.base_build.outputs.value != '0'
if: false
with:
context: docker/base/
tags: techknowlogick/xgo:base
Expand Down
8 changes: 4 additions & 4 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@ ADD patches /patches
##########################

# Configure the container for OSX cross compilation
ENV OSX_SDK MacOSX10.11.sdk
ENV OSX_SDK_PATH https://s3.dockerproject.org/darwin/v2/$OSX_SDK.tar.xz
ENV OSX_SDK MacOSX11.1.sdk
ENV OSX_SDK_PATH https://faasd-test.spacebear.ee/$OSX_SDK.tar.xz

# Make libxar known to the ld64 and cctools build
ENV LD_LIBRARY_PATH=/osxcross/target/lib

# Download the osx sdk and build the osx toolchain
# We download the osx sdk, patch it and pack it again to be able to throw the patched version at osxcross
RUN \
$FETCH $OSX_SDK_PATH dd228a335194e3392f1904ce49aff1b1da26ca62 && \
$FETCH $OSX_SDK_PATH e8f0382f9e54ab3d7211b4886216475201ee750e47fa76dc6a0bf4604a63ddfc && \
tar -xf `basename $OSX_SDK_PATH` && rm -f `basename $OSX_SDK_PATH`
ADD patch.tar.xz $OSX_SDK/usr/include/c++
RUN tar -cf - $OSX_SDK/ | xz -c - > $OSX_SDK.tar.xz && rm -rf $OSX_SDK

# Actually build the toolchain
RUN \
git clone https://github.com/tpoechtrager/osxcross.git && \
cd osxcross && git checkout 88cb6e8d0d7675cae7c8a2d66c11f58237101df0 && cd ../ && \
#cd osxcross && git checkout 035cc170338b7b252e3f13b0e3ccbf4411bffc41 && cd ../ && \
mv $OSX_SDK.tar.xz /osxcross/tarballs/ && \
OSX_VERSION_MIN=10.10 UNATTENDED=1 LD_LIBRARY_PATH=/osxcross/target/lib /osxcross/build.sh

Expand Down
31 changes: 19 additions & 12 deletions docker/base/bootstrap_pure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ GOOS=linux GOARCH=386 CGO_ENABLED=1 go install std
echo "Bootstrapping linux/arm64..."
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-6 go install std

if [ $GO_VERSION -ge 170 ]; then
echo "Bootstrapping linux/mips64..."
GOOS=linux GOARCH=mips64 CGO_ENABLED=1 CC=mips64-linux-gnuabi64-gcc-6 go install std
echo "Bootstrapping linux/mips64..."
GOOS=linux GOARCH=mips64 CGO_ENABLED=1 CC=mips64-linux-gnuabi64-gcc-6 go install std

echo "Bootstrapping linux/mips64le..."
GOOS=linux GOARCH=mips64le CGO_ENABLED=1 CC=mips64el-linux-gnuabi64-gcc-6 go install std
fi
echo "Bootstrapping linux/mips64le..."
GOOS=linux GOARCH=mips64le CGO_ENABLED=1 CC=mips64el-linux-gnuabi64-gcc-6 go install std

if [ $GO_VERSION -ge 180 ]; then
echo "Bootstrapping linux/mips..."
GOOS=linux GOARCH=mips CGO_ENABLED=1 CC=mips-linux-gnu-gcc-6 go install std
echo "Bootstrapping linux/mips..."
GOOS=linux GOARCH=mips CGO_ENABLED=1 CC=mips-linux-gnu-gcc-6 go install std

echo "Bootstrapping linux/mipsle..."
GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC=mipsel-linux-gnu-gcc-6 go install std
fi
echo "Bootstrapping linux/mipsle..."
GOOS=linux GOARCH=mipsle CGO_ENABLED=1 CC=mipsel-linux-gnu-gcc-6 go install std

echo "Bootstrapping linux/ppc64le..."
GOOS=linux GOARCH=ppc64le CGO_ENABLED=1 CC=powerpc64le-linux-gnu-gcc-6 go install std

echo "Bootstrapping linux/s390x..."
GOOS=linux GOARCH=s390x CGO_ENABLED=1 CC=s390x-linux-gnu-gcc-6 go install std

echo "Bootstrapping windows/amd64..."
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go install std
Expand All @@ -58,6 +60,11 @@ GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go install std
echo "Bootstrapping darwin/amd64..."
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=o64-clang go install std

if [ $GO_VERSION -ge 1160 ]; then
echo "Bootstrapping darwin/arm64..."
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CC=o64-clang go install std
fi

# Install xgo within the container to enable internal cross compilation
echo "Installing xgo-in-xgo..."
go get -u src.techknowlogick.com/xgo
Expand Down
12 changes: 10 additions & 2 deletions docker/base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# FLAG_BUILDMODE - Optional buildmode flag to set on the Go builder
# FLAG_TRIMPATH - Optional trimpath flag to set on the Go builder
# TARGETS - Comma separated list of build targets to compile for
# GO_VERSION - Bootstrapped version of Go to disable uncupported targets
# GO_VERSION - Bootstrapped version of Go to disable unsupported targets
# EXT_GOPATH - GOPATH elements mounted from the host filesystem

# Define a function that figures out the binary extension
Expand Down Expand Up @@ -50,7 +50,7 @@ function extension {
# Detect if we are using go modules
if [[ "$GO111MODULE" == "on" || "$GO111MODULE" == "auto" ]]; then
USEMODULES=true
else
else
USEMODULES=false
fi

Expand Down Expand Up @@ -414,6 +414,14 @@ for TARGET in $TARGETS; do
fi
CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $V $X $TP $MOD "${T[@]}" --ldflags="$LDSTRIP $V $LD" $R $BM -o "/build/$NAME-darwin-$PLATFORM-amd64$R`extension darwin`" $PACK_RELPATH
fi
if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then
echo "Compiling for darwin-$PLATFORM/arm64..."
CC=o64-clang CXX=o64-clang++ HOST=arm64-apple-darwin15 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]}
if [[ "$USEMODULES" == false ]]; then
CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" -d $PACK_RELPATH
fi
CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X $TP $MOD "${T[@]}" --ldflags="$LDSTRIP $V $LD" $R $BM -o "/build/$NAME-darwin-$PLATFORM-arm64$R`extension darwin`" $PACK_RELPATH
fi
# Remove any automatically injected deployment target vars
unset MACOSX_DEPLOYMENT_TARGET
fi
Expand Down
24 changes: 19 additions & 5 deletions xgo.bats
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env bats

@test "embedded c" {
run go run xgo.go github.com/techknowlogick/xgo/tests/embedded_c
run go run xgo.go ./tests/embedded_c
echo "$output"
[ "$status" -eq 0 ]
}

@test "embedded cpp" {
skip "TODO: C++ is failing on linux/386, need to look into this"
run go run xgo.go github.com/techknowlogick/xgo/tests/embedded_cpp
run go run xgo.go ./tests/embedded_cpp
echo "$output"
[ "$status" -eq 0 ]
}
Expand All @@ -25,16 +26,29 @@
}

@test "branches" {
run go run xgo.go --branch memprof --targets "linux/amd64" github.com/rwcarlsen/cyan/cmd/cyan
skip "remotes are temporarily disabled due to gomod"
run go run xgo.go --remote github.com/rwcarlsen/cyan --branch memprof --targets "linux/amd64" github.com/rwcarlsen/cyan/cmd/cyan
echo "$output"
[ "$status" -eq 0 ]
}

@test "eth smoke" {
run go run xgo.go --targets "linux/amd64" github.com/ethereum/go-ethereum/cmd/geth
skip "remotes are temporarily disabled due to gomod"
run go run xgo.go --remote github.com/ethereum/go-ethereum --targets "linux/amd64" github.com/ethereum/go-ethereum/cmd/geth
echo "$output"
[ "$status" -eq 0 ]
}

@test "gitea smoke" {
run go run xgo.go --targets "darwin-10.6/amd64" code.gitea.io/gitea
git clone https://github.com/go-gitea/gitea.git /tmp/gitea
run go run xgo.go --targets "darwin-10.6/amd64" -tags 'netgo osusergo sqlite sqlite_unlock_notify' /tmp/gitea
echo "$output"
[ "$status" -eq 0 ]
}

@test "vikunja smoke" {
git clone https://kolaente.dev/vikunja/api /tmp/vikunja
run go run xgo.go --targets "darwin-10.6/amd64" /tmp/vikunja
echo "$output"
[ "$status" -eq 0 ]
}

0 comments on commit 6a603af

Please sign in to comment.