From ed942b52f55eab92348a402bcadcaa1e47797253 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 4 Aug 2021 14:24:19 +0200 Subject: [PATCH 1/6] Add tinycc image Add tinycc image Signed-off-by: Bensuperpc --- .github/workflows/main.yml | 2 +- Makefile | 4 +-- linux-x64-tinycc/Dockerfile.in | 31 +++++++++++++++++++++++ linux-x64-tinycc/Toolchain.cmake | 12 +++++++++ linux-x64-tinycc/x86_64-linux-gnu-noop.sh | 2 ++ 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 linux-x64-tinycc/Dockerfile.in create mode 100644 linux-x64-tinycc/Toolchain.cmake create mode 100755 linux-x64-tinycc/x86_64-linux-gnu-noop.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2799ce6..afad9a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,7 @@ jobs: strategy: fail-fast: false matrix: - arch_name: [android-arm, android-arm64, android-x86, android-x86_64, web-wasm, linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, manylinux2014-x64, manylinux2014-x86, manylinux2014-aarch64, windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, linux-riscv64, linux-riscv32, linux-m68k-uclibc] + arch_name: [android-arm, android-arm64, android-x86, android-x86_64, web-wasm, linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, manylinux2014-x64, manylinux2014-x86, manylinux2014-aarch64, windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, linux-riscv64, linux-riscv32, linux-x64-tinycc, linux-m68k-uclibc] steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 diff --git a/Makefile b/Makefile index 8b48621..f79df83 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,10 @@ ORG = dockcross BIN = ./bin # These images are built using the "build implicit rule" -STANDARD_IMAGES = linux-s390x android-arm android-arm64 android-x86 android-x86_64 linux-x86 linux-x64 linux-arm64 linux-x64-clang linux-arm64-musl linux-armv5 linux-armv5-musl linux-armv6 linux-armv6-musl linux-armv7 linux-armv7a linux-armv7l-musl linux-mips linux-ppc64le windows-static-x86 windows-static-x64 windows-static-x64-posix windows-shared-x86 windows-shared-x64 windows-shared-x64-posix linux-riscv64 linux-riscv32 linux-m68k-uclibc +STANDARD_IMAGES = linux-s390x android-arm android-arm64 android-x86 android-x86_64 linux-x86 linux-x64 linux-arm64 linux-x64-clang linux-arm64-musl linux-armv5 linux-armv5-musl linux-armv6 linux-armv6-musl linux-armv7 linux-armv7a linux-armv7l-musl linux-mips linux-ppc64le windows-static-x86 windows-static-x64 windows-static-x64-posix windows-shared-x86 windows-shared-x64 windows-shared-x64-posix linux-riscv64 linux-riscv32 linux-m68k-uclibc linux-x64-tinycc # Generated Dockerfiles. -GEN_IMAGES = linux-s390x android-arm android-arm64 linux-x86 linux-x64 linux-mips linux-x64-clang manylinux1-x64 manylinux1-x86 manylinux2010-x64 manylinux2010-x86 manylinux2014-x64 manylinux2014-x86 manylinux2014-aarch64 web-wasm linux-arm64 linux-arm64-musl windows-static-x86 windows-static-x64 windows-static-x64-posix windows-shared-x86 windows-shared-x64 windows-shared-x64-posix linux-armv7 linux-armv7a linux-armv7l-musl linux-armv6 linux-armv6-musl linux-armv5 linux-armv5-musl linux-ppc64le linux-riscv64 linux-riscv32 linux-m68k-uclibc +GEN_IMAGES = linux-s390x android-arm android-arm64 linux-x86 linux-x64 linux-mips linux-x64-clang manylinux1-x64 manylinux1-x86 manylinux2010-x64 manylinux2010-x86 manylinux2014-x64 manylinux2014-x86 manylinux2014-aarch64 web-wasm linux-arm64 linux-arm64-musl windows-static-x86 windows-static-x64 windows-static-x64-posix windows-shared-x86 windows-shared-x64 windows-shared-x64-posix linux-armv7 linux-armv7a linux-armv7l-musl linux-armv6 linux-armv6-musl linux-armv5 linux-armv5-musl linux-ppc64le linux-riscv64 linux-riscv32 linux-m68k-uclibc linux-x64-tinycc GEN_IMAGE_DOCKERFILES = $(addsuffix /Dockerfile,$(GEN_IMAGES)) diff --git a/linux-x64-tinycc/Dockerfile.in b/linux-x64-tinycc/Dockerfile.in new file mode 100644 index 0000000..469b0f4 --- /dev/null +++ b/linux-x64-tinycc/Dockerfile.in @@ -0,0 +1,31 @@ +FROM dockcross/base:latest +MAINTAINER Matt McCormick "matt.mccormick@kitware.com" + +RUN git clone --recurse-submodules https://repo.or.cz/tinycc.git \ + && cd tinycc \ + && ./configure --cpu=x86_64 \ + && make -j$(nproc) \ + && make test \ + && make install + +ENV PATH="/usr/local/bin:${PATH}" +# Test if compiler work +RUN tcc -v + +ENV CROSS_TRIPLE x86_64-linux-gnu +ENV CROSS_ROOT /usr/bin +ENV AS=/usr/bin/${CROSS_TRIPLE}-as \ + AR=/usr/bin/${CROSS_TRIPLE}-ar \ + CC=/usr/local/bin/tcc \ + CPP=/usr/bin/${CROSS_TRIPLE}-cpp \ + CXX=/usr/bin/${CROSS_TRIPLE}-g++ \ + LD=/usr/bin/${CROSS_TRIPLE}-ld \ + FC=/usr/bin/${CROSS_TRIPLE}-gfortran + + +COPY ${CROSS_TRIPLE}-noop.sh /usr/bin/${CROSS_TRIPLE}-noop + +COPY Toolchain.cmake /usr/lib/${CROSS_TRIPLE}/ +ENV CMAKE_TOOLCHAIN_FILE /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake + +#include "common.label-and-env" diff --git a/linux-x64-tinycc/Toolchain.cmake b/linux-x64-tinycc/Toolchain.cmake new file mode 100644 index 0000000..9866b79 --- /dev/null +++ b/linux-x64-tinycc/Toolchain.cmake @@ -0,0 +1,12 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(cross_triple "x86_64-linux-gnu") + +set(CMAKE_C_COMPILER $ENV{CC}) +set(CMAKE_CXX_COMPILER $ENV{CXX}) +set(CMAKE_Fortran_COMPILER $ENV{FC}) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) + +set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/${cross_triple}-noop) diff --git a/linux-x64-tinycc/x86_64-linux-gnu-noop.sh b/linux-x64-tinycc/x86_64-linux-gnu-noop.sh new file mode 100755 index 0000000..311cb8c --- /dev/null +++ b/linux-x64-tinycc/x86_64-linux-gnu-noop.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$@" From 3c74c2f0d244f3d78a4d4d5fa4d0c2e13a2116a6 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 4 Aug 2021 18:53:19 +0200 Subject: [PATCH 2/6] Fix GCC build Fix GCC build Signed-off-by: Bensuperpc --- linux-x64-tinycc/Dockerfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-x64-tinycc/Dockerfile.in b/linux-x64-tinycc/Dockerfile.in index 469b0f4..aa4f4c1 100644 --- a/linux-x64-tinycc/Dockerfile.in +++ b/linux-x64-tinycc/Dockerfile.in @@ -3,7 +3,7 @@ MAINTAINER Matt McCormick "matt.mccormick@kitware.com" RUN git clone --recurse-submodules https://repo.or.cz/tinycc.git \ && cd tinycc \ - && ./configure --cpu=x86_64 \ + && ./configure --cpu=x86_64 --with-libgcc \ && make -j$(nproc) \ && make test \ && make install From bca0a99e99d767ae6de896bb8ddb090af882adf6 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 4 Aug 2021 19:00:48 +0200 Subject: [PATCH 3/6] Multi lines arch_name in CI Multi lines arch_name in CI Signed-off-by: Bensuperpc --- .github/workflows/main.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afad9a6..660423c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,15 @@ jobs: strategy: fail-fast: false matrix: - arch_name: [android-arm, android-arm64, android-x86, android-x86_64, web-wasm, linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, manylinux2014-x64, manylinux2014-x86, manylinux2014-aarch64, windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, linux-riscv64, linux-riscv32, linux-x64-tinycc, linux-m68k-uclibc] + arch_name: [android-arm, android-arm64, android-x86, android-x86_64, + web-wasm, linux-arm64, linux-arm64-musl, linux-armv5, linux-armv5-musl, + linux-armv6, linux-armv6-musl, linux-armv7, linux-armv7a, linux-armv7l-musl, + linux-x64-clang, linux-s390x, linux-x64, linux-x86, linux-mips, linux-ppc64le, + manylinux1-x64, manylinux1-x86, manylinux2010-x64, manylinux2010-x86, + manylinux2014-x64, manylinux2014-x86, manylinux2014-aarch64, windows-static-x64, + windows-static-x64-posix, windows-static-x86, windows-shared-x64, + windows-shared-x64-posix, windows-shared-x86, linux-riscv64, + inux-riscv32, linux-x64-tinycc, linux-m68k-uclibc] steps: - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 From 37ece838f830ad1d3b2f32c130f97832f3f49ac1 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Wed, 4 Aug 2021 21:40:16 +0200 Subject: [PATCH 4/6] Disable libgcc Disable libgcc Signed-off-by: Bensuperpc --- linux-x64-tinycc/Dockerfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-x64-tinycc/Dockerfile.in b/linux-x64-tinycc/Dockerfile.in index aa4f4c1..469b0f4 100644 --- a/linux-x64-tinycc/Dockerfile.in +++ b/linux-x64-tinycc/Dockerfile.in @@ -3,7 +3,7 @@ MAINTAINER Matt McCormick "matt.mccormick@kitware.com" RUN git clone --recurse-submodules https://repo.or.cz/tinycc.git \ && cd tinycc \ - && ./configure --cpu=x86_64 --with-libgcc \ + && ./configure --cpu=x86_64 \ && make -j$(nproc) \ && make test \ && make install From b5dc5e6488feb9c873db7b2f997ee04bc9d4bd35 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 10 Aug 2021 21:32:27 +0200 Subject: [PATCH 5/6] Update README ans tools scripts Update README ans tools scripts Signed-off-by: Bensuperpc --- README.md | 12 ++++++++-- ...-builder.sh => dockcross-cmake-builder.sh} | 0 tools/dockcross-make-builder.sh | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) rename tools/{dockcross-builder.sh => dockcross-cmake-builder.sh} (100%) create mode 100755 tools/dockcross-make-builder.sh diff --git a/README.md b/README.md index f336ed6..99d98f5 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,14 @@ Cross compiling toolchains in Docker images. - Most images also contain an emulator for the target system. - Clean separation of build tools, source code, and build artifacts. - Commands in the container are run as the calling user, so that any created files have the expected ownership, (i.e. not root). -- Make variables **CC**, **CXX**, **LD** etc) are set to point to the appropriate tools in the container. +- Make variables **CC**, **CXX**, **LD**, **AS** etc) are set to point to the appropriate tools in the container. - Recent [CMake](https://cmake.org) and ninja are precompiled. - [Conan.io](https://www.conan.io) can be used as a package manager. - Toolchain files configured for CMake. - Current directory is mounted as the container\'s workdir, `/work`. - Works with the [Docker for Mac](https://docs.docker.com/docker-for-mac/) and [Docker for Windows](https://docs.docker.com/docker-for-windows/). - Support using alternative container executor by setting **OCI_EXE** environment variable. By default, it searches for [docker](https://www.docker.com) and [podman](https://podman.io) executable. +- [crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) and [buildroot](https://github.com/buildroot/buildroot) configuration files. ## Examples @@ -46,7 +47,7 @@ To install the helper script, run one of the images with no arguments, and redir Where **CROSS_COMPILER_IMAGE_NAME** is the name of the cross-compiler toolchain Docker instance, e.g: **dockcross/linux-armv7**. -Only 64-bit x86_64 images are provided; a 64-bit x86_64 host system is required. +Only 64-bit x86_64 images are provided, a 64-bit x86_64 host system is required. ## Usage @@ -73,6 +74,7 @@ The dockcross script will execute the given command-line inside the container, a | dockcross/android-x86 | x86 | Clang | Android | | dockcross/android-x86_64 | x86_64 | Clang | Android | | dockcross/linux-arm64 | ARMv8 | GCC | Linux | +| dockcross/linux-arm64-full | ARMv8 | GCC | Linux | | dockcross/linux-arm64-musl | ARMv8 | GCC + musl | Linux | | dockcross/linux-armv5 | ARMv5 | GCC | Linux | | dockcross/linux-armv5-musl | ARMv5 | GCC + musl | Linux | @@ -140,6 +142,12 @@ The Android NDK standalone toolchain for the x86_64 architecture. Cross compiler for the 64-bit ARM platform on Linux, also known as AArch64. +### dockcross/linux-arm64-full + +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/linux-arm64-full/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/linux-arm64-full) + +Cross compiler for the 64-bit ARM platform on Linux, with cross-libs: SDL2, OpenSSL, Boost, OpenCV and Qt5 (minimal). + ### dockcross/linux-arm64-musl ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/linux-arm64-musl/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/linux-arm64-musl) diff --git a/tools/dockcross-builder.sh b/tools/dockcross-cmake-builder.sh similarity index 100% rename from tools/dockcross-builder.sh rename to tools/dockcross-cmake-builder.sh diff --git a/tools/dockcross-make-builder.sh b/tools/dockcross-make-builder.sh new file mode 100755 index 0000000..2f45d81 --- /dev/null +++ b/tools/dockcross-make-builder.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +if (( $# >= 1 )); then + image=$1 + build_file=build-${image%:*} + shift 1 + + make_arg=$* + echo "make arg: $make_arg" + + #echo "Pulling dockcross/$image" + #docker pull dockcross/"$image" + + echo "Make script dockcross-$image" + docker run --rm dockcross/"$image" > ./dockcross-"$image" + chmod +x ./dockcross-"$image" + + echo "Build $build_file" + ./dockcross-"$image" bash -c 'make CXX=${CXX} CC=${CC} AR=${AR} AS=${AS} LD=${LD} CPP=${CPP} FC=${FC} '"$make_arg" +else + echo "Usage: ${0##*/} " + exit 1 +fi From 5b175f9eac76ef015306f2595c3511de2937f407 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 10 Aug 2021 21:39:37 +0200 Subject: [PATCH 6/6] Update README Update README Signed-off-by: Bensuperpc --- README.md | 75 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 99d98f5..fb4f09a 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,11 @@ This image does not need to be run manually. Instead, there is a helper script t To install the helper script, run one of the images with no arguments, and redirect the output to a file: - docker run --rm CROSS_COMPILER_IMAGE_NAME > ./dockcross - chmod +x ./dockcross - mv ./dockcross ~/bin/ +```bash +docker run --rm CROSS_COMPILER_IMAGE_NAME > ./dockcross +chmod +x ./dockcross +mv ./dockcross ~/bin/ +``` Where **CROSS_COMPILER_IMAGE_NAME** is the name of the cross-compiler toolchain Docker instance, e.g: **dockcross/linux-armv7**. @@ -53,14 +55,18 @@ Only 64-bit x86_64 images are provided, a 64-bit x86_64 host system is required. For the impatient, here\'s how to compile a hello world for armv7: - cd ~/src/dockcross - docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7 - chmod +x ./dockcross-linux-armv7 - ./dockcross-linux-armv7 bash -c '$CC test/C/hello.c -o hello_arm' +```bash +cd ~/src/dockcross +docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7 +chmod +x ./dockcross-linux-armv7 +./dockcross-linux-armv7 bash -c '$CC test/C/hello.c -o hello_arm' +``` Note how invoking any toolchain command (make, gcc, etc.) is just a matter of prepending the **dockcross** script on the commandline: - ./dockcross-linux-armv7 [command] [args...] +```bash +./dockcross-linux-armv7 [command] [args...] +``` The dockcross script will execute the given command-line inside the container, along with all arguments passed after the command. Commands that evaluate environmental variables in the image, like **$CC** or **$CXX** above, should be executed in [bash -c]. The present working directory is mounted within the image, which can be used to make source code available in the Docker container. @@ -357,12 +363,13 @@ cross-compiler Docker image or the dockcross script itself. To easily download all images, the convenience target `display_images` could be used: - - curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile - for image in $(make -f dockcross-Makefile display_images); do - echo "Pulling dockcross/$image" - docker pull dockcross/$image - done +```bash +curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile +for image in $(make -f dockcross-Makefile display_images); do + echo "Pulling dockcross/$image" + docker pull dockcross/$image +done +``` ## Install all dockcross scripts @@ -370,16 +377,18 @@ To automatically install in `~/bin` the dockcross scripts for each images already downloaded, the convenience target `display_images` could be used: - curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile - for image in $(make -f dockcross-Makefile display_images); do - if [[ $(docker images -q dockcross/$image) == "" ]]; then - echo "~/bin/dockcross-$image skipping: image not found locally" - continue - fi - echo "~/bin/dockcross-$image ok" - docker run dockcross/$image > ~/bin/dockcross-$image && \ - chmod u+x ~/bin/dockcross-$image - done +```bash +curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile +for image in $(make -f dockcross-Makefile display_images); do + if [[ $(docker images -q dockcross/$image) == "" ]]; then + echo "~/bin/dockcross-$image skipping: image not found locally" + continue + fi + echo "~/bin/dockcross-$image ok" + docker run dockcross/$image > ~/bin/dockcross-$image && \ + chmod u+x ~/bin/dockcross-$image +done +``` ## Dockcross configuration @@ -424,17 +433,21 @@ In order to extend Dockcross images with your own commands, one must: An example Dockerfile would be: - FROM dockcross/linux-armv7 +``` +FROM dockcross/linux-armv7 - ENV DEFAULT_DOCKCROSS_IMAGE my_cool_image - RUN apt-get install nano +ENV DEFAULT_DOCKCROSS_IMAGE my_cool_image +RUN apt-get install nano +``` And then in the shell: - docker build -t my_cool_image . ## Builds the dockcross image. - docker run my_cool_image > linux-armv7 ## Creates a helper script named linux-armv7. - chmod +x linux-armv7 ## Gives the script execution permission. - ./linux-armv7 bash ## Runs the helper script with the argument "bash", which starts an interactive container using your extended image. +``` +docker build -t my_cool_image . ## Builds the dockcross image. +docker run my_cool_image > linux-armv7 ## Creates a helper script named linux-armv7. +chmod +x linux-armv7 ## Gives the script execution permission. +./linux-armv7 bash ## Runs the helper script with the argument "bash", which starts an interactive container using your extended image. +``` ## What is the difference between **dockcross** and **dockbuild** ?