diff --git a/.github/workflows/build_images.yml b/.github/workflows/build_images.yml index 4ef88de..5d38695 100644 --- a/.github/workflows/build_images.yml +++ b/.github/workflows/build_images.yml @@ -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 diff --git a/.github/workflows/test_pr.yml b/.github/workflows/test_pr.yml index 9e7ab96..0258afc 100644 --- a/.github/workflows/test_pr.yml +++ b/.github/workflows/test_pr.yml @@ -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 diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 1ada9a8..bbc591a 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -58,8 +58,8 @@ 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 @@ -67,7 +67,7 @@ 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 @@ -75,7 +75,7 @@ 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 diff --git a/docker/base/bootstrap_pure.sh b/docker/base/bootstrap_pure.sh index 9dc954b..e391e8c 100644 --- a/docker/base/bootstrap_pure.sh +++ b/docker/base/bootstrap_pure.sh @@ -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 @@ -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 diff --git a/docker/base/build.sh b/docker/base/build.sh index bbed448..e6fc0ec 100644 --- a/docker/base/build.sh +++ b/docker/base/build.sh @@ -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 @@ -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 @@ -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 diff --git a/xgo.bats b/xgo.bats index 60b0268..e1a3d35 100644 --- a/xgo.bats +++ b/xgo.bats @@ -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 ] } @@ -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 ] }