Giter Site home page Giter Site logo

go-cross's Introduction

cross

A Go 1.21.0 cross-compilation toolchain for Go capable of targeting

  • darwin/arm64 (dynamic)
  • darwin/amd64 (dynamic)
  • windows/amd64 (static / dynamic)
  • linux/amd64 (static / dynamic)
  • linux/arm64 (static / dynamic)

Cross-compiling CGo applications

darwin/arm64

CGO_ENABLED=1 CC=o64-clang CXX=o64-clang++ HOST=arm64-apple-darwin15 PREFIX=/usr/local GOOS=darwin GOARCH=arm64 go build ...

darwin/amd64

CGO_ENABLED=1 CC=o64-clang CXX=o64-clang++ HOST=x86_64-apple-darwin15 PREFIX=/usr/local GOOS=darwin GOARCH=arm64 go build ...

linux/arm64 (static)

CGO_ENABLED=1 CC=/usr/bin/musl-aarch64/bin/musl-gcc GOOS=linux GOARCH=arm64 go build -ldflags="-linkmode external -extldflags='-static'" ...

linux/amd64 (static)

CGO_ENABLED=1 CC=/usr/bin/musl-x86_64/bin/musl-gcc GOOS=linux GOARCH=amd64 go build -ldflags="-linkmode external -extldflags='-static'" ...

windows/amd64 (static)

CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-12 GOOS=windows GOARCH=amd64 go build -ldflags="-linkmode external -extldflags='-static'" ...

Notes

The Docker image is ~4.7 GB and takes around 20 minutes to build. Therefore, it is recommended that the image is pushed to a registry, and pulled from there.

Maintenance

Upgrading Go versions should be easy. Just swap out the go version in the download step. However, upgrading Ubuntu versions may not be that easy as it requires two things:

  • Check what gcc version is shipped with build-essential for that version
  • Check if mingw-gcc is available for that gcc version
  • Change all the cross-compiler versions to use that gcc version
  • Otherwise, just let the Ubuntu version be. DO NOT INSTALL MISMATCHING VERSIONS.

Another thing is upgrading macOS SDK versions. Please refer to xgo's toolchain Dockerfile for version changes, and when you change a macOS SDK version, update the patches.tar.xz with the one in xgo.

go-cross's People

Contributors

akshit-deepsource avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.