Compare commits

...

16 Commits

Author SHA1 Message Date
95c12a3a87 Merge pull request #559 from tresf/patch-1
Remove cpp, allow gcc -E fallback
2021-08-12 02:31:50 +02:00
713ebf0491 Remove cpp from ARMv7 too 2021-08-11 15:55:51 -04:00
434877cfe1 Remove cpp, allow gcc -E fallback
Also switches to using mingw-w64 "familiar" suffixes
2021-08-11 15:48:36 -04:00
428fa38a94 Merge pull request #558 from bensuperpc/Update_readme_and_makefile
Update Readme and Makefile
2021-08-11 18:58:01 +02:00
a4cb929bef Fix build
Fix build

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-11 18:32:57 +02:00
84cab46099 Update Readme and Makefile
Update Readme and Makefile

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-11 10:58:03 +02:00
4481ba2a8e Merge pull request #557 from bensuperpc/add_windows_ARM64
Add windows arm64 and armv7
2021-08-11 09:57:34 +02:00
da8d9a8208 Merge branch 'master' into add_windows_ARM64 2021-08-11 09:57:26 +02:00
f84173c7e4 Merge pull request #555 from bensuperpc/Update_tools
Update Readme and tools scripts
2021-08-11 08:05:45 +02:00
29ccbad9aa Merge pull request #539 from bensuperpc/add_tinycc
Add tinycc
2021-08-11 08:05:34 +02:00
5c45f72a87 Update Readme
Update Readme

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-11 01:18:07 +02:00
526cab12a8 Add windows-armv7
Add windows-armv7

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-11 01:12:48 +02:00
92102d9138 Add windows-arm64
Add windows-arm64

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-11 01:07:37 +02:00
5b175f9eac Update README
Update README

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-10 21:39:37 +02:00
b5dc5e6488 Update README ans tools scripts
Update README ans tools scripts

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-10 21:32:27 +02:00
fd49a1de52 Merge commit 'a42f26cc753f43041c6c25159bd4b79ff29cd210' into Update_tools 2021-08-10 21:24:00 +02:00
9 changed files with 198 additions and 39 deletions

View File

@ -53,9 +53,9 @@ jobs:
linux-x64-clang, linux-s390x, linux-x64, linux-x86,
linux-mips, linux-ppc64le, web-wasm,
manylinux2014-x64, manylinux2014-x86,
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, linux-x64-tinycc, linux-xtensa-uclibc]
windows-static-x64, windows-static-x64-posix, windows-static-x86, windows-armv7,
windows-shared-x64, windows-shared-x64-posix, windows-shared-x86, windows-arm64,
linux-riscv64, linux-riscv32, linux-m68k-uclibc, linux-xtensa-uclibc, linux-x64-tinycc]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2

View File

@ -19,14 +19,14 @@ STANDARD_IMAGES = android-arm android-arm64 android-x86 android-x86_64 \
linux-armv6 linux-armv6-lts linux-armv6-musl \
linux-armv7l-musl linux-armv7 linux-armv7a \
linux-mips linux-ppc64le linux-riscv64 linux-riscv32 linux-xtensa-uclibc \
windows-static-x86 windows-static-x64 windows-static-x64-posix \
windows-shared-x86 windows-shared-x64 windows-shared-x64-posix
windows-static-x86 windows-static-x64 windows-static-x64-posix windows-armv7 \
windows-shared-x86 windows-shared-x64 windows-shared-x64-posix windows-arm64
# Generated Dockerfiles.
GEN_IMAGES = android-arm android-arm64 \
linux-x86 linux-x64 linux-x64-clang linux-arm64 linux-arm64-musl linux-arm64-full \
manylinux2014-x64 manylinux2014-x86 \
web-wasm linux-mips \
web-wasm linux-mips windows-arm64 windows-armv7 \
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 \

View File

