Merge branch 'master' into add_windows_ARM64

This commit is contained in:
Bensuperpc 2021-08-11 09:57:26 +02:00 committed by GitHub
commit da8d9a8208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 125 additions and 36 deletions

View File

@ -55,7 +55,7 @@ jobs:
manylinux2014-x64, manylinux2014-x86, manylinux2014-x64, manylinux2014-x86,
windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-armv7, windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-armv7,
windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, windows-arm64, windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, windows-arm64,
linux-riscv64, linux-riscv32, linux-m68k-uclibc, linux-xtensa-uclibc] linux-riscv64, linux-riscv32, linux-m68k-uclibc, linux-xtensa-uclibc, linux-x64-tinycc]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v2

View File

@ -15,7 +15,7 @@ BIN = ./bin
# These images are built using the "build implicit rule" # These images are built using the "build implicit rule"
STANDARD_IMAGES = android-arm android-arm64 android-x86 android-x86_64 \ STANDARD_IMAGES = android-arm android-arm64 android-x86 android-x86_64 \
linux-x86 linux-x64 linux-x64-clang linux-arm64 linux-arm64-musl linux-arm64-full \ linux-x86 linux-x64 linux-x64-clang linux-arm64 linux-arm64-musl linux-arm64-full \
linux-armv5 linux-armv5-musl linux-m68k-uclibc linux-s390x \ linux-armv5 linux-armv5-musl linux-m68k-uclibc linux-s390x linux-x64-tinycc \
linux-armv6 linux-armv6-lts linux-armv6-musl \ linux-armv6 linux-armv6-lts linux-armv6-musl \
linux-armv7l-musl linux-armv7 linux-armv7a \ linux-armv7l-musl linux-armv7 linux-armv7a \
linux-mips linux-ppc64le linux-riscv64 linux-riscv32 linux-xtensa-uclibc \ linux-mips linux-ppc64le linux-riscv64 linux-riscv32 linux-xtensa-uclibc \
@ -32,7 +32,7 @@ GEN_IMAGES = android-arm android-arm64 \
linux-armv7 linux-armv7a linux-armv7l-musl \ linux-armv7 linux-armv7a linux-armv7l-musl \
linux-armv6 linux-armv6-lts linux-armv6-musl \ linux-armv6 linux-armv6-lts linux-armv6-musl \
linux-armv5 linux-armv5-musl linux-ppc64le linux-s390x \ linux-armv5 linux-armv5-musl linux-ppc64le linux-s390x \
linux-riscv64 linux-riscv32 linux-m68k-uclibc linux-xtensa-uclibc linux-riscv64 linux-riscv32 linux-m68k-uclibc linux-x64-tinycc linux-xtensa-uclibc
GEN_IMAGE_DOCKERFILES = $(addsuffix /Dockerfile,$(GEN_IMAGES)) GEN_IMAGE_DOCKERFILES = $(addsuffix /Dockerfile,$(GEN_IMAGES))

View File

