Compare commits

..

11 Commits

Author SHA1 Message Date
6a512eeb08 Merge branch 'master' into add_tinycc 2021-08-10 21:22:16 +02:00
88222c9793 Merge remote-tracking branch 'origin/master' into add_tinycc 2021-08-10 00:46:39 +02:00
e6e3cde831 Fix merge
Fix merge

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-07 13:35:38 +02:00
1ce323ce7e Merge branch 'master' into add_tinycc 2021-08-07 01:04:38 +02:00
47f1545e66 Fix merge
Fix merge

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-06 23:09:08 +02:00
bd6d6d77d4 Merge remote-tracking branch 'origin/master' into add_tinycc 2021-08-05 16:58:52 +02:00
37ece838f8 Disable libgcc
Disable libgcc

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-04 21:40:16 +02:00
bca0a99e99 Multi lines arch_name in CI
Multi lines arch_name in CI

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-04 19:00:48 +02:00
3c74c2f0d2 Fix GCC build
Fix GCC build

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-04 18:53:19 +02:00
d76d2ae8c5 Merge remote-tracking branch 'origin/HEAD' into add_tinycc 2021-08-04 18:20:35 +02:00
ed942b52f5 Add tinycc image
Add tinycc image

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-08-04 14:24:19 +02:00
8 changed files with 81 additions and 80 deletions

View File

@ -55,7 +55,7 @@ jobs:
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-xtensa-uclibc]
linux-riscv64, linux-riscv32, linux-m68k-uclibc, linux-x64-tinycc, linux-xtensa-uclibc]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2

View File

@ -15,7 +15,7 @@ BIN = ./bin
# These images are built using the "build implicit rule"
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-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-armv7l-musl linux-armv7 linux-armv7a \
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-armv6 linux-armv6-lts linux-armv6-musl \
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))

View File

@ -13,14 +13,13 @@ 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**, **AS** etc) are set to point to the appropriate tools in the container.
- Make variables **CC**, **CXX**, **LD** 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
@ -41,32 +40,26 @@ 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/
```
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'
```
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...]
```
./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.
@ -80,7 +73,6 @@ 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 |
@ -148,12 +140,6 @@ 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)
@ -363,13 +349,12 @@ 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
```
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
@ -377,18 +362,16 @@ 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
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
```
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
@ -433,21 +416,17 @@ 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** ?

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

View File

@ -1,23 +0,0 @@
#!/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