Coder Social home page Coder Social logo

crossbuild's Introduction

Docker crossbuild

Sync Labels status Check Markdown status Check License status Check Taskfiles status Check Shell Scripts status

This docker container has been created to allow us to easily crosscompile our c++ tools. The idea comes from multiarch/crossbuild, but that container unfortunately is outdated and the apt sources are no longer available.

Starting Image

The starting image is ubuntu:latest (The ubuntu:latest tag points to the "latest LTS", since that's the version recommended for general use.) at the time of writing latest points to Ubuntu 22.04 jammy.

The starting image is only marginally important, since internally we use manually installed toolchains.

The Toolchains

The toolchains are download from http://downloads.arduino.cc/tools/internal/toolchains.tar.gz . Inside that archive there are:

  • gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu toolchain to crosscompile for linux_arm64 (downloaded from here)
  • gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf toolchain used to crosscompile for linux_arm (downloaded from here)
  • i686-ubuntu16.04-linux-gnu toolchain to crosscompile for linux_386 (32bit)
  • x86_64-ubuntu16.04-linux-gnu-gcc toolchain to crosscompile for linux_amd64
  • osxcross toolchain to crosscompile for darwin_amd64. Inside osxcross/tarballs/ there is already MacOSX10.15.sdk.tar.xz: the SDK required by macos to crosscompile (we tried with SDK version 10.09 but it was too old)

Regarding the two ubuntu toolchains: in the beginning we tried to use the ones shipped with 12.04 but they caused some build errors because they were too old, so we upgraded to 16.04 ones. They are created using crosstool-ng.

Apparently, osxcross does not have tags or version so we checkout a specific commit in order to have a pinned environment.

The last toolchain required to crosscompile for windows is mingw-w64 and it's installed through apt along with other useful packages.

Once the toolchains are installed in /opt we add the binaries to the PATH env variable, to easily use them in the CI.

Copying and Building Libraries

As explained in the other README.md there are some libraries that needs to be compiled, in order to create static binaries. This is achieved by copying deps/ directory inside /opt/lib/ in the container and then by using build_libs.sh script here

Multi-stage build

To reduce the overall dimension of the docker image we used the multi-stage build. But the image still 8GB.

How to build and use the container

Usefull commands you can use:

  • docker build -t ghcr.io/arduino/crossbuild:<version> . to build the container
  • docker push ghcr.io/arduino/crossbuild:<version> to push the image to github remote registry
  • docker run -it --name crossbuild -v $PWD:/workdir ghcr.io/arduino/crossbuild:<version> to get a shell inside the container and use the toolchains available inside (just like the CI does).

crossbuild's People

Contributors

umbynos avatar matteopologruto avatar facchinm avatar 1jo1 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.