@ -13,13 +13,14 @@ Cross compiling toolchains in Docker images.
- Most images also contain an emulator for the target system. - Most images also contain an emulator for the target system.
- Clean separation of build tools, source code, and build artifacts. - 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). - 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. - Recent [CMake](https://cmake.org) and ninja are precompiled.
- [Conan.io](https://www.conan.io) can be used as a package manager. - [Conan.io](https://www.conan.io) can be used as a package manager.
- Toolchain files configured for CMake. - Toolchain files configured for CMake.
- Current directory is mounted as the container\'s workdir, `/work`. - 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/). - 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. - 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 ## Examples
@ -40,26 +41,32 @@ 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: 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 ```bash
chmod +x ./dockcross docker run --rm CROSS_COMPILER_IMAGE_NAME > ./dockcross
mv ./dockcross ~/bin/ 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**. 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 ## Usage
For the impatient, here\'s how to compile a hello world for armv7: For the impatient, here\'s how to compile a hello world for armv7:
cd ~/src/dockcross ```bash
docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7 cd ~/src/dockcross
chmod +x ./dockcross-linux-armv7 docker run --rm dockcross/linux-armv7 > ./dockcross-linux-armv7
./dockcross-linux-armv7 bash -c '$CC test/C/hello.c -o hello_arm' 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: 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. 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.
@ -73,6 +80,7 @@ The dockcross script will execute the given command-line inside the container, a
| dockcross/android-x86 | x86 | Clang | Android | | dockcross/android-x86 | x86 | Clang | Android |
| dockcross/android-x86_64 | x86_64 | Clang | Android | | dockcross/android-x86_64 | x86_64 | Clang | Android |
| dockcross/linux-arm64 | ARMv8 | GCC | Linux | | dockcross/linux-arm64 | ARMv8 | GCC | Linux |
| dockcross/linux-arm64-full | ARMv8 | GCC | Linux |
| dockcross/linux-arm64-musl | ARMv8 | GCC + musl | Linux | | dockcross/linux-arm64-musl | ARMv8 | GCC + musl | Linux |
| dockcross/linux-armv5 | ARMv5 | GCC | Linux | | dockcross/linux-armv5 | ARMv5 | GCC | Linux |
| dockcross/linux-armv5-musl | ARMv5 | GCC + musl | Linux | | dockcross/linux-armv5-musl | ARMv5 | GCC + musl | Linux |
@ -142,6 +150,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. 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 ### 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) ![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)
@ -363,12 +377,13 @@ cross-compiler Docker image or the dockcross script itself.
To easily download all images, the convenience target `display_images` To easily download all images, the convenience target `display_images`
could be used: could be used:
```bash
curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile
for image in $(make -f dockcross-Makefile display_images); do for image in $(make -f dockcross-Makefile display_images); do
echo "Pulling dockcross/$image" echo "Pulling dockcross/$image"
docker pull dockcross/$image docker pull dockcross/$image
done done
```
## Install all dockcross scripts ## Install all dockcross scripts
@ -376,16 +391,18 @@ To automatically install in `~/bin` the dockcross scripts for each
images already downloaded, the convenience target `display_images` could images already downloaded, the convenience target `display_images` could
be used: be used:
curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile ```bash
for image in $(make -f dockcross-Makefile display_images); do curl https://raw.githubusercontent.com/dockcross/dockcross/master/Makefile -o dockcross-Makefile
if [[ $(docker images -q dockcross/$image) == "" ]]; then for image in $(make -f dockcross-Makefile display_images); do
echo "~/bin/dockcross-$image skipping: image not found locally" if [[ $(docker images -q dockcross/$image) == "" ]]; then
continue echo "~/bin/dockcross-$image skipping: image not found locally"
fi continue
echo "~/bin/dockcross-$image ok" fi
docker run dockcross/$image > ~/bin/dockcross-$image && \ echo "~/bin/dockcross-$image ok"
chmod u+x ~/bin/dockcross-$image docker run dockcross/$image > ~/bin/dockcross-$image && \
done chmod u+x ~/bin/dockcross-$image
done
```
## Dockcross configuration ## Dockcross configuration
@ -430,17 +447,21 @@ In order to extend Dockcross images with your own commands, one must:
An example Dockerfile would be: An example Dockerfile would be:
FROM dockcross/linux-armv7 ```
FROM dockcross/linux-armv7
ENV DEFAULT_DOCKCROSS_IMAGE my_cool_image ENV DEFAULT_DOCKCROSS_IMAGE my_cool_image
RUN apt-get install nano RUN apt-get install nano
```
And then in the shell: 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. docker build -t my_cool_image . ## Builds the dockcross image.
chmod +x linux-armv7 ## Gives the script execution permission. docker run my_cool_image > linux-armv7 ## Creates a helper script named linux-armv7.
./linux-armv7 bash ## Runs the helper script with the argument "bash", which starts an interactive container using your extended image. 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** ? ## What is the difference between **dockcross** and **dockbuild** ?

View File

@ -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"

View File

@ -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)

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec "$@"

23
tools/dockcross-make-builder.sh Executable file
View File

@ -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##*/} <docker imag (ex: linux-x64/linux-x64-clang/linux-arm64/windows-shared-x64/windows-static-x64...)> <make arg.>"
exit 1
fi