Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
impactaky committed Feb 14, 2024
1 parent 0322217 commit 578d487
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 64 deletions.
93 changes: 81 additions & 12 deletions README.md
@@ -1,35 +1,104 @@
# mimic-cross

A cross compile environment Docker image, can be used like docker multiarch
image without speed penalty.
Fast cross-compiled environment requiring no special recipes.

## Usage
## Quick start

Change base image. [Example](/example/binutils.dockerfile)
### Usage

Just use this as base image and build image with `--platform` option.

```Dockerfile
FROM --platform=${BUILDPLATFORM} impactaky/mc-ubuntu22.04-${TARGETARCH}:2.0.0
```

### Run example

Use [binutils build example](/example/binutils.dockerfile).

```bash
cd ./example
docker buildx build --platform=linux/arm64,linux/amd64 -f binutils.dockerfile .
```

This is the result on my local machine. | Base image | sec | |
------------------------------ | ----- | | ubuntu:22.04 (native compile) | 29.9
| | ubuntu:22.04 (cross compile) | 434.8 | | mc-ubuntu22.04 (cross compile) |
34.6 |

### How to introduce mimic-cross to existing image

Please write as following.

```Dockerfile
# FROM ubuntu:20.04
# FROM multiarch/ubuntu-core:arm64-focal
FROM impactaky/mimic-cross:arm64-focal
FROM --platform=${BUILDPLATFORM} impactaky/mc-ubuntu22.04-${TARGETARCH}-host:2.0.0 AS mimic-host
FROM ubuntu:22.04
COPY --from=mimic-host / /mimic-cross
RUN /mimic-cross/mimic-cross.deno/setup.sh
```

## Notes

mimic-cross currently does not support the apt command, please use apt-get.

mimic-cross currently does not support the pip command. Please use
`python3 -m pip` instead.

## Supported environments

Currently, support only ubuntu18.04 or 20.04 and aarch64.
- OS
- ubuntu:22.04
- Build platform
- linux/amd64
- linux/arm64
- Target platform
- linux/amd64
- linux/arm64
- Package manager
- apt-get
- Compiler
- gcc-11
- g++-11
- Language
- python3.10

Supported packages can be found in
[supported.json](/mimic-cross.deno/apt/packages/supported.json)

## How to add support packages

T.B.D.

## How to make runable users binary

T.B.D.

## How mimic-cross works

![Untitled Diagram (1)](https://user-images.githubusercontent.com/37619203/131243313-c4f6264f-621c-47b6-981b-a76f4ec7902f.png)

Mimic-cross introduces binaries running on host into the environment run by
qemu-use-static to speed up the process. To do so, the mimic-cross image has a
sysroot for the host architecture under /host.
sysroot for the host architecture under /mimic-cross.

This allows us to run the program faster without using QEMU instead of
increasing the image size.\
The image size increase can be handled by multistage build.

### More details
### What happen when run package manager

1. Run in target sysroot
2. Check installed package
3. If supported package installed, package install in /mimic-cross sysroot.
4. Set up for mimicking (Patch to elf RUNPATH, etc...)

## Environent variables

### MIMIC_CROSS_DISABLE=1

When this value is set, execute only the original command by qemu and no special
mimic-cross processing.

- [apt package management in mimic-cross](docs/apt-get.md)
- [about mimic python](docs/python3.md)
If you run the pip command with this, you will not be able to invoke the
installed packages in the mimic-cross environment, but you can reduce the image
size if you are simply installing dependencies needed for the build
17 changes: 0 additions & 17 deletions docs/apt-get.md

This file was deleted.

35 changes: 0 additions & 35 deletions docs/python3.md

This file was deleted.

0 comments on commit 578d487

Please sign in to comment.