@ -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
@ -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:
```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**.
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
For the impatient, here\'s how to compile a hello world for armv7:
```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:
```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.
@ -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_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 |
@ -94,6 +102,7 @@ The dockcross script will execute the given command-line inside the container, a
| dockcross/linux-x86 | x86 | GCC | Linux |
| dockcross/linux-x64 | x86_64 | GCC | Linux |
| dockcross/linux-x64-clang | x86_64 | Clang | Linux |
| dockcross/linux-x64-tinycc | x86_64 | tcc + GCC | Linux |
| dockcross/web-wasm | JS | LLVM | Web (JS) |
| dockcross/windows-shared-x86 | x86 | GCC | Windows |
| dockcross/windows-shared-x64 | x86_64 | GCC | Windows |
@ -101,6 +110,8 @@ The dockcross script will execute the given command-line inside the container, a
| dockcross/windows-static-x86 | x86 | GCC | Windows |
| dockcross/windows-static-x64 | x86_64 | GCC | Windows |
| dockcross/windows-static-x64-posix | x86_64 | GCC | Windows |
| dockcross/windows-armv7 | ARMv7 | Clang | Windows |
| dockcross/windows-arm64 | ARMv8 | Clang | Windows |
## Cross compilers
@ -140,6 +151,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)
@ -255,6 +272,12 @@ Linux clang x86_64/amd64 compiler. Since the Docker image is natively x86_64, th
Linux i686 cross compiler.
### dockcross/linux-x64-tinycc
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/linux-x64-tinycc/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/linux-x64-tinycc)
Linux tcc compiler for C compiler, and GCC for C++ compiler, for linux x86_64/amd64 arch.
### dockcross/manylinux2014-x64
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/manylinux2014-x64/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/manylinux2014-x64)
@ -311,6 +334,18 @@ linking.
32-bit Windows cross-compiler based on [MXE/MinGW-w64](https://mxe.cc/) with win32 threads and dynamic linking.
### dockcross/windows-armv7
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/windows-armv7/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/windows-armv7)
ARMv7 32-bit Windows cross-compiler based on [LLVM/MinGW-w64](https://github.com/mstorsjo/llvm-mingw)
### dockcross/windows-arm64
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/dockcross/windows-arm64/latest) ![Docker Pulls](https://img.shields.io/docker/pulls/dockcross/windows-arm64)
ARMv8 64-bit Windows cross-compiler based on [llvm-mingw](https://github.com/mstorsjo/llvm-mingw)
## Summary legacy cross compilers
The list of docker images that are no longer supported or broken
@ -349,12 +384,13 @@ cross-compiler Docker image or the dockcross script itself.
To easily download all images, the convenience target `display_images`
could be used:
```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
@ -362,6 +398,7 @@ To automatically install in `~/bin` the dockcross scripts for each
images already downloaded, the convenience target `display_images` could
be used:
```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
@ -372,6 +409,7 @@ be used:
docker run dockcross/$image > ~/bin/dockcross-$image && \
chmod u+x ~/bin/dockcross-$image
done
```
## Dockcross configuration
@ -416,17 +454,21 @@ In order to extend Dockcross images with your own commands, one must:
An example Dockerfile would be:
```
FROM dockcross/linux-armv7
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.
```
## What is the difference between **dockcross** and **dockbuild** ?

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

View File

@ -0,0 +1,28 @@
FROM dockcross/base:latest
MAINTAINER Matt McCormick "matt.mccormick@kitware.com"
ENV XCC_PREFIX /usr/xcc
ENV CROSS_TRIPLE aarch64-w64-mingw32
ENV CROSS_ROOT ${XCC_PREFIX}/${CROSS_TRIPLE}-cross
ARG DOWNLOAD_URL=https://github.com/mstorsjo/llvm-mingw/releases/download/20210423/llvm-mingw-20210423-msvcrt-ubuntu-18.04-x86_64.tar.xz
ENV DOWNLOAD_URL=${DOWNLOAD_URL}
RUN mkdir -p ${CROSS_ROOT} && wget -qO- "${DOWNLOAD_URL}" | tar xJvf - --strip 1 -C ${CROSS_ROOT}/ > /dev/null
ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
AR=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ar \
CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \
CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ \
LD=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ld \
FC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gfortran
COPY Toolchain.cmake ${CROSS_ROOT}/
ENV CMAKE_TOOLCHAIN_FILE ${CROSS_ROOT}/Toolchain.cmake
# Linux kernel cross compilation variables
ENV PATH ${PATH}:${CROSS_ROOT}/bin
ENV CROSS_COMPILE ${CROSS_TRIPLE}-
ENV ARCH arm64
#include "common.label-and-env"

View File

@ -0,0 +1,19 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(cross_triple $ENV{CROSS_TRIPLE})
set(cross_root $ENV{CROSS_ROOT})
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_Fortran_COMPILER $ENV{FC})
set(CMAKE_CXX_FLAGS "-I ${cross_root}/include/")
set(CMAKE_FIND_ROOT_PATH ${cross_root} ${cross_root}/${cross_triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-aarch64)

View File

@ -0,0 +1,28 @@
FROM dockcross/base:latest
MAINTAINER Matt McCormick "matt.mccormick@kitware.com"
ENV XCC_PREFIX /usr/xcc
ENV CROSS_TRIPLE armv7-w64-mingw32
ENV CROSS_ROOT ${XCC_PREFIX}/${CROSS_TRIPLE}-cross
ARG DOWNLOAD_URL=https://github.com/mstorsjo/llvm-mingw/releases/download/20210423/llvm-mingw-20210423-msvcrt-ubuntu-18.04-x86_64.tar.xz
ENV DOWNLOAD_URL=${DOWNLOAD_URL}
RUN mkdir -p ${CROSS_ROOT} && wget -qO- "${DOWNLOAD_URL}" | tar xJvf - --strip 1 -C ${CROSS_ROOT}/ > /dev/null
ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
AR=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ar \
CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \
CXX=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-g++ \
LD=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-ld \
FC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gfortran
COPY Toolchain.cmake ${CROSS_ROOT}/
ENV CMAKE_TOOLCHAIN_FILE ${CROSS_ROOT}/Toolchain.cmake
# Linux kernel cross compilation variables
ENV PATH ${PATH}:${CROSS_ROOT}/bin
ENV CROSS_COMPILE ${CROSS_TRIPLE}-
ENV ARCH arm
#include "common.label-and-env"

View File

@ -0,0 +1,19 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(cross_triple $ENV{CROSS_TRIPLE})
set(cross_root $ENV{CROSS_ROOT})
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_Fortran_COMPILER $ENV{FC})
set(CMAKE_CXX_FLAGS "-I ${cross_root}/include/")
set(CMAKE_FIND_ROOT_PATH ${cross_root} ${cross_root}/${cross_triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-arm)