Repository: cross-rs/cross
Branch: main
Commit: 588b3c99db52
Files: 361
Total size: 1016.6 KB
Directory structure:
gitextract_3cdscn2l/
├── .cargo/
│ └── config.toml
├── .changes/
│ ├── 1006.json
│ ├── 1018.json
│ ├── 1023.json
│ ├── 1024.json
│ ├── 1028-1132.json
│ ├── 1032.json
│ ├── 1033.json
│ ├── 1038-1220-1482.json
│ ├── 1039.json
│ ├── 1049-1142.json
│ ├── 1054.json
│ ├── 1057.json
│ ├── 1063-1125-1134.json
│ ├── 1073.json
│ ├── 1078.json
│ ├── 1084.json
│ ├── 1085.json
│ ├── 1105.json
│ ├── 1112.json
│ ├── 1118.json
│ ├── 1123.json
│ ├── 1138.json
│ ├── 1159.json
│ ├── 1160.json
│ ├── 1164.json
│ ├── 1166.json
│ ├── 1183.json
│ ├── 1199.json
│ ├── 1207.json
│ ├── 1220.json
│ ├── 1246.json
│ ├── 1248.json
│ ├── 1260.json
│ ├── 1265.json
│ ├── 1271.json
│ ├── 1280.json
│ ├── 1317.json
│ ├── 1325.json
│ ├── 1330-1349.json
│ ├── 1333.json
│ ├── 1340.json
│ ├── 1342.json
│ ├── 1346.json
│ ├── 1348.json
│ ├── 1373.json
│ ├── 1374-1490.json
│ ├── 1385.json
│ ├── 1391.json
│ ├── 1399.json
│ ├── 1403-1411.json
│ ├── 1420.json
│ ├── 1458.json
│ ├── 1465.json
│ ├── 1466.json
│ ├── 1468.json
│ ├── 1481.json
│ ├── 1483.json
│ ├── 1485.json
│ ├── 1488.json
│ ├── 1489.json
│ ├── 1491.json
│ ├── 1494.json
│ ├── 1495.json
│ ├── 1525.json
│ ├── 1540.json
│ ├── 1557.json
│ ├── 1574.json
│ ├── 1623.json
│ ├── 1625.json
│ ├── 1630.json
│ ├── 1641.json
│ ├── 1647.json
│ ├── 1651.json
│ ├── 1664.json
│ ├── 1674.json
│ ├── 1681.json
│ ├── 554.json
│ ├── 589.json
│ ├── 591-1095.json
│ ├── 661.json
│ ├── 817.json
│ ├── 880-1111.json
│ ├── 918.json
│ ├── 931.json
│ ├── 934.json
│ ├── 937.json
│ ├── 939.json
│ ├── 942.json
│ ├── 945.json
│ ├── 947.json
│ ├── 952.json
│ ├── 955.json
│ ├── 956.json
│ ├── 957-1393.json
│ ├── 962.json
│ ├── 964.json
│ ├── 968.json
│ ├── 974.json
│ ├── 982.json
│ ├── 984.json
│ ├── 987.json
│ ├── 989.json
│ ├── 994.json
│ ├── README.md
│ └── template/
│ ├── 940.json
│ ├── 978.json
│ ├── 979-981.json
│ ├── CHANGELOG.md
│ └── issue440.json
├── .editorconfig
├── .gitattributes
├── .github/
│ ├── CODEOWNERS
│ ├── ISSUE_TEMPLATE/
│ │ ├── a_blank_issue.md
│ │ ├── b_issue_report.yml
│ │ ├── config.yml
│ │ └── z_feature_request.yml
│ ├── actions/
│ │ ├── cargo-install-upload-artifacts/
│ │ │ └── action.yml
│ │ ├── cargo-llvm-cov/
│ │ │ └── action.yml
│ │ ├── cargo-publish/
│ │ │ └── action.yml
│ │ ├── post/
│ │ │ ├── action.yml
│ │ │ └── main.js
│ │ └── setup-rust/
│ │ ├── action.yml
│ │ └── rust.json
│ ├── bors.toml
│ ├── codecov.yml
│ ├── dependabot.yml
│ └── workflows/
│ ├── changelog.yml.x
│ ├── ci.yml
│ ├── try.yml
│ └── weekly.yml
├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── ci/
│ ├── build_release.sh
│ ├── shared.sh
│ ├── test-bisect.sh
│ ├── test-cross-image.sh
│ ├── test-docker-in-docker.sh
│ ├── test-foreign-toolchain.sh
│ ├── test-podman.sh
│ ├── test-remote.sh
│ ├── test-zig-image.sh
│ └── test.sh
├── clippy.toml
├── crosstool-ng/
│ ├── arm-unknown-linux-gnueabihf.config.in
│ ├── loongarch64-unknown-linux-gnu.config.in
│ └── loongarch64-unknown-linux-musl.config.in
├── deny.toml
├── docker/
│ ├── .dockerignore
│ ├── .gitattributes
│ ├── Dockerfile.aarch64-linux-android
│ ├── Dockerfile.aarch64-unknown-freebsd
│ ├── Dockerfile.aarch64-unknown-linux-gnu
│ ├── Dockerfile.aarch64-unknown-linux-gnu.centos
│ ├── Dockerfile.aarch64-unknown-linux-musl
│ ├── Dockerfile.aarch64_be-unknown-linux-gnu
│ ├── Dockerfile.arm-linux-androideabi
│ ├── Dockerfile.arm-unknown-linux-gnueabi
│ ├── Dockerfile.arm-unknown-linux-gnueabihf
│ ├── Dockerfile.arm-unknown-linux-musleabi
│ ├── Dockerfile.arm-unknown-linux-musleabihf
│ ├── Dockerfile.armv5te-unknown-linux-gnueabi
│ ├── Dockerfile.armv5te-unknown-linux-musleabi
│ ├── Dockerfile.armv7-linux-androideabi
│ ├── Dockerfile.armv7-unknown-linux-gnueabi
│ ├── Dockerfile.armv7-unknown-linux-gnueabihf
│ ├── Dockerfile.armv7-unknown-linux-musleabi
│ ├── Dockerfile.armv7-unknown-linux-musleabihf
│ ├── Dockerfile.asmjs-unknown-emscripten
│ ├── Dockerfile.cross
│ ├── Dockerfile.i586-unknown-linux-gnu
│ ├── Dockerfile.i586-unknown-linux-musl
│ ├── Dockerfile.i686-linux-android
│ ├── Dockerfile.i686-pc-windows-gnu
│ ├── Dockerfile.i686-unknown-freebsd
│ ├── Dockerfile.i686-unknown-linux-gnu
│ ├── Dockerfile.i686-unknown-linux-musl
│ ├── Dockerfile.loongarch64-unknown-linux-gnu
│ ├── Dockerfile.loongarch64-unknown-linux-musl
│ ├── Dockerfile.mips-unknown-linux-gnu
│ ├── Dockerfile.mips-unknown-linux-musl
│ ├── Dockerfile.mips64-unknown-linux-gnuabi64
│ ├── Dockerfile.mips64-unknown-linux-muslabi64
│ ├── Dockerfile.mips64el-unknown-linux-gnuabi64
│ ├── Dockerfile.mips64el-unknown-linux-muslabi64
│ ├── Dockerfile.mipsel-unknown-linux-gnu
│ ├── Dockerfile.mipsel-unknown-linux-musl
│ ├── Dockerfile.native
│ ├── Dockerfile.native.centos
│ ├── Dockerfile.powerpc-unknown-linux-gnu
│ ├── Dockerfile.powerpc64-unknown-linux-gnu
│ ├── Dockerfile.powerpc64le-unknown-linux-gnu
│ ├── Dockerfile.riscv64gc-unknown-linux-gnu
│ ├── Dockerfile.riscv64gc-unknown-linux-musl
│ ├── Dockerfile.s390x-unknown-linux-gnu
│ ├── Dockerfile.sparc64-unknown-linux-gnu
│ ├── Dockerfile.sparcv9-sun-solaris
│ ├── Dockerfile.thumbv6m-none-eabi
│ ├── Dockerfile.thumbv7em-none-eabi
│ ├── Dockerfile.thumbv7em-none-eabihf
│ ├── Dockerfile.thumbv7m-none-eabi
│ ├── Dockerfile.thumbv7neon-linux-androideabi
│ ├── Dockerfile.thumbv7neon-unknown-linux-gnueabihf
│ ├── Dockerfile.thumbv8m.base-none-eabi
│ ├── Dockerfile.thumbv8m.main-none-eabi
│ ├── Dockerfile.thumbv8m.main-none-eabihf
│ ├── Dockerfile.wasm32-unknown-emscripten
│ ├── Dockerfile.x86_64-linux-android
│ ├── Dockerfile.x86_64-pc-solaris
│ ├── Dockerfile.x86_64-pc-windows-gnu
│ ├── Dockerfile.x86_64-unknown-dragonfly
│ ├── Dockerfile.x86_64-unknown-freebsd
│ ├── Dockerfile.x86_64-unknown-illumos
│ ├── Dockerfile.x86_64-unknown-linux-gnu
│ ├── Dockerfile.x86_64-unknown-linux-gnu.centos
│ ├── Dockerfile.x86_64-unknown-linux-musl
│ ├── Dockerfile.x86_64-unknown-netbsd
│ ├── Dockerfile.zig
│ ├── aarch64-linux-gnu-glibc.sh
│ ├── android/
│ │ ├── README.md
│ │ ├── android/
│ │ │ ├── __init__.py
│ │ │ ├── make.py
│ │ │ ├── soong.py
│ │ │ └── util.py
│ │ ├── pyproject.toml
│ │ ├── scripts/
│ │ │ └── build-system.py
│ │ ├── tests/
│ │ │ ├── Addition.bp
│ │ │ ├── Android.bp
│ │ │ ├── Android.mk
│ │ │ ├── Comments.mk
│ │ │ ├── Empty.bp
│ │ │ ├── Empty.mk
│ │ │ ├── FakeTitle.mk
│ │ │ ├── Grouped.mk
│ │ │ ├── ListMap.bp
│ │ │ ├── Multiline.mk
│ │ │ ├── Nested.mk
│ │ │ ├── NonTest.bp
│ │ │ ├── README.md
│ │ │ ├── Single.mk
│ │ │ ├── test_make.py
│ │ │ ├── test_metadata.py
│ │ │ ├── test_soong.py
│ │ │ └── test_util.py
│ │ └── tox.ini
│ ├── android-ndk.sh
│ ├── android-runner
│ ├── android-symlink.sh
│ ├── android-system.sh
│ ├── android.cmake
│ ├── apt-cross-essential.sh
│ ├── base-runner.sh
│ ├── cmake.sh
│ ├── common.sh
│ ├── cross.sh
│ ├── crosstool-config/
│ │ ├── aarch64_be-unknown-linux-gnu.config
│ │ ├── arm-unknown-linux-gnueabihf.config
│ │ ├── loongarch64-unknown-linux-gnu.config
│ │ ├── loongarch64-unknown-linux-musl.config
│ │ └── riscv64gc-unknown-linux-musl.config
│ ├── crosstool-ng.sh
│ ├── deny-debian-packages.sh
│ ├── dragonfly.sh
│ ├── dropbear.sh
│ ├── emscripten.sh
│ ├── freebsd-common.sh
│ ├── freebsd-extras.sh
│ ├── freebsd-fetch-best-mirror.sh
│ ├── freebsd-gcc.sh
│ ├── freebsd-install-package.sh
│ ├── freebsd-install.sh
│ ├── freebsd-setup-packagesite.sh
│ ├── freebsd.sh
│ ├── illumos.sh
│ ├── lib.sh
│ ├── linux-image.sh
│ ├── linux-runner
│ ├── mingw.sh
│ ├── musl-gcc.sh
│ ├── musl-symlink.sh
│ ├── musl.sh
│ ├── native-linux-image.sh
│ ├── native-linux-runner
│ ├── native-qemu.sh
│ ├── netbsd.sh
│ ├── qemu-runner
│ ├── qemu.sh
│ ├── solaris.sh
│ ├── tidyup.sh
│ ├── toolchain.cmake
│ ├── validate-android-args.sh
│ ├── windows-entry.sh
│ ├── wine.sh
│ └── zig.sh
├── docs/
│ ├── cargo_configuration.md
│ ├── config_file.md
│ ├── custom_images.md
│ ├── environment_variables.md
│ ├── getting-started.md
│ ├── recipes.md
│ ├── remote.md
│ └── unstable_features.md
├── rustfmt.yml
├── src/
│ ├── bin/
│ │ ├── commands/
│ │ │ ├── clean.rs
│ │ │ ├── containers.rs
│ │ │ ├── images.rs
│ │ │ ├── mod.rs
│ │ │ └── run.rs
│ │ ├── cross-util.rs
│ │ └── cross.rs
│ ├── build.rs
│ ├── cargo.rs
│ ├── cli.rs
│ ├── config.rs
│ ├── cross_toml.rs
│ ├── docker/
│ │ ├── build.rs
│ │ ├── custom.rs
│ │ ├── engine.rs
│ │ ├── image.rs
│ │ ├── local.rs
│ │ ├── mod.rs
│ │ ├── provided_images.rs
│ │ ├── remote.rs
│ │ ├── seccomp.json
│ │ └── shared.rs
│ ├── errors.rs
│ ├── extensions.rs
│ ├── file.rs
│ ├── id.rs
│ ├── interpreter.rs
│ ├── lib.rs
│ ├── rustc.rs
│ ├── rustup.rs
│ ├── shell.rs
│ ├── temp.rs
│ ├── tests/
│ │ ├── rustup.rs
│ │ └── toml.rs
│ └── tests.rs
├── targets.toml
└── xtask/
├── Cargo.toml
└── src/
├── build_docker_image.rs
├── changelog.rs
├── ci/
│ └── target_matrix.rs
├── ci.rs
├── codegen.rs
├── crosstool.rs
├── hooks.rs
├── install_git_hooks.rs
├── main.rs
├── pre-commit.sh
├── pre-push.sh
├── target_info.rs
├── target_info.sh
└── util.rs
================================================
FILE CONTENTS
================================================
================================================
FILE: .cargo/config.toml
================================================
[alias]
xtask = ["run", "-p", "xtask", "--"]
build-docker-image = ["xtask", "build-docker-image"]
================================================
FILE: .changes/1006.json
================================================
{
"type": "added",
"description": "add CentOS7-compatible target for aarch64",
"issues": [528]
}
================================================
FILE: .changes/1018.json
================================================
{
"description": "deny installation of armhf debian packages for the arm-unknown-linux-gnueabihf target.",
"type": "fixed"
}
================================================
FILE: .changes/1023.json
================================================
{
"description": "support different Android NDK, API, and Android versions using Docker build args.",
"type": "added"
}
================================================
FILE: .changes/1024.json
================================================
{
"description": "`rust-std` is no longer downloaded when using `build-std = true`",
"type": "fixed",
"breaking": false
}
================================================
FILE: .changes/1028-1132.json
================================================
[
{
"description": "link to libgcc for armv5te-unknown-linux-musleabi.",
"type": "fixed"
},
{
"description": "add C++ support for FreeBSD targets.",
"type": "added"
},
{
"description": "test dynamic library support for Android targets in CI.",
"type": "internal"
},
{
"description": "test partial C++ support for mips64el-unknown-linux-muslabi64 in CI.",
"type": "internal"
},
{
"description": "convert mips64el-unknown-linux-muslabi64 to a hard-float toolchain to match the rust target.",
"type": "changed",
"breaking": true
},
{
"description": "convert mips64el-unknown-linux-muslabi64 to use the mips64r2 architecture, identical to the rust target.",
"type": "changed",
"breaking": true
},
{
"description": "convert mips-unknown-linux-musl and mipsel-unknown-linux-musl to use the mips32r2 architecture, identical to the rust targets.",
"type": "changed",
"breaking": true
}
]
================================================
FILE: .changes/1032.json
================================================
{
"description": "allow disabling buildkit for container engines lacking buildkit support.",
"type": "added"
}
================================================
FILE: .changes/1033.json
================================================
{
"description": "fix --cache-from using podman.",
"type": "fixed",
"issues": [1031]
}
================================================
FILE: .changes/1038-1220-1482.json
================================================
[
{
"description": "bump MSRV to 1.77.2",
"type": "internal"
}
]
================================================
FILE: .changes/1039.json
================================================
{
"description": "support overlay and fuse-overlayfs storage drivers",
"type": "added"
}
================================================
FILE: .changes/1049-1142.json
================================================
{
"type": "changed",
"description": "stop parsing arguments to `cross run` after `--`",
"issues": [1048, 1141]
}
================================================
FILE: .changes/1054.json
================================================
{
"type": "internal",
"description": "change the unique container ID to be unique based off the toolchain and system time."
}
================================================
FILE: .changes/1057.json
================================================
{
"description": "fix mount paths outside of the workspace mount directory on Windows and those provided as a WSL path.",
"type": "fixed",
"issues": [1145, 1156]
}
================================================
FILE: .changes/1063-1125-1134.json
================================================
[
{
"type": "changed",
"description": "changed musl targets to use static-pie linkage by default, consistent with Alpine.",
"breaking": true
},
{
"type": "fixed",
"description": "fixed C++ support for musl targets.",
"issues": [902],
"breaking": true
},
{
"type": "fixed",
"description": "use a linker script for musl libstdc++ to ensure the archive links to libc, libm, and libgcc as needed.",
"issues": [1124]
}
]
================================================
FILE: .changes/1073.json
================================================
{
"type": "added",
"description": "passthrough cross environment variables by default"
}
================================================
FILE: .changes/1078.json
================================================
{
"type": "fixed",
"description": "Fix custom image names for images with a trailing '-' character.\ncustom images in packages with the `^[^0-9-].*([^A-Za-z_]*-)|(-[^A-Za-z_]*)$` package name pattern are now supported.",
"issues": [1077]
}
================================================
FILE: .changes/1084.json
================================================
{
"type": "fixed",
"description": "fixed remote docker data volume paths on windows",
"issues": [1081]
}
================================================
FILE: .changes/1085.json
================================================
{
"type": "added",
"description": "support custom toolchains without rustup."
}
================================================
FILE: .changes/1105.json
================================================
{
"type": "changed",
"description": "explicitly prefer `-ar` to `-gcc-ar`.",
"issues": [1100]
}
================================================
FILE: .changes/1112.json
================================================
[
{
"description": "fixed CMake support for Android and newlib targets.",
"type": "fixed",
"issues": [1110]
},
{
"description": "added C++ support for newlib targets.",
"type": "added"
}
]
================================================
FILE: .changes/1118.json
================================================
{
"type": "added",
"description": "added ARMv8-M newlib targets.",
"issues": [1116]
}
================================================
FILE: .changes/1123.json
================================================
{
"description": "support external C/C++ dependencies using C11/C++11 threads for MinGW targets by switching linkers from `*-gcc` to `*gcc-posix`.",
"type": "added",
"issues": [1122],
"breaking": true
}
================================================
FILE: .changes/1138.json
================================================
{
"description": "explicitly specify ar for all toolchains",
"type": "changed",
"issues": [1137]
}
================================================
FILE: .changes/1159.json
================================================
{
"type": "changed",
"description": "use `[workspace.metadata.cross]` as an alternative to `Cross.toml`"
}
================================================
FILE: .changes/1160.json
================================================
{
"type": "changed",
"description": "don't warn when toolchain version is explicitly provided.",
"issues": [1148]
}
================================================
FILE: .changes/1164.json
================================================
{
"type": "internal",
"description": "add fallback mirrors for FreeBSD packages.",
"issues": [1162]
}
================================================
FILE: .changes/1166.json
================================================
{
"description": "freebsd: include memstat in build image to fix build with libc 0.2.138 and up.",
"type": "fixed"
}
================================================
FILE: .changes/1183.json
================================================
{
"description": "resolve issue when using `pre-build` and `image.toolchain` in `Cargo.toml`",
"type": "fixed",
"issues": [1182]
}
================================================
FILE: .changes/1199.json
================================================
{
"type": "fixed",
"description": "use current target_dir path when copying build artifacts back",
"issues": [1103]
}
================================================
FILE: .changes/1207.json
================================================
{
"type": "fixed",
"description": "properly copy directories when using `CROSS_REMOTE`",
"issues": [1206]
}
================================================
FILE: .changes/1220.json
================================================
{
"type": "fixed",
"description": "don't pass `--target-dir` in remote context when it's not needed",
"issues": [1218]
}
================================================
FILE: .changes/1246.json
================================================
{
"description": "fix support for bare metal targets other than thumb",
"type": "fixed"
}
================================================
FILE: .changes/1248.json
================================================
{
"description": "customize `--cache-from` and `--cache-to` options for `build-docker-image`",
"type": "internal"
}
================================================
FILE: .changes/1260.json
================================================
{
"description": "fix podman bind mounts on macOS by removing SELinux labels.",
"issues": [756],
"type": "fixed",
"breaking": false
}
================================================
FILE: .changes/1265.json
================================================
{
"description": "replace `ctrlc` signal handler with `signal-hook`",
"type": "changed"
}
================================================
FILE: .changes/1271.json
================================================
{
"description": "add aarch64-unknown-freebsd image.",
"type": "added",
"breaking": false
}
================================================
FILE: .changes/1280.json
================================================
{
"description": "Allow to run arbitrary commands in containers using `cross-util run ...`",
"issues": [1266],
"type": "added",
"breaking": false
}
================================================
FILE: .changes/1317.json
================================================
{
"description": "Re-add PKG_CONFIG_PATH for the arm-unknown-linux-gnueabihf target.",
"issues": [1316],
"type": "fixed",
"breaking": false
}
================================================
FILE: .changes/1325.json
================================================
{
"description": "create CACHEDIR.TAG during custom docker build",
"type": "fixed",
"issues": [1324]
}
================================================
FILE: .changes/1330-1349.json
================================================
{
"description": "update cargo-zigbuild from 0.17.2 to 0.17.3",
"type": "changed"
}
================================================
FILE: .changes/1333.json
================================================
{
"description": "set arm-unknown-linux-gnueabihf to use glibc 2.31",
"type": "changed"
}
================================================
FILE: .changes/1340.json
================================================
{
"description": "don't error when a non-provided target is used with only a dockerfile specified",
"type": "fixed"
}
================================================
FILE: .changes/1342.json
================================================
[
{
"description": "fix `--list` showing cross commands for the host",
"type": "fixed"
},
{
"description": "add `rustdoc` as a supported cargo subcommand",
"type": "added"
}
]
================================================
FILE: .changes/1346.json
================================================
{
"description": "bump musl to 1.2.3, like done in rust 1.71",
"type": "changed"
}
================================================
FILE: .changes/1348.json
================================================
{
"description": "add `libexecinfo.so` in netbsd",
"type": "added"
}
================================================
FILE: .changes/1373.json
================================================
{
"type": "fixed",
"description": "fix wineboot silently failing on qemu",
"issues": [1372]
}
================================================
FILE: .changes/1374-1490.json
================================================
{
"type": "changed",
"description": "update wine to 9.0.0.0",
"issues": [1372]
}
================================================
FILE: .changes/1385.json
================================================
{
"description": "Set PKG_CONFIG_PATH in the FreeBSD Dockerfile.",
"issues": [1384],
"type": "fixed"
}
================================================
FILE: .changes/1391.json
================================================
{
"type": "fixed",
"description": "Add `-idirafter/usr/include` to bindgen's clang invocation on GNU/Linux",
"issues": [1389]
}
================================================
FILE: .changes/1399.json
================================================
{
"description": "fix creating `initrd` when using debian `ports` mirror and compressed kernel modules",
"issues": [1399],
"type": "fixed"
}
================================================
FILE: .changes/1403-1411.json
================================================
[{
"type": "fixed",
"description": "switch to freebsd 13.2 following 12.4 EoL",
"issues": [1390]
},
{
"type": "added",
"description": "Added helper script `/freebsd-install-package.sh` and friends to install freebsd packages, see [wiki](https://github.com/cross-rs/cross/wiki/FAQ#custom-images)"
}]
================================================
FILE: .changes/1420.json
================================================
{
"description": "set the required environment variables in the runner",
"type": "fixed"
}
================================================
FILE: .changes/1458.json
================================================
{
"description": "add gfortran for target *-gnu*, *-musl*, *-freebsd*, *-solaris*, *-dragonfly*, *-illumos*, *-netbsd*",
"issues": [1457],
"type": "added"
}
================================================
FILE: .changes/1465.json
================================================
{
"type": "added",
"description": "add loongarch64 support",
"issues": [1404]
}
================================================
FILE: .changes/1466.json
================================================
{
"type": "added",
"description": "Upgrade qemu and integrate qemu-user runners for loongarch64-linux-gnu",
"issues": [1467]
}
================================================
FILE: .changes/1468.json
================================================
{
"type": "changed",
"description": "use defconfig for ct-ng, minimizing the config",
"issues": [1335]
}
================================================
FILE: .changes/1481.json
================================================
{
"description": "allow pass-through environment variables to contain numbers",
"type": "fixed"
}
================================================
FILE: .changes/1483.json
================================================
{
"description": "Fix paths when using `CROSS_CONTAINER_IN_CONTAINER`",
"type": "fixed"
}
================================================
FILE: .changes/1485.json
================================================
{
"description": "Use `/proc/self/mountinfo` as a fallback for `docker inspect` if using `HOSTNAME` fails",
"issues": [1321],
"type": "changed"
}
================================================
FILE: .changes/1488.json
================================================
{
"description": "Allow `build-std` to take an array of crate names",
"issues": [896],
"type": "changed",
"breaking": true
}
================================================
FILE: .changes/1489.json
================================================
{
"description": "Simplify config internals",
"type": "internal"
}
================================================
FILE: .changes/1491.json
================================================
{
"description": "Allow specifying only a tag or subtarget for images in config",
"issues": [1169],
"type": "changed"
}
================================================
FILE: .changes/1494.json
================================================
{
"description": "Fix `zig.image` precedence",
"type": "fixed",
"breaking": true
}
================================================
FILE: .changes/1495.json
================================================
{
"description": "Fix `*-solaris` targets",
"issues": [1424],
"type": "fixed",
"breaking": true
}
================================================
FILE: .changes/1525.json
================================================
{
"description": "Fix riscv64gc-unknown-linux-gnu target",
"issues": [1423],
"type": "fixed"
}
================================================
FILE: .changes/1540.json
================================================
{
"description": "Upgrade the crosstool for the loongarch64-unknown-linux-gnu target",
"issues": [1538],
"type": "fixed"
}
================================================
FILE: .changes/1557.json
================================================
{
"type": "added",
"description": "add loongarch64-linux-musl support",
"issues": [1556]
}
================================================
FILE: .changes/1574.json
================================================
{
"type": "fixed",
"description": "`dockerfile` path is now relative to cargo workspace root"
}
================================================
FILE: .changes/1623.json
================================================
{
"type": "fixed",
"description": "fixed an issue where cross would look for metadata.cross outside the workspace"
}
================================================
FILE: .changes/1625.json
================================================
{
"description": "bump ct-ng to 1.27.0",
"type": "changed"
}
================================================
FILE: .changes/1630.json
================================================
{
"type": "added",
"description": "Add docker platform support for `linux/arm64/v8` target for many Ubuntu-based targets"
}
================================================
FILE: .changes/1641.json
================================================
{
"description": "Update binutils to 2.38 in illumos and solaris",
"issues": [1639],
"type": "changed"
}
================================================
FILE: .changes/1647.json
================================================
{
"description": "use `-q` when gathering the installed toolchains",
"issues": [1645],
"type": "fixed"
}
================================================
FILE: .changes/1651.json
================================================
{
"description": "Fix BINDGEN_EXTRA_CLANG_ARGS for x86_64-unknown-illumos",
"issues": [1644],
"type": "fixed",
"breaking": false
}
================================================
FILE: .changes/1664.json
================================================
{
"type": "added",
"description": "add riscv64gc-unknown-linux-musl support",
"issues": [1197]
}
================================================
FILE: .changes/1674.json
================================================
{
"type": "fixed",
"description": "use zstd to extract the compressed file as FreeBSD do so. also, bump the gcc version"
}
================================================
FILE: .changes/1681.json
================================================
{
"description": "also recognize active and default as installed toolchains",
"issues": [1645, 1678],
"type": "fixed"
}
================================================
FILE: .changes/554.json
================================================
{
"type": "fixed",
"description": "add the `--force-non-host` flag for newer rustup versions",
"issues": [536]
}
================================================
FILE: .changes/589.json
================================================
{
"type": "fixed",
"description": "Ensure podman builds use non-interactive package installs.",
"issues": [589]
}
================================================
FILE: .changes/591-1095.json
================================================
[
{
"description": "update Ubuntu images to 20.04 LTS.",
"type": "changed",
"breaking": true,
"issues": [417, 517, 556, 616]
},
{
"description": "remove Linux image from `mips-unknown-linux-gnu`.",
"type": "removed",
"breaking": true
},
{
"type": "changed",
"description": "upgraded most linux images to use a 5.x kernel instead of a 4.x kernel.",
"breaking": true
},
{
"type": "changed",
"description": "updated powerpc64, riscv64, and sparc64 `*-linux-gnu` images to use a 6.x kernel instead of a 4.x kernel.",
"breaking": true,
"issues": [1094]
}
]
================================================
FILE: .changes/661.json
================================================
{
"description": "When cross has given a warning, it will now quit instead of continuing with `cargo` when run in CI or with `CROSS_NO_WARNINGS=1`",
"breaking": true,
"type": "changed"
}
================================================
FILE: .changes/817.json
================================================
[
{
"description": "Images can now specify a certain toolchain via `target.{target}.image.toolchain`",
"breaking": true,
"type": "added"
},
{
"description": "made `cross +channel` parsing more compliant to parsing a toolchain",
"type": "fixed"
},
{
"description": "`pre-build` and `dockerfile` now uses buildx/buildkit",
"breaking": true,
"type": "changed"
}
]
================================================
FILE: .changes/880-1111.json
================================================
{
"description": "added a zig-based image (v0.10.0), allowing multiple targets to be built from the same image, using cargo-zigbuild (v0.14.1).",
"type": "added",
"issues": [860, 1109]
}
================================================
FILE: .changes/918.json
================================================
{
"description": "use JSON-based files to autogenerate CHANGELOG.md",
"issues": [662],
"type": "internal"
}
================================================
FILE: .changes/931.json
================================================
{
"description": "deny installation of debian packages that conflict with our cross-compiler toolchains.",
"type": "fixed"
}
================================================
FILE: .changes/934.json
================================================
{
"type": "added",
"description": "add support for pre-build hooks with remote docker",
"issues": [928]
}
================================================
FILE: .changes/937.json
================================================
{
"type": "fixed",
"description": "support Windows-style and absolute manifest paths",
"issues": [935]
}
================================================
FILE: .changes/939.json
================================================
{
"type": "changed",
"description": "Remove `/project` mounting, instead always mount in the same path as on the host",
"issues": [938]
}
================================================
FILE: .changes/942.json
================================================
[
{
"description": "use non-canonical paths for mount locations.",
"type": "changed",
"issues": [920]
},
{
"description": "fixed DeviceNS drive parsing in creating WSL-style paths on windows.",
"type": "fixed"
},
{
"description": "fixed the environment variable name for mounted volumes.",
"type": "fixed"
}
]
================================================
FILE: .changes/945.json
================================================
{
"type": "fixed",
"description": "fix pre-build hook image naming with podman",
"issues": [944]
}
================================================
FILE: .changes/947.json
================================================
[
{
"type": "internal",
"description": "resolve symlinks to cargo and xargo home before mounting",
"issues": [373]
},
{
"type": "fixed",
"description": "mount cargo, xargo, and the sysroot at the same path as on the host to avoid unnecessary recompilation.",
"issues": [551]
}
]
================================================
FILE: .changes/952.json
================================================
{
"description": "run non-x86 binaries natively if on a compatible host.",
"type": "added"
}
================================================
FILE: .changes/955.json
================================================
{
"description": "Update QEMU to version 7.0.0 for Ubuntu targets",
"type": "changed",
"breaking": false
}
================================================
FILE: .changes/956.json
================================================
{
"description": "use Wine from Ubuntu 20.04 WineHQ repo",
"type": "changed",
"breaking": false
}
================================================
FILE: .changes/957-1393.json
================================================
{
"description": "use latest Debian kernel images",
"type": "changed",
"breaking": false
}
================================================
FILE: .changes/962.json
================================================
{
"description": "fix SELinux labels to allow use in multiple containers and/or the host filesystem.",
"type": "fixed",
"issues": [961]
}
================================================
FILE: .changes/964.json
================================================
{
"type": "fixed",
"description": "don't keep stdin open when running containers."
}
================================================
FILE: .changes/968.json
================================================
{
"description": "only print rustup --verbose if `-vv` or `CROSS_VERBOSE=1` is used",
"type": "fixed"
}
================================================
FILE: .changes/974.json
================================================
[
{
"description": "change `mips64-unknown-linux-muslabi64` target to hard-float target.",
"type": "fixed",
"issues": [906]
},
{
"description": "build static libgcc and link to static libgcc for `mips64-unknown-linux-muslabi64` target.",
"type": "fixed"
}
]
================================================
FILE: .changes/982.json
================================================
{
"type": "internal",
"description": "use generic dockerfiles for when the toolchain and image platfom match."
}
================================================
FILE: .changes/984.json
================================================
{
"description": "added linux images for `riscv64gc-unknown-linux-gnu` to allow full system emulation.",
"type": "added"
}
================================================
FILE: .changes/987.json
================================================
{
"type": "fixed",
"description": "link to libgcc for `armv5te-unknown-linux-musleabi` to fix missing `__sync_X_and_fetch` builtins.",
"issues": [367]
}
================================================
FILE: .changes/989.json
================================================
{
"type": "changed",
"description": "add default nix_store value to solve nix-related issues",
"issues": [260]
}
================================================
FILE: .changes/994.json
================================================
{
"type": "fixed",
"description": "fixed wrong path used for target when pre-building in container in container mode",
"issues": [993]
}
================================================
FILE: .changes/README.md
================================================
# Changes
This stores changes to automatically generate the changelog, to avoid merge conflicts. Files should be in a JSON format, with the following format:
```json
{
"description": "single-line description to add to the CHANGELOG.",
"issues": [894],
"type": "added",
"breaking": false
}
```
Valid types are:
- added (Added)
- changed (Changed)
- fixed (Fixed)
- removed (Removed)
- internal (Internal)
`breaking` is optional and defaults to false. if `breaking` is present for any active changes, a `BREAKING:` notice will be added at the start of the entry. `issues` is also optional, and is currently unused, and is an array of issues fixed by the PR, and defaults to an empty array.
The file numbers should be `${pr}.json`. The `pr` is optional, and if not, an issue number should be used, in the `_${issue}.json` format. We also support multiple PRs per entry, using the `${pr1}-${pr2}-(...).json` format.
If multiple changes are made in a single PR, you can also pass an array of entries:
```json
[
{
"description": "this is one added entry.",
"issues": [630],
"type": "added"
},
{
"description": "this is another added entry.",
"issues": [642],
"type": "added"
},
{
"description": "this is a fixed entry that has no attached issue.",
"type": "fixed"
}
]
```
See [template](/.changes/template) for sample object and array-based changes.
================================================
FILE: .changes/template/940.json
================================================
[
{
"description": "this is one added entry.",
"issues": [630],
"type": "added"
},
{
"description": "this is another added entry.",
"issues": [642],
"type": "added"
},
{
"description": "this is a fixed entry that has no attached issue.",
"type": "fixed"
},
{
"description": "this is a breaking change.",
"issues": [679],
"breaking": true,
"type": "changed"
}
]
================================================
FILE: .changes/template/978.json
================================================
{
"description": "sample description for a PR adding one CHANGELOG entry.",
"issues": [437],
"type": "fixed"
}
================================================
FILE: .changes/template/979-981.json
================================================
{
"description": "this has 2 PRs associated.",
"issues": [441],
"type": "added"
}
================================================
FILE: .changes/template/CHANGELOG.md
================================================
# Change Log
This is a template changelog. This represents an older state of this repository, used to test parsing/formatting.
## [Unreleased] - ReleaseDate
### Added
- #905 - added `qemu-runner` for musl images, allowing use of native or emulated runners.
- #905 - added qemu emulation to `i586-unknown-linux-gnu`, `i686-unknown-linux-musl`, and `i586-unknown-linux-gnu`, so they can run on an `x86` CPU, rather than an `x86_64` CPU.
- #900 - add the option to skip copying build artifacts back to host when using remote cross via `CROSS_REMOTE_SKIP_BUILD_ARTIFACTS`.
- #891 - support custom user namespace overrides by setting the `CROSS_CONTAINER_USER_NAMESPACE` environment variable.
- #890 - support rootless docker via the `CROSS_ROOTLESS_CONTAINER_ENGINE` environment variable.
- #878 - added an image `ghcr.io/cross-rs/cross` containing cross.
### Changed
- #869 - ensure cargo configuration environment variable flags are passed to the docker container.
- #859 - added color diagnostic output and error messages.
### Fixed
- #905 - fixed running dynamically-linked libraries for all musl targets except `x86_64-unknown-linux-musl`.
- #904 - ensure `cargo metadata` works by using the same channel.
- #904 - fixed the path for workspace volumes and passthrough volumes with docker-in-docker.
- #898 - fix the path to the mount root with docker-in-docker if mounting volumes.
- #897 - ensure `target.$(...)` config options override `build` ones when parsing strings and vecs.
- #895 - convert filenames in docker tags to ASCII lowercase and ignore invalid characters
- #885 - handle symlinks when using remote docker.
- #868 - ignore the `CARGO` environment variable.
- #867 - fixed parsing of `build.env.passthrough` config values.
## [v0.2.2] - 2022-06-24
### Added
- #803 - added `CROSS_CUSTOM_TOOLCHAIN` to disable automatic installation of components for use with tools like `cargo-bisect-rustc`
- #795 - added images for additional toolchains maintained by cross-rs.
- #792 - added `CROSS_CONTAINER_IN_CONTAINER` environment variable to replace `CROSS_DOCKER_IN_DOCKER`.
- #785 - added support for remote container engines through data volumes through setting the `CROSS_REMOTE` environment variable. also adds in utility commands to create and remove persistent data volumes.
- #782 - added `build-std` config option, which builds the rust standard library from source if enabled.
- #678 - Add optional `target.{target}.dockerfile[.file]`, `target.{target}.dockerfile.context` and `target.{target}.dockerfile.build-args` to invoke docker/podman build before using an image.
- #678 - Add `target.{target}.pre-build` config for running commands before building the image.
- #772 - added `CROSS_CONTAINER_OPTS` environment variable to replace `DOCKER_OPTS`.
- #767, #788 - added the `cross-util` and `xtask` commands.
- #842 - Add `Cargo.toml` as configuration source
- #745 - added `thumbv7neon-*` targets.
- #741 - added `armv7-unknown-linux-gnueabi` and `armv7-unknown-linux-musleabi` targets.
- #721 - add support for running doctests on nightly if `CROSS_UNSTABLE_ENABLE_DOCTESTS=true`.
- #719 - add `--list` to known subcommands.
- #681 - Warn on unknown fields and confusable targets
- #624 - Add `build.default-target`
- #647 - Add `mips64-unknown-linux-muslabi64` and `mips64el-unknown-linux-muslabi64` support
- #543 - Added environment variables to control the UID and GID in the container
- #524 - docker: Add Nix Store volume support
- Added support for mounting volumes.
- #684 - Enable cargo workspaces to work from any path in the workspace, and make path dependencies mount seamlessly. Also added support for private SSH dependencies.
### Changed
- #838 - re-enabled the solaris targets.
- #807 - update Qemu to 6.1.0 on images using Ubuntu 18.04+ with python3.6+.
- #775 - forward Cargo exit code to host
- #762 - re-enabled `x86_64-unknown-dragonfly` target.
- #747 - reduced android image sizes.
- #746 - limit image permissions for android images.
- #377 - update WINE versions to 7.0.
- #734 - patch `arm-unknown-linux-gnueabihf` to build for ARMv6, and add architecture for crosstool-ng-based images.
- #709 - Update Emscripten targets to `emcc` version 3.1.10
- #707, #708 - Set `BINDGEN_EXTRA_CLANG_ARGS` environment variable to pass sysroot to `rust-bindgen`
- #696 - bump freebsd to 12.3
- #629 - Update Android NDK version and API version
- #497 - don't set RUSTFLAGS in aarch64-musl image
- #492 - Add cmake to FreeBSD images
- #748 - allow definitions in the environment variable passthrough
### Fixed
- #836 - write a `CACHEDIR.TAG` when creating the target directory, similar to `cargo`.
- #804 - allow usage of env `CARGO_BUILD_TARGET` as an alias for `CROSS_BUILD_TARGET`
- #792 - fixed container-in-container support when using podman.
- #781 - ensure `target.$(...)` config options override `build` ones.
- #771 - fix parsing of `DOCKER_OPTS`.
- #727 - add `PKG_CONFIG_PATH` to all `*-linux-gnu` images.
- #722 - boolean environment variables are evaluated as truthy or falsey.
- #720 - add android runner to preload `libc++_shared.so`.
- #725 - support `CROSS_DEBUG` and `CROSS_RUNNER` on android images.
- #714 - use host target directory when falling back to host cargo.
- #713 - convert relative target directories to absolute paths.
- #501 (reverted, see #764) - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
- #500 - use runner setting specified in Cross.toml
- #498 - bump linux-image version to fix CI
- Re-enabled `powerpc64-unknown-linux-gnu` image
- Re-enabled `sparc64-unknown-linux-gnu` image
- #582 - Added `libprocstat.so` to FreeBSD images
- #665 - when not using [env.volumes](https://github.com/cross-rs/cross#mounting-volumes-into-the-build-environment), mount project in /project
- #494 - Parse Cargo's --manifest-path option to determine mounted docker root
### Removed
- #718 - remove deb subcommand.
### Internal
- #856 - remove use of external wslpath and create internal helper that properly handles UNC paths.
- #828 - assume paths are Unicode and provide better error messages for path encoding errors.
- #787 - add installer for git hooks.
- #786, #791 - Migrate build script to rust: `cargo build-docker-image $TARGET`
- #730 - make FreeBSD builds more resilient.
- #670 - Use serde for deserialization of Cross.toml
- Change rust edition to 2021 and bump MSRV for the cross binary to 1.58.1
- #654 - Use color-eyre for error reporting
- #658 - Upgrade dependencies
- #652 - Allow trying individual targets via bors.
- #650 - Improve Docker caching.
- #609 - Switch to Github Actions and GHCR.
- #588 - fix ci: bump openssl version in freebsd again
- #552 - Added CHANGELOG.md automation
- #534 - fix image builds with update of dependencies
- #502 - fix ci: bump openssl version in freebsd
- #489 - Add support for more hosts and simplify/unify host support checks
- #477 - Fix Docker/Podman links in README
- #476 - Use Rustlang mirror for Sabotage linux tarballs
- Bump nix dependency to `0.22.1`
- Bump musl version to 1.1.24.
## [v0.2.1] - 2020-06-30
- Disabled `powerpc64-unknown-linux-gnu` image.
- Disabled `sparc64-unknown-linux-gnu` image.
- Disabled `x86_64-unknown-dragonfly` image.
- Removed CI testing for `i686-apple-darwin`.
## [v0.2.0] - 2020-02-22
- Removed OpenSSL from all images.
- Added support for Podman.
- Bumped all images to at least Ubuntu 16.04.
## [v0.1.16] - 2019-09-17
- Bump OpenSSL version to 1.0.2t.
- Re-enabled `asmjs-unknown-emscripten` target.
- Default to `native` runner instead of `qemu-user` for certain targets.
## [v0.1.15] - 2019-09-04
- Images are now hosted at https://hub.docker.com/r/rustembedded/cross.
- Bump OpenSSL version to 1.0.2p.
- Bump musl version to 1.1.20.
- Bump Ubuntu to 18.04 to all musl targets.
- Bump gcc version to 6.3.0 for all musl targets.
- OpenSSL support for the `arm-unknown-linux-musleabi` target.
- OpenSSL support for the `armv7-unknown-linux-musleabihf` target.
- Build and test support for `aarch64-unknown-linux-musl`, `arm-unknown-linux-musleabihf`,
`armv5te-unknown-linux-musleabi`, `i586-unknown-linux-musl`, `mips-unknown-linux-musl`,
add `mipsel-unknown-linux-musl` targets.
## [v0.1.14] - 2017-11-22
### Added
- Support for the `i586-unknown-linux-gnu` target.
### Changed
- Downgraded the Solaris toolchains from 2.11 to 2.10 to make the binaries produced by Cross more
compatible (this version matches what rust-lang/rust is using).
## [v0.1.13] - 2017-11-08
### Added
- Support for the custom [`deb`] subcommand.
[`deb`]: https://github.com/mmstick/cargo-deb
- Partial `test` / `run` support for android targets. Using the android API via `cross run` / `cross test` is _not_ supported because Cross is using QEMU instead of the official Android emulator.
- Partial support for the `sparcv9-sun-solaris` and `x86_64-sun-solaris` targets. `cross test` and
`cross run` doesn't work for these new targets.
- OpenSSL support for the `i686-unknown-linux-musl` target.
### Changed
- Bump OpenSSL version to 1.0.2m.
## [v0.1.12] - 2017-09-22
### Added
- Support for `cross check`. This subcommand won't use any Docker container.
### Changed
- `binfmt_misc` is not required on the host for toolchain v1.19.0 and newer.
With these toolchains `binfmt_misc` interpreters don't need to be installed
on the host saving a _privileged_ docker run which some systems don't allow.
## [v0.1.11] - 2017-06-10
### Added
- Build and test support for `i686-pc-windows-gnu`, `x86_64-pc-windows-gnu`,
`asmjs-unknown-emscripten` and `wasm-unknown-emscripten`.
- Build support for `aarch64-linux-android`, `arm-linux-androideabi`,
`armv7-linux-androideabi`, `x86_64-linux-android` and `i686-linux-android`
- A `build.env.passthrough` / `build.target.*.passthrough` option to Cross.toml
to support passing environment variables from the host to the Docker image.
### Changed
- Bumped OpenSSL version to 1.0.2k
- Bumped QEMU version to 2.9.0
## [v0.1.10] - 2017-04-02
### Added
- Cross compilation support for `x86_64-pc-windows-gnu`
- Cross compilation support for Android targets
### Changed
- Bumped OpenSSL version to 1.0.2k
## [v0.1.9] - 2017-02-08
### Added
- Support for ARM MUSL targets.
### Changed
- The automatic lockfile update that happens every time `cross` is invoked
should no longer hit the network when there's no git dependency to add/update.
- The QEMU_STRACE variable is passed to the underlying Docker container. Paired
with `cross run`, this lets you get a trace of system call from the execution
of "foreign" (non x86_64) binaries.
## [v0.1.8] - 2017-01-21
### Added
- Support for custom targets. Cross will now also try to use a docker image for
them. As with the built-in targets, one can override the image using
`[target.{}.image]` in Cross.toml.
### Changed
- Moved to a newer Xargo: v0.3.5
## [v0.1.7] - 2017-01-19
### Changed
- Moved to a newer Xargo: v0.3.4
### Fixed
- QEMU interpreters were being register when not required, e.g. for the
`x86_64-unknown-linux-gnu` target.
## [v0.1.6] - 2017-01-14
### Fixed
- Stable releases were picking the wrong image (wrong tag: 0.1.5 instead of
v0.1.5)
## [v0.1.5] - 2017-01-14 [YANKED]
### Added
- `cross run` support for the thumb targets.
- A `build.xargo` / `target.$TARGET.xargo` option to Cross.toml to use Xargo
instead of Cargo.
- A `target.$TARGET.image` option to override the Docker image used for
`$TARGET`.
- A `sparc64-unknown-linux-gnu` environment.
- A `x86_64-unknown-dragonfly` environment.
### Changed
- Building older versions (<0.7.0) of the `openssl` crate is now supported.
- Before Docker is invoked, `cross` will _always_ (re)generate the lockfile to
avoid errors later on due to read/write permissions. This removes the need to
call `cargo generate-lockfile` before `cross` in _all_ cases.
## [v0.1.4] - 2017-01-07
### Added
- Support for the `arm-unknown-linux-gnueabi` target
- `cross build` support for:
- `i686-unknown-freebsd`
- `x86_64-unknown-freebsd`
- `x86_64-unknown-netbsd`
### Changed
- It's no longer necessary to call `cargo generate-lockfile` before using
`cross` as `cross` will now take care of creating a lockfile when necessary.
- The C environments for the `thumb` targets now include newlib (`libc.a`,
`libm.a`, etc.)
### Fixed
- A segfault when `cross` was trying to figure out the name of the user that
called it.
## [v0.1.3] - 2017-01-01
### Changed
- Fix the `i686-unknown-linux-musl` target
## [v0.1.2] - 2016-12-31
### Added
- Support for `i686-unknown-linux-musl`
- Support for `cross build`ing crates for the `thumbv*-none-eabi*` targets.
## [v0.1.1] - 2016-12-28
### Added
- Support for `x86_64-unknown-linux-musl`
- Print shell commands when the verbose flag is used.
- Support crossing from x86_64 osx to i686 osx
## v0.1.0 - 2016-12-26
- Initial release. Supports 12 targets.
[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.2...HEAD
[v0.2.2]: https://github.com/cross-rs/cross/compare/v0.2.1...v0.2.2
[v0.2.1]: https://github.com/cross-rs/cross/compare/v0.2.0...v0.2.1
[v0.2.0]: https://github.com/cross-rs/cross/compare/v0.1.16...v0.2.0
[v0.1.16]: https://github.com/cross-rs/cross/compare/v0.1.15...v0.1.16
[v0.1.15]: https://github.com/cross-rs/cross/compare/v0.1.14...v0.1.15
[v0.1.14]: https://github.com/cross-rs/cross/compare/v0.1.13...v0.1.14
[v0.1.13]: https://github.com/cross-rs/cross/compare/v0.1.12...v0.1.13
[v0.1.12]: https://github.com/cross-rs/cross/compare/v0.1.11...v0.1.12
[v0.1.11]: https://github.com/cross-rs/cross/compare/v0.1.10...v0.1.11
[v0.1.10]: https://github.com/cross-rs/cross/compare/v0.1.9...v0.1.10
[v0.1.9]: https://github.com/cross-rs/cross/compare/v0.1.8...v0.1.9
[v0.1.8]: https://github.com/cross-rs/cross/compare/v0.1.7...v0.1.8
[v0.1.7]: https://github.com/cross-rs/cross/compare/v0.1.6...v0.1.7
[v0.1.6]: https://github.com/cross-rs/cross/compare/v0.1.5...v0.1.6
[v0.1.5]: https://github.com/cross-rs/cross/compare/v0.1.4...v0.1.5
[v0.1.4]: https://github.com/cross-rs/cross/compare/v0.1.3...v0.1.4
[v0.1.3]: https://github.com/cross-rs/cross/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/cross-rs/cross/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/cross-rs/cross/compare/v0.1.0...v0.1.1
================================================
FILE: .changes/template/issue440.json
================================================
{
"description": "no associated PR.",
"issues": [440],
"type": "fixed"
}
================================================
FILE: .editorconfig
================================================
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.{rs,py,sh,md,toml,yml,js}]
charset = utf-8
[*.{rs,py,sh,yml,js}]
trim_trailing_whitespace = true
[*.{rs,py,sh}]
indent_style = space
indent_size = 4
[*.yml]
indent_style = space
indent_size = 2
[Dockerfile.*]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
================================================
FILE: .gitattributes
================================================
* text=auto
Dockerfile.* linguist-language=Dockerfile eol=lf
================================================
FILE: .github/CODEOWNERS
================================================
* @cross-rs/maintainers
================================================
FILE: .github/ISSUE_TEMPLATE/a_blank_issue.md
================================================
---
name: Blank Issue
about: Create a blank issue.
---
================================================
FILE: .github/ISSUE_TEMPLATE/b_issue_report.yml
================================================
name: Issue report
description: Report something that is broken, missing or wrong.
body:
- type: checkboxes
id: acknowledgments
attributes:
label: Checklist
options:
- label: I've looked through the [issues and pull requests](https://github.com/cross-rs/cross/issues?q=) for similar reports
required: true
- type: textarea
id: description
validations:
required: true
attributes:
label: Describe your issue
description: |
Write a description of your issue. Include error messages if there are any.
placeholder: |
Examples:
- cross no longer compiles my project after upgrade.
- I have trouble doing X.
- Feature X has stopped working for me.
- type: dropdown
id: target
attributes:
label: What target(s) are you cross-compiling for?
description: You may select more than one or none if this is not applicable (N/A).
multiple: true
options:
- aarch64-linux-android
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- aarch64-unknown-freebsd
- arm-linux-androideabi
- arm-unknown-linux-gnueabi
- arm-unknown-linux-gnueabihf
- arm-unknown-linux-musleabi
- arm-unknown-linux-musleabihf
- armv5te-unknown-linux-gnueabi
- armv5te-unknown-linux-musleabi
- armv7-linux-androideabi
- armv7-unknown-linux-gnueabihf
- armv7-unknown-linux-musleabihf
- asmjs-unknown-emscripten
- i586-unknown-linux-gnu
- i586-unknown-linux-musl
- i686-linux-android
- i686-pc-windows-gnu
- i686-unknown-freebsd
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- loongarch64-unknown-linux-gnu
- loongarch64-unknown-linux-musl
- mips64el-unknown-linux-gnuabi64
- mips64el-unknown-linux-muslabi64
- mips64-unknown-linux-gnuabi64
- mips64-unknown-linux-muslabi64
- mipsel-unknown-linux-gnu
- mipsel-unknown-linux-musl
- mips-unknown-linux-gnu
- mips-unknown-linux-musl
- powerpc64le-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- powerpc-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
- riscv64gc-unknown-linux-musl
- s390x-unknown-linux-gnu
- sparc64-unknown-linux-gnu
- sparcv9-sun-solaris
- thumbv6m-none-eabi
- thumbv7em-none-eabi
- thumbv7em-none-eabihf
- thumbv7m-none-eabi
- wasm32-unknown-emscripten
- x86_64-linux-android
- x86_64-pc-windows-gnu
- x86_64-pc-solaris
- x86_64-unknown-freebsd
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-unknown-netbsd
- other (specify in description)
- type: checkboxes
id: host-system
attributes:
label: Which operating system is the host (e.g computer cross is on) running?
description: You may select more than one or none if N/A.
options:
- label: macOS
- label: Windows
- label: Linux / BSD
- label: other OS (specify in description)
- type: checkboxes
id: host-arch
attributes:
label: What architecture is the host?
description: You may select more than one or none if N/A.
options:
- label: x86_64 / AMD64
- label: arm32
- label: arm64 (including Mac M1)
- type: checkboxes
id: container-engine
attributes:
label: What container engine is cross using?
description: You may select more than one or none if N/A.
options:
- label: docker
- label: podman
- label: other container engine (specify in description)
- type: input
id: cross-version
validations:
required: true
attributes:
label: cross version
description: The version of cross given with `cross -V` or `cross --version`
placeholder: cross 0.4.2 (c8df353 2025-01-01)
- type: textarea
id: mcve
attributes:
label: Example
description: Please provide a short, complete example of the issue if possible.
placeholder: |
```sh
git clone https://github.com/ghost/my_mcve
cross build --target x86_65-unknown-linux-gnu
```
Gives the error message `could not discover target specification`
- type: textarea
id: additional
attributes:
label: Additional information / notes
description: Provide any information you think is relevant to the issue
placeholder: It builds on `asmjs-unknown-emscripten`
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: true
contact_links:
- name: Question?
url: https://matrix.to/#/#cross-rs:matrix.org
about: Reach out to us on our Matrix room if you want!
- name: Question!
url: https://github.com/cross-rs/cross/discussions/categories/q-a
about: Or try the Q&A discussions
- name: FAQ
url: https://github.com/cross-rs/cross/wiki/FAQ
about: Frequently Asked Questions are compiled here.
================================================
FILE: .github/ISSUE_TEMPLATE/z_feature_request.yml
================================================
name: Feature Request
description: Leave a feature request if you have a suggestion to improve cross and/or the rust ecosystem
labels: ["feature-request"]
body:
- type: checkboxes
id: acknowledgments
attributes:
label: Checklist
options:
- label: I've looked through the [issues and pull requests](https://github.com/cross-rs/cross/issues?q=) for similar request
required: true
- label: This feature could be solved with a [custom image](https://github.com/cross-rs/cross/blob/main/docs/custom_images.md#custom-images) (optional)
- type: textarea
id: description
validations:
required: true
attributes:
label: Describe your request
description: |
Write a description of what your feature would do.
If you have an idea how to solve this, feel free to leave a comment on the feature request after creating it.
If you have tried solved this but couldn't, explain what you tried and how or why it didn't work. We want to help!
placeholder: |
Examples:
- cross should be able to do X.
- Add more emojis to the error printing.
- Implement support for cargo feature X.
- type: textarea
id: motivation
validations:
required: false
attributes:
label: Describe why this would be a good inclusion for `cross`
description: |
Why should this be added?
================================================
FILE: .github/actions/cargo-install-upload-artifacts/action.yml
================================================
name: Upload cargo install artifacts
description: Upload `cargo install` artifacts
inputs:
target:
description: 'Target'
required: true
runs:
using: composite
steps:
- name: Setup
id: metadata
run: |
metadata="$(cargo metadata --format-version 1 --no-deps)"
package_name="cross"
echo "package-name=${package_name}" >> $GITHUB_OUTPUT
out_dir="$(mktemp -d)"
artifacts_dir="$(mktemp -d)"
if which cygpath; then
out_dir="$(cygpath -w "${out_dir}")"
artifacts_dir="$(cygpath -w "${artifacts_dir}")"
fi
echo "out-dir=${out_dir}" >> $GITHUB_OUTPUT
echo "artifacts-dir=${artifacts_dir}" >> $GITHUB_OUTPUT
shell: bash
- run: rm -rf .git
shell: bash
- name: Build with all features
run:
cargo install
--locked
--path .
--target ${{ inputs.target }}
--all-features
--root ${{ steps.metadata.outputs.out-dir }}
--bins
shell: ${{ contains(runner.os, 'windows') && 'pwsh' || 'bash' }}
env:
RUSTFLAGS: "" # Make sure to unset RUSTFLAGS
- name: Archive artifacts
id: archive
run: |
set -x
if which cygpath; then
out_dir="$(cygpath -u "${out_dir}")"
artifacts_dir="$(cygpath -u "${artifacts_dir}")"
fi
artifact_name="${package_name}-${target}"
artifact_path="${artifacts_dir}/${artifact_name}.tar.gz"
pushd "${out_dir}/bin"
tar -cvzf "${artifact_path}" *
popd
tar -tf "${artifact_path}"
ls -al "${artifact_path}"
if which cygpath; then
artifact_path="$(cygpath -w "${artifact_path}")"
fi
echo "name=${artifact_name}" >> $GITHUB_OUTPUT
echo "path=${artifact_path}" >> $GITHUB_OUTPUT
env:
package_name: ${{ steps.metadata.outputs.package-name }}
out_dir: ${{ steps.metadata.outputs.out-dir }}
artifacts_dir: ${{ steps.metadata.outputs.artifacts-dir }}
target: ${{ inputs.target }}
shell: bash
- name: Upload artifacts
if: ${{ steps.archive.outputs.path }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.archive.outputs.name }}
path: ${{ steps.archive.outputs.path }}
if-no-files-found: error
================================================
FILE: .github/actions/cargo-llvm-cov/action.yml
================================================
name: llvm coverage
description: Sets up everything that is needed for coverage. Makes artifacts available for processing later, prefixed with _coverage-
inputs:
name:
description: 'the name of the artifact'
required: true
outputs:
artifact-name:
description: 'the name of the artifact'
value: ${{ steps.cov.outputs.artifact-name }}
runs:
using: composite
steps:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov@0.5.3
- run: rustup component add llvm-tools-preview
shell: bash
- name: LLVM instrument coverage
id: cov
uses: ./.github/actions/post
if: always()
with:
main: |
pwd=$(pwd)
if which cygpath; then
pwd="$(cygpath -w "$(pwd)")"
fi
echo RUSTFLAGS=" -C instrument-coverage --remap-path-prefix ${pwd}=" >> $GITHUB_ENV
echo LLVM_PROFILE_FILE="${pwd}/target/cross-%m.profraw" >> $GITHUB_ENV
echo CARGO_INCREMENTAL="0" >> $GITHUB_ENV
echo RUST_TEST_THREADS="1" >> $GITHUB_ENV
echo "artifact-name=_coverage-${name}" >> $GITHUB_OUTPUT
post: |
# XXX(emilgardis): Upload early?
pwd=$(pwd)
if which cygpath; then
pwd="$(cygpath -w "$(pwd)")"
fi
export LLVM_PROFILE_FILE="${pwd}/target/cross-%m.profraw"
export CARGO_LLVM_COV_TARGET_DIR="${pwd}/target"
mkdir coverage
echo $(ls target)
cargo llvm-cov report --remap-path-prefix --lcov --output-path "coverage/lcov.${name}.info" -vv || ( echo "::error title=Coverage merge failed::" && exit 0 )
rm target/*.profraw
npm install @actions/artifact
npm install glob
cat <<-EOT | node - || ( echo "::error title=Coverage upload failed::" && exit 0 )
(async function main() {
var artifact = require('@actions/artifact');
var glob = require('glob')
const artifactClient = artifact.create();
const artifactName = '_coverage-' + process.env.name;
const files = glob.sync("coverage/*");
if (!files.length) {
process.exit(0);
}
console.log("${files}")
const options = { retentionDays: 2 };
const upload = await artifactClient.uploadArtifact(artifactName, files, "coverage", options);
})()
EOT
env:
name: ${{ inputs.name }}
================================================
FILE: .github/actions/cargo-publish/action.yml
================================================
name: Publish crate
description: Publish crate on crates.io and create release on github
inputs:
cargo-registry-token:
description: 'API token for crates.io'
required: true
github-token:
description: 'Github API token'
required: true
runs:
using: composite
steps:
- name: Read changelog
id: changelog-reader
uses: mindsers/changelog-reader-action@v2
with:
# validation_depth: 10
version: ${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-') && github.ref_name) || 'Unreleased' }}
path: ./CHANGELOG.md
- name: Download artifacts
id: download-artifacts
uses: actions/download-artifact@v4
with:
path:
${{ runner.temp }}/artifacts
- name: Log into crates.io
if: >
github.event_name == 'push' && (
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
startsWith(github.ref, 'refs/tags/v')
)
run: cargo login ${{ inputs.cargo-registry-token }}
shell: bash
- run: gh release delete --yes Unreleased || exit 0
if: >
github.event_name == 'push' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
- name: Create GitHub release
if: >
github.event_name == 'push' && (
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
startsWith(github.ref, 'refs/tags/v')
)
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ (github.ref_type == 'tag' && github.ref_name) || 'Unreleased' }}
body: ${{ steps.changelog-reader.outputs.changes }}
prerelease: ${{ startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-') }}
draft: ${{ !startsWith(github.ref, 'refs/tags/v') && steps.changelog-reader.outputs.status == 'unreleased' }}
files: |
${{ steps.download-artifacts.outputs.download-path }}/cross-*/*
- name: Publish crate
run: cargo publish ${{ !startsWith(github.ref, 'refs/tags/v') && '--dry-run' || '' }}
shell: bash
================================================
FILE: .github/actions/post/action.yml
================================================
# adapted from https://github.com/actions/runner/issues/1478
name: With post step
description: 'Generic JS Action to execute a main command and set a command in a post step.'
inputs:
main:
description: 'Main command/script.'
required: true
post:
description: 'Post command/script.'
required: true
runs:
using: 'node20'
main: 'main.js'
post: 'main.js'
================================================
FILE: .github/actions/post/main.js
================================================
// adapted from https://github.com/actions/runner/issues/1478
const { exec } = require("child_process");
function run(cmd) {
exec(cmd, { shell: "bash" }, (error, stdout, stderr) => {
if (stdout.length != 0) {
console.log(`${stdout}`);
}
if (stderr.length != 0) {
console.error(`${stderr}`);
}
if (error) {
process.exitCode = error.code;
console.error(`${error}`);
}
});
}
if (process.env[`STATE_POST`] != undefined) {
// Are we in the 'post' step?
run(process.env.INPUT_POST);
} else {
// Otherwise, this is the main step
console.log(`POST=true >> $GITHUB_STATE`);
run(process.env.INPUT_MAIN);
}
================================================
FILE: .github/actions/setup-rust/action.yml
================================================
name: Setup Rust
description: Setup Rust with specified toolchain, target and components.
inputs:
toolchain:
description: 'Toolchain'
default: stable
required: true
target:
description: 'Target'
required: false
components:
description: 'Components'
required: false
runs:
using: composite
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
target: ${{ inputs.target }}
components: ${{ inputs.components }}
- name: Install rust matcher
run: echo "::add-matcher::.github/actions/setup-rust/rust.json"
shell: bash
- uses: Swatinem/rust-cache@v2.2.0
================================================
FILE: .github/actions/setup-rust/rust.json
================================================
{
"problemMatcher": [
{
"owner": "rust",
"pattern": [
{
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
"severity": 1,
"message": 4,
"code": 3
},
{
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 2,
"line": 3,
"column": 4
}
]
},
{
"owner": "cross-rs",
"pattern": [
{
"regexp": "^\\[cross\\] (warning|error): (.*)$",
"severity": 1,
"message": 2
}
]
}
]
}
================================================
FILE: .github/bors.toml
================================================
block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 0
use_codeowners = false
status = ["conclusion"]
timeout_sec = 21600
================================================
FILE: .github/codecov.yml
================================================
comment: false
codecov:
branch: main
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
flag_management:
default_rules: # the rules that will be followed for any flag added, generally.
carryforward: true
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/actions/cargo-install-upload-artifacts"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/actions/cargo-llvm-cov"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/actions/cargo-publish"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/actions/post"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/actions/setup-rust"
schedule:
interval: "weekly"
groups:
github_actions:
patterns:
- "*"
================================================
FILE: .github/workflows/changelog.yml.x
================================================
on:
pull_request:
types: [labeled, unlabeled, opened, synchronize, reopened]
name: Changelog check
jobs:
changelog:
name: Changelog check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-rust
- name: Get Changed Files
id: files
uses: tj-actions/changed-files@v41
with:
separator: ';'
files: |
.changes/*.json
- name: Validate Changelog
id: changelog
run: |
set -x
set -e
IFS=';' read -a added_modified <<< '${{ steps.files.outputs.all_changed_files }}'
IFS=';' read -a removed <<< '${{ steps.files.outputs.deleted_files }}'
added_count=${#added_modified[@]}
removed_count=${#removed[@]}
if ${{ !contains(github.event.pull_request.labels.*.name, 'no changelog' ) }}; then
if [[ "$added_count" -eq "0" ]] && [[ "$removed_count" -eq "0" ]]; then
echo "Must add or remove changes or add the 'no changelog' label"
exit 1
else
cargo xtask changelog validate
fi
fi
================================================
FILE: .github/workflows/ci.yml
================================================
on:
workflow_call:
inputs:
matrix-args:
required: false
type: string
description: Arguments to pass to `cargo xtask ci-job target-matrix`
checkout-ref:
required: false
type: string
description: Used to checkout a specific ref, instead of the default ref with `actions/checkout` action
pull_request:
merge_group:
push:
branches: [main, staging, trying]
tags:
- "v*.*.*"
name: CI
env:
CARGO_NET_RETRY: 3
CARGO_HTTP_CHECK_REVOKE: false
CROSS_IMAGE: ghcr.io/${{ github.repository_owner }}
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- name: Run ShellCheck
uses: Azbagheri/shell-linter@latest
with:
exclude-paths: ".github/CODEOWNERS,LICENSE-APACHE,LICENSE-MIT"
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: EmbarkStudios/cargo-deny-action@v2
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
with:
components: rustfmt
- name: Run rustfmt
run: cargo fmt -- --check
clippy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
with:
components: clippy
toolchain: 1.92.0 # MSRV, Minimally Supported Rust Version. Make sure to update README.md and clippy.toml
- name: Run clippy
run: cargo clippy --locked --all-targets --all-features --workspace -- -D warnings
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- uses: ./.github/actions/cargo-llvm-cov
with:
name: test-${{matrix.os}}
- name: Run unit tests
run: cargo test --locked --all-targets --workspace --all-features
timeout-minutes: 10
check:
runs-on: ubuntu-latest
outputs:
is-latest: ${{ steps.check.outputs.is-latest }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- run: cargo xtask ci-job check
id: check
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
tests: ${{ steps.generate-matrix.outputs.tests }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: Generate matrix
id: generate-matrix
run: cargo xtask ci-job target-matrix ${{ github.event_name == 'merge_group' && format('--merge-group {0}', github.ref) || '' }} ${{ inputs.matrix-args || '' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: target (${{ matrix.pretty }},${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [shellcheck, test, generate-matrix, check]
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'merge_group' || github.event_name == 'issue_comment' || github.event_name == 'schedule') && needs.generate-matrix.outputs.matrix != '{}' && needs.generate-matrix.outputs.matrix != '[]' && needs.generate-matrix.outputs.matrix != ''
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.pretty }}
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
outputs:
has-image: ${{ steps.prepare-meta.outputs.has-image }}
images: ${{ steps.build-docker-image.outputs.images && fromJSON(steps.build-docker-image.outputs.images) }}
coverage-artifact: ${{ steps.cov.outputs.artifact-name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v2
- name: Build xtask
run: cargo build -p xtask
- name: Prepare Meta
id: prepare-meta
timeout-minutes: 60
run: cargo xtask ci-job prepare-meta "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
shell: bash
- name: LLVM instrument coverage
id: cov
uses: ./.github/actions/cargo-llvm-cov
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant != 'zig'
with:
name: cross-${{matrix.pretty}}
- name: Install cross
if: matrix.deploy
run: cargo install --path . --force --debug
- name: Docker Meta
if: steps.prepare-meta.outputs.has-image
id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
name=${{ steps.prepare-meta.outputs.image }}
labels: |
${{ fromJSON(steps.prepare-meta.outputs.labels) }}
- name: Build Docker image
id: build-docker-image
if: steps.prepare-meta.outputs.has-image
timeout-minutes: 120
run: cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}" ${{ matrix.verbose && '-v' || '' }}
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta.outputs.labels }}
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
CROSS_DEBUG: ${{ matrix.cross-debug }}
shell: bash
- name: Set Docker image for test
if: steps.prepare-meta.outputs.has-image
run: |
TARGET_VAR="cross_target_${TARGET//-/_}_image"
echo "${TARGET_VAR^^}=${IMAGE}" | tee -a "${GITHUB_ENV}"
env:
TARGET: ${{ matrix.target }}
IMAGE: ${{ steps.build-docker-image.outputs.image }}
shell: bash
- name: Test Image
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default'
run: ./ci/test.sh
env:
TARGET: ${{ matrix.target }}
CPP: ${{ matrix.cpp }}
DYLIB: ${{ matrix.dylib }}
STD: ${{ matrix.std }}
BUILD_STD: ${{ matrix.build-std }}
RUN: ${{ matrix.run }}
RUNNERS: ${{ matrix.runners }}
CROSS_DEBUG: ${{ matrix.cross-debug }}
shell: bash
- uses: ./.github/actions/cargo-install-upload-artifacts
if: matrix.deploy
with:
target: ${{ matrix.target }}
- name: Test Zig Image
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'zig'
run: ./ci/test-zig-image.sh
shell: bash
- name: Test Cross Image
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'cross'
run: ./ci/test-cross-image.sh
env:
TARGET: 'aarch64-unknown-linux-gnu'
IMAGE: 'ghcr.io/${{ github.repository_owner }}/aarch64-unknown-linux-gnu:main'
shell: bash
- name: Login to GitHub Container Registry
if: steps.prepare-meta.outputs.has-image
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to GitHub Container Registry
if: >
(github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') &&
steps.prepare-meta.outputs.has-image && (
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
startsWith(github.ref, 'refs/tags/v')
)
run: cargo xtask build-docker-image -v --push "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta.outputs.labels }}
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
shell: bash
# we should always have an artifact from a previous build.
remote:
needs: [test, check, generate-matrix]
if: fromJson(needs.generate-matrix.outputs.tests).remote
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: LLVM instrument coverage
uses: ./.github/actions/cargo-llvm-cov
with:
name: integration-remote
- name: Run Remote Test
env:
TARGET: aarch64-unknown-linux-gnu
run: ./ci/test-remote.sh
shell: bash
bisect:
needs: [test, check, generate-matrix]
if: fromJson(needs.generate-matrix.outputs.tests).bisect
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: LLVM instrument coverage
uses: ./.github/actions/cargo-llvm-cov
with:
name: integration-bisect
- name: Run Bisect Test
env:
TARGET: aarch64-unknown-linux-gnu
run: ./ci/test-bisect.sh
shell: bash
foreign:
needs: [test, check, generate-matrix]
if: fromJson(needs.generate-matrix.outputs.tests).foreign
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: LLVM instrument coverage
uses: ./.github/actions/cargo-llvm-cov
with:
name: integration-bisect
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run Foreign toolchain test
run: ./ci/test-foreign-toolchain.sh
shell: bash
docker-in-docker:
needs: [test, check, generate-matrix]
if: fromJson(needs.generate-matrix.outputs.tests).docker-in-docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: LLVM instrument coverage
uses: ./.github/actions/cargo-llvm-cov
with:
name: integration-docker-in-docker
- name: Run Docker-in-Docker Test
env:
TARGET: aarch64-unknown-linux-gnu
IMAGE: 'ghcr.io/${{ github.repository_owner }}/aarch64-unknown-linux-gnu:main'
run: ./ci/test-docker-in-docker.sh
shell: bash
podman:
name: podman
runs-on: ubuntu-latest
needs: [shellcheck, test, check, generate-matrix]
if: fromJson(needs.generate-matrix.outputs.tests).podman
strategy:
fail-fast: false
outputs:
coverage-artifact: ${{ steps.cov.outputs.artifact-name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: Install Podman
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install podman --no-install-recommends --assume-yes
- name: LLVM instrument coverage
id: cov
uses: ./.github/actions/cargo-llvm-cov
with:
name: cross-podman-aarch64-unknown-linux-gnu
- name: Install cross
run: cargo install --path . --force --debug
- name: Run Podman Test
run: ./ci/test-podman.sh
env:
CROSS_CONTAINER_ENGINE: podman
TARGET: aarch64-unknown-linux-gnu
shell: bash
publish:
needs: [build, check, fmt, clippy, cargo-deny]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- uses: ./.github/actions/cargo-publish
with:
cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
conclusion:
needs: [shellcheck, fmt, clippy, test, generate-matrix, build, publish, check, remote, bisect, docker-in-docker, foreign, podman]
if: always()
runs-on: ubuntu-latest
steps:
- name: Result
run: |
jq -C <<< "${needs}"
# Check if all needs were successful or skipped.
"$(jq -r 'all(.result as $result | (["success", "skipped"] | contains([$result])))' <<< "${needs}")"
env:
needs: ${{ toJson(needs) }}
code-cov:
name: Coverage
needs: [test, build, conclusion, generate-matrix]
# should check that there are any artifacts, if not skip
if: always() && (needs.build.result == 'success' || needs.build.result == 'skipped') && needs.test.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/artifacts
- name: Grab PR number
run: echo "pr=$(echo ${commit_message} | sed -ne 's/.*#\(.*\):/\1/p')" >> $GITHUB_OUTPUT
id: pr-number
if: ${{ !github.event.pull_request.number }}
env:
commit_message: >
${{
((
startsWith(github.event.head_commit.message, 'Try #') &&
github.event.head_commit.author.username == 'bors[bot]'
) && github.event.head_commit.message) || ''
}}
- name: Upload to codecov.io
run: |
set -x
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
sha_rev=$(git rev-parse HEAD)
for file in $(find ${artifacts} -name "lcov.*.info" -exec ls {} +); do
name=$(echo $file | awk -F'.' '{print $2}');
./codecov -F $name ${pr:+-P ${pr}} -f $file --sha ${sha_rev} -n $name;
done
env:
pr: ${{ steps.pr-number.outputs.pr }}
artifacts: ${{ runner.temp }}/artifacts
================================================
FILE: .github/workflows/try.yml
================================================
name: Try
on:
issue_comment:
types: [created]
jobs:
acknowledge:
runs-on: ubuntu-latest
if: github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && (contains(toJson(github.event.comment.body), '\n/ci try') || startsWith(github.event.comment.body, '/ci try'))
steps:
- uses: actions/checkout@v3
- name: Acknowledge command
id: acknowledge
run: |
gh pr comment ${{ github.event.issue.number }} --body "
Starting try run. [Link to action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.issue.number }})"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
try:
if: github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && (contains(toJson(github.event.comment.body), '\n/ci try') || startsWith(github.event.comment.body, '/ci try'))
uses: ./.github/workflows/ci.yml
with:
matrix-args: try --comment "${{ github.event.comment.body }}" --pr ${{ github.event.issue.number }}
checkout-ref: refs/pull/${{ github.event.issue.number }}/head
comment:
needs: [try, acknowledge]
if: always() && needs.try.result != 'skipped'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Minimize existing comments
run: |
COMMENTS=$(gh pr view ${{ github.event.issue.number }} --json comments --jq '.comments[] | select((.body | contains("") or contains("")) and (.author.login == "github-actions") and (.isMinimized | not)) | .id')
while read -r comment_id; do
gh api graphql -f query='mutation { minimizeComment(input: { classifier: OUTDATED, subjectId: "'"$comment_id"'" }) { minimizedComment { isMinimized } } }'
done <<< "$COMMENTS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
# comment on the PR with the result and links to the logs using gh cli
# Something like `### Try build: [{result}]({link_to_logs})`
# the url to the logs are on jobs[name="try"].url gathered with `gh run view ${{ github.run_id }} --json jobs`
- name: Comment on PR
run: |
PR_ID=${{ github.event.issue.number }}
gh run view ${{ github.run_id }} --json jobs |\
jq -r --arg pr_id "$PR_ID" --arg comment "${{ github.event.comment.html_url }}" '
def box: .conclusion | if . == "success" then "✔️ " elif . == "skipped" then "🛇 " else "❌ " end;
def reason: if .conclusion == "failure" and (.steps | length > 0) then .steps[] | select(.conclusion == "failure") | .name else "" end;
def job_to_md: . | "- [\(.name)](\(.url)?pr=\($pr_id)\(.conclusion | if . == "success" then "#step:10:1)" else "#)" end) - \(box) \(reason)";
def wrap_if_needed:
(.[0].conclusion | if . == "success" then "#### Successful Jobs\n\n" else "#### Failed Jobs\n\n" end) +
if length > 10 then
"\nList\n\n\(map(job_to_md) | join("\n"))\n\n\n"
else
map(job_to_md) | join("\n") + "\n"
end;
"\n## [Try](\(.jobs[] | select(.name == "try / generate-matrix") | .url + "#step:4:18")) run for [comment](\($comment))\n\n" +
"\(.jobs[] | select(.name == "try / conclusion") | job_to_md)\n\n" +
([.jobs[] | select(.name | startswith("try / target")) | select(.name | contains("matrix.pretty") | not ) | . as $job |
{conclusion: $job.conclusion, name: ($job.name | capture("\\((?[^,]+),.*") | .name), url: $job.url, steps: $job.steps } ] |
group_by(if .conclusion == "success" then "success" else "failure" end) |
map(wrap_if_needed) |
join("\n"))' |\
gh pr comment "$PR_ID" --body "$(< /dev/stdin)"
env:
GH_TOKEN: ${{ github.token }}
================================================
FILE: .github/workflows/weekly.yml
================================================
on:
schedule:
- cron: '0 0 * * 5'
workflow_dispatch:
inputs:
targets:
required: false
description: 'check these space or comma separated targets, supports wildcard *'
name: Check
env:
CARGO_NET_RETRY: 3
CARGO_HTTP_CHECK_REVOKE: false
jobs:
weekly:
uses: ./.github/workflows/ci.yml
with:
matrix-args: --weekly
checkout-ref: ${{ github.ref }}
wiki:
name: Ensure wiki is valid
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-rust
- run: git clone ${wikirepo}
shell: bash
env:
wikirepo: https://github.com/${{ github.repository }}.wiki.git
- run: cargo test toml_check -- --nocapture
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
================================================
FILE: .gitignore
================================================
**/target/
**/.idea/
**/.vscode/*.*
**/*.log
/cargo-timing*.html
CHANGELOG.md.draft
# python stuff
__pycache__/
.pytest_cache/
*.py[cod]
*$py.class
*.egg-info/
*.egg
.tox
#--------------------------------------------------#
# The following was generated with gitignore.nvim: #
#--------------------------------------------------#
# Gitignore for the following technologies: Vim
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
================================================
FILE: .gitmodules
================================================
[submodule "docker/cross-toolchains"]
path = docker/cross-toolchains
url = https://github.com/cross-rs/cross-toolchains.git
================================================
FILE: CHANGELOG.md
================================================
# Change Log
All notable changes to this project will be documented in this file. This is an automatically-generated document: entries are added via changesets present in the `.changes` directory.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] - ReleaseDate
## [v0.2.5] - 2023-02-04
## Fixed
- #962 - fix SELinux labels to allow use in multiple containers and/or the host filesystem.
- #1166 - freebsd: include memstat in build image to fix build with libc 0.2.138 and up.
- #1183 - resolve issue when using `pre-build` in `Cargo.toml`
## [v0.2.4] - 2022-07-10
### Fixed
- #930 - fix any parsing of 1-character subcommands
- #929 - Fixed issue where `--verbose` would not output data when it should
## [v0.2.3] - 2022-07-09
### Added
- #921 - use `CARGO_TERM_VERBOSE`, `CARGO_TERM_QUIET`, and `CARGO_TERM_COLOR` environment variables for cross terminal output.
- #913 - added the `x86_64-unknown-illumos` target.
- #910 - `pre-build` can now take a string pointing to a script file to run.
- #905 - added `qemu-runner` for musl images, allowing use of native or emulated runners.
- #905 - added qemu emulation to `i586-unknown-linux-gnu`, `i686-unknown-linux-musl`, and `i586-unknown-linux-gnu`, so they can run on an `x86` CPU, rather than an `x86_64` CPU.
- #900 - add the option to skip copying build artifacts back to host when using remote cross via `CROSS_REMOTE_SKIP_BUILD_ARTIFACTS`.
- #891 - support custom user namespace overrides by setting the `CROSS_CONTAINER_USER_NAMESPACE` environment variable.
- #890 - support rootless docker via the `CROSS_ROOTLESS_CONTAINER_ENGINE` environment variable.
- #878 - added an image `ghcr.io/cross-rs/cross` containing cross.
### Changed
- #869 - ensure cargo configuration environment variable flags are passed to the docker container.
- #859 - added color diagnostic output and error messages.
### Fixed
- #905 - fixed running dynamically-linked libraries for all musl targets except `x86_64-unknown-linux-musl`.
- #904 - ensure `cargo metadata` works by using the same channel.
- #904 - fixed the path for workspace volumes and passthrough volumes with docker-in-docker.
- #898 - fix the path to the mount root with docker-in-docker if mounting volumes.
- #897 - ensure `target.$(...)` config options override `build` ones when parsing strings and vecs.
- #895 - convert filenames in docker tags to ASCII lowercase and ignore invalid characters
- #885 - handle symlinks when using remote docker.
- #868 - ignore the `CARGO` environment variable.
- #867 - fixed parsing of `build.env.passthrough` config values.
## [v0.2.2] - 2022-06-24
### Added
- #803 - added `CROSS_CUSTOM_TOOLCHAIN` to disable automatic installation of components for use with tools like `cargo-bisect-rustc`
- #795 - added images for additional toolchains maintained by cross-rs.
- #792 - added `CROSS_CONTAINER_IN_CONTAINER` environment variable to replace `CROSS_DOCKER_IN_DOCKER`.
- #785 - added support for remote container engines through data volumes through setting the `CROSS_REMOTE` environment variable. also adds in utility commands to create and remove persistent data volumes.
- #782 - added `build-std` config option, which builds the rust standard library from source if enabled.
- #678 - Add optional `target.{target}.dockerfile[.file]`, `target.{target}.dockerfile.context` and `target.{target}.dockerfile.build-args` to invoke docker/podman build before using an image.
- #678 - Add `target.{target}.pre-build` config for running commands before building the image.
- #772 - added `CROSS_CONTAINER_OPTS` environment variable to replace `DOCKER_OPTS`.
- #767, #788 - added the `cross-util` and `xtask` commands.
- #842 - Add `Cargo.toml` as configuration source
- #745 - added `thumbv7neon-*` targets.
- #741 - added `armv7-unknown-linux-gnueabi` and `armv7-unknown-linux-musleabi` targets.
- #721 - add support for running doctests on nightly if `CROSS_UNSTABLE_ENABLE_DOCTESTS=true`.
- #719 - add `--list` to known subcommands.
- #681 - Warn on unknown fields and confusable targets
- #624 - Add `build.default-target`
- #647 - Add `mips64-unknown-linux-muslabi64` and `mips64el-unknown-linux-muslabi64` support
- #543 - Added environment variables to control the UID and GID in the container
- #524 - docker: Add Nix Store volume support
- Added support for mounting volumes.
- #684 - Enable cargo workspaces to work from any path in the workspace, and make path dependencies mount seamlessly. Also added support for private SSH dependencies.
### Changed
- #838 - re-enabled the solaris targets.
- #807 - update Qemu to 6.1.0 on images using Ubuntu 18.04+ with python3.6+.
- #775 - forward Cargo exit code to host
- #762 - re-enabled `x86_64-unknown-dragonfly` target.
- #747 - reduced android image sizes.
- #746 - limit image permissions for android images.
- #377 - update WINE versions to 7.0.
- #734 - patch `arm-unknown-linux-gnueabihf` to build for ARMv6, and add architecture for crosstool-ng-based images.
- #709 - Update Emscripten targets to `emcc` version 3.1.10
- #707, #708 - Set `BINDGEN_EXTRA_CLANG_ARGS` environment variable to pass sysroot to `rust-bindgen`
- #696 - bump freebsd to 12.3
- #629 - Update Android NDK version and API version
- #497 - don't set RUSTFLAGS in aarch64-musl image
- #492 - Add cmake to FreeBSD images
- #748 - allow definitions in the environment variable passthrough
### Fixed
- #836 - write a `CACHEDIR.TAG` when creating the target directory, similar to `cargo`.
- #804 - allow usage of env `CARGO_BUILD_TARGET` as an alias for `CROSS_BUILD_TARGET`
- #792 - fixed container-in-container support when using podman.
- #781 - ensure `target.$(...)` config options override `build` ones.
- #771 - fix parsing of `DOCKER_OPTS`.
- #727 - add `PKG_CONFIG_PATH` to all `*-linux-gnu` images.
- #722 - boolean environment variables are evaluated as truthy or falsey.
- #720 - add android runner to preload `libc++_shared.so`.
- #725 - support `CROSS_DEBUG` and `CROSS_RUNNER` on android images.
- #714 - use host target directory when falling back to host cargo.
- #713 - convert relative target directories to absolute paths.
- #501 (reverted, see #764) - x86_64-linux: lower glibc version requirement to 2.17 (compatible with centos 7)
- #500 - use runner setting specified in Cross.toml
- #498 - bump linux-image version to fix CI
- Re-enabled `powerpc64-unknown-linux-gnu` image
- Re-enabled `sparc64-unknown-linux-gnu` image
- #582 - Added `libprocstat.so` to FreeBSD images
- #665 - when not using [env.volumes](https://github.com/cross-rs/cross#mounting-volumes-into-the-build-environment), mount project in /project
- #494 - Parse Cargo's --manifest-path option to determine mounted docker root
### Removed
- #718 - remove deb subcommand.
### Internal
- #856 - remove use of external wslpath and create internal helper that properly handles UNC paths.
- #828 - assume paths are Unicode and provide better error messages for path encoding errors.
- #787 - add installer for git hooks.
- #786, #791 - Migrate build script to rust: `cargo build-docker-image $TARGET`
- #730 - make FreeBSD builds more resilient.
- #670 - Use serde for deserialization of Cross.toml
- Change rust edition to 2021 and bump MSRV for the cross binary to 1.58.1
- #654 - Use color-eyre for error reporting
- #658 - Upgrade dependencies
- #652 - Allow trying individual targets via bors.
- #650 - Improve Docker caching.
- #609 - Switch to Github Actions and GHCR.
- #588 - fix ci: bump openssl version in freebsd again
- #552 - Added CHANGELOG.md automation
- #534 - fix image builds with update of dependencies
- #502 - fix ci: bump openssl version in freebsd
- #489 - Add support for more hosts and simplify/unify host support checks
- #477 - Fix Docker/Podman links in README
- #476 - Use Rustlang mirror for Sabotage linux tarballs
- Bump nix dependency to `0.22.1`
- Bump musl version to 1.1.24.
## [v0.2.1] - 2020-06-30
- Disabled `powerpc64-unknown-linux-gnu` image.
- Disabled `sparc64-unknown-linux-gnu` image.
- Disabled `x86_64-unknown-dragonfly` image.
- Removed CI testing for `i686-apple-darwin`.
## [v0.2.0] - 2020-02-22
- Removed OpenSSL from all images.
- Added support for Podman.
- Bumped all images to at least Ubuntu 16.04.
## [v0.1.16] - 2019-09-17
- Bump OpenSSL version to 1.0.2t.
- Re-enabled `asmjs-unknown-emscripten` target.
- Default to `native` runner instead of `qemu-user` for certain targets.
## [v0.1.15] - 2019-09-04
- Images are now hosted at .
- Bump OpenSSL version to 1.0.2p.
- Bump musl version to 1.1.20.
- Bump Ubuntu to 18.04 to all musl targets.
- Bump gcc version to 6.3.0 for all musl targets.
- OpenSSL support for the `arm-unknown-linux-musleabi` target.
- OpenSSL support for the `armv7-unknown-linux-musleabihf` target.
- Build and test support for `aarch64-unknown-linux-musl`, `arm-unknown-linux-musleabihf`,
`armv5te-unknown-linux-musleabi`, `i586-unknown-linux-musl`, `mips-unknown-linux-musl`,
add `mipsel-unknown-linux-musl` targets.
## [v0.1.14] - 2017-11-22
### Added
- Support for the `i586-unknown-linux-gnu` target.
### Changed
- Downgraded the Solaris toolchains from 2.11 to 2.10 to make the binaries produced by Cross more
compatible (this version matches what rust-lang/rust is using).
## [v0.1.13] - 2017-11-08
### Added
- Support for the custom [`deb`] subcommand.
[`deb`]: https://github.com/mmstick/cargo-deb
- Partial `test` / `run` support for android targets. Using the android API via `cross run` / `cross test` is _not_ supported because Cross is using QEMU instead of the official Android emulator.
- Partial support for the `sparcv9-sun-solaris` and `x86_64-sun-solaris` targets. `cross test` and
`cross run` doesn't work for these new targets.
- OpenSSL support for the `i686-unknown-linux-musl` target.
### Changed
- Bump OpenSSL version to 1.0.2m.
## [v0.1.12] - 2017-09-22
### Added
- Support for `cross check`. This subcommand won't use any Docker container.
### Changed
- `binfmt_misc` is not required on the host for toolchain v1.19.0 and newer.
With these toolchains `binfmt_misc` interpreters don't need to be installed
on the host saving a _privileged_ docker run which some systems don't allow.
## [v0.1.11] - 2017-06-10
### Added
- Build and test support for `i686-pc-windows-gnu`, `x86_64-pc-windows-gnu`,
`asmjs-unknown-emscripten` and `wasm-unknown-emscripten`.
- Build support for `aarch64-linux-android`, `arm-linux-androideabi`,
`armv7-linux-androideabi`, `x86_64-linux-android` and `i686-linux-android`
- A `build.env.passthrough` / `build.target.*.passthrough` option to Cross.toml
to support passing environment variables from the host to the Docker image.
### Changed
- Bumped OpenSSL version to 1.0.2k
- Bumped QEMU version to 2.9.0
## [v0.1.10] - 2017-04-02
### Added
- Cross compilation support for `x86_64-pc-windows-gnu`
- Cross compilation support for Android targets
### Changed
- Bumped OpenSSL version to 1.0.2k
## [v0.1.9] - 2017-02-08
### Added
- Support for ARM MUSL targets.
### Changed
- The automatic lockfile update that happens every time `cross` is invoked
should no longer hit the network when there's no git dependency to add/update.
- The QEMU_STRACE variable is passed to the underlying Docker container. Paired
with `cross run`, this lets you get a trace of system call from the execution
of "foreign" (non x86_64) binaries.
## [v0.1.8] - 2017-01-21
### Added
- Support for custom targets. Cross will now also try to use a docker image for
them. As with the built-in targets, one can override the image using
`[target.{}.image]` in Cross.toml.
### Changed
- Moved to a newer Xargo: v0.3.5
## [v0.1.7] - 2017-01-19
### Changed
- Moved to a newer Xargo: v0.3.4
### Fixed
- QEMU interpreters were being register when not required, e.g. for the
`x86_64-unknown-linux-gnu` target.
## [v0.1.6] - 2017-01-14
### Fixed
- Stable releases were picking the wrong image (wrong tag: 0.1.5 instead of
v0.1.5)
## [v0.1.5] - 2017-01-14 [YANKED]
### Added
- `cross run` support for the thumb targets.
- A `build.xargo` / `target.$TARGET.xargo` option to Cross.toml to use Xargo
instead of Cargo.
- A `target.$TARGET.image` option to override the Docker image used for
`$TARGET`.
- A `sparc64-unknown-linux-gnu` environment.
- A `x86_64-unknown-dragonfly` environment.
### Changed
- Building older versions (<0.7.0) of the `openssl` crate is now supported.
- Before Docker is invoked, `cross` will _always_ (re)generate the lockfile to
avoid errors later on due to read/write permissions. This removes the need to
call `cargo generate-lockfile` before `cross` in _all_ cases.
## [v0.1.4] - 2017-01-07
### Added
- Support for the `arm-unknown-linux-gnueabi` target
- `cross build` support for:
- `i686-unknown-freebsd`
- `x86_64-unknown-freebsd`
- `x86_64-unknown-netbsd`
### Changed
- It's no longer necessary to call `cargo generate-lockfile` before using
`cross` as `cross` will now take care of creating a lockfile when necessary.
- The C environments for the `thumb` targets now include newlib (`libc.a`,
`libm.a`, etc.)
### Fixed
- A segfault when `cross` was trying to figure out the name of the user that
called it.
## [v0.1.3] - 2017-01-01
### Changed
- Fix the `i686-unknown-linux-musl` target
## [v0.1.2] - 2016-12-31
### Added
- Support for `i686-unknown-linux-musl`
- Support for `cross build`ing crates for the `thumbv*-none-eabi*` targets.
## [v0.1.1] - 2016-12-28
### Added
- Support for `x86_64-unknown-linux-musl`
- Print shell commands when the verbose flag is used.
- Support crossing from x86_64 osx to i686 osx
## v0.1.0 - 2016-12-26
- Initial release. Supports 12 targets.
[Unreleased]: https://github.com/cross-rs/cross/compare/v0.2.5...HEAD
[v0.2.5]: https://github.com/cross-rs/cross/compare/v0.2.4...v0.2.5
[v0.2.4]: https://github.com/cross-rs/cross/compare/v0.2.3...v0.2.4
[v0.2.3]: https://github.com/cross-rs/cross/compare/v0.2.2...v0.2.3
[v0.2.2]: https://github.com/cross-rs/cross/compare/v0.2.1...v0.2.2
[v0.2.1]: https://github.com/cross-rs/cross/compare/v0.2.0...v0.2.1
[v0.2.0]: https://github.com/cross-rs/cross/compare/v0.1.16...v0.2.0
[v0.1.16]: https://github.com/cross-rs/cross/compare/v0.1.15...v0.1.16
[v0.1.15]: https://github.com/cross-rs/cross/compare/v0.1.14...v0.1.15
[v0.1.14]: https://github.com/cross-rs/cross/compare/v0.1.13...v0.1.14
[v0.1.13]: https://github.com/cross-rs/cross/compare/v0.1.12...v0.1.13
[v0.1.12]: https://github.com/cross-rs/cross/compare/v0.1.11...v0.1.12
[v0.1.11]: https://github.com/cross-rs/cross/compare/v0.1.10...v0.1.11
[v0.1.10]: https://github.com/cross-rs/cross/compare/v0.1.9...v0.1.10
[v0.1.9]: https://github.com/cross-rs/cross/compare/v0.1.8...v0.1.9
[v0.1.8]: https://github.com/cross-rs/cross/compare/v0.1.7...v0.1.8
[v0.1.7]: https://github.com/cross-rs/cross/compare/v0.1.6...v0.1.7
[v0.1.6]: https://github.com/cross-rs/cross/compare/v0.1.5...v0.1.6
[v0.1.5]: https://github.com/cross-rs/cross/compare/v0.1.4...v0.1.5
[v0.1.4]: https://github.com/cross-rs/cross/compare/v0.1.3...v0.1.4
[v0.1.3]: https://github.com/cross-rs/cross/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/cross-rs/cross/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/cross-rs/cross/compare/v0.1.0...v0.1.1
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# The Rust Code of Conduct
## Conduct
* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic.
* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all.
* Please be kind and courteous. There's no need to be mean or rude.
* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works.
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the [Citizen Code of Conduct](http://citizencodeofconduct.org/); if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Tools team][team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back.
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
## Moderation
These are the policies for upholding our community's standards of conduct.
1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.)
2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed.
3. Moderators will first respond to such remarks with a warning.
4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off.
5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded.
6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology.
7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed.
8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others.
In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely.
And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.
The enforcement policies listed above apply to the cross-rs [GitHub repositories]
and the cross-rs [Matrix room].
*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*
[team]: https://github.com/cross-rs
[GitHub repositories]: https://github.com/cross-rs
[Matrix room]: https://matrix.to/#/#cross-rs:matrix.org
================================================
FILE: CONTRIBUTING.md
================================================
Thank you for looking to contribute to cross. Have a new feature you'd like to add? Know how to fix an open bug? Want to add an image for a new target? We host documentation for how to contribute on our [wiki](https://github.com/cross-rs/cross/wiki/Contributing).
Please read our [code of conduct](https://github.com/cross-rs/cross/blob/main/CODE_OF_CONDUCT.md) so our community stays positive and welcoming. If you have any additional questions, please feel free to ask in either our [discussions](https://github.com/cross-rs/cross/discussions) or our [Matrix room](https://matrix.to/#/#cross-rs:matrix.org).
================================================
FILE: Cargo.toml
================================================
[package]
build = "src/build.rs"
description = "Zero setup cross compilation and cross testing"
documentation = "https://github.com/cross-rs/cross"
keywords = ["cross", "compilation", "testing", "tool"]
license = "MIT OR Apache-2.0"
name = "cross"
repository = "https://github.com/cross-rs/cross"
version = "0.2.5"
edition = "2021"
include = [
"src/**/*",
"docs/*.md",
"Cargo.toml",
"Cargo.lock",
"LICENSE*",
"README.md",
"assets/*",
]
rust-version = "1.92.0"
[features]
default = []
dev = []
[workspace]
members = ["xtask"]
[dependencies]
is-terminal = "0.4.2"
clap = { version = "4.1.4", features = ["derive"] }
color-eyre = { version = "0.6.5", default-features = false, features = ["track-caller"] }
eyre = "0.6.8"
thiserror = "2.0"
home = "0.5.4"
rustc_version = "0.4.0"
toml = "0.9"
which = "8.0"
shell-escape = "0.1.5"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = { version = "1.0.91", features = ["raw_value"] }
serde_ignored = "0.1.7"
shell-words = "1.1.0"
const-sha1 = "0.3"
signal-hook = { version = "0.4" }
directories = "6.0"
walkdir = { version = "2.3.2", optional = true }
tempfile = "3.3.0"
owo-colors = { version = "4.0", features = ["supports-colors"] }
semver = "1.0.16"
is_ci = "1.1.1"
[target.'cfg(not(windows))'.dependencies]
nix = { version = "0.30", default-features = false, features = ["user"] }
libc = "0.2.139"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["winbase"] }
dunce = "1.0.3"
[profile.release]
lto = true
[dev-dependencies]
regex = "1.7.1"
once_cell = "1.17.0"
ignore = "0.4.20"
[package.metadata.release]
push = false
publish = false
tag = false
consolidate-commits = false
pre-release-hook = ["cargo", "xtask", "changelog", "build", "--release", "{{version}}"]
pre-release-commit-message = "release version {{version}}"
[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = "\\.\\.\\.HEAD"
replace = "...v{{version}}"
exactly = 1
[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = ""
replace = "\n\n[Unreleased]: https://github.com/cross-rs/{{crate_name}}/compare/v{{version}}...HEAD"
exactly = 1
[[package.metadata.release.pre-release-replacements]]
file = "docs/config_file.md"
search = "(# Translates to `.*?:).*?(-centos`)"
replace = "${1}{{version}}$2"
exactly = 1
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.tar.gz"
bin-dir = "{ bin }{ binary-ext }"
pkg-fmt = "tgz"
================================================
FILE: LICENSE-APACHE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
================================================
FILE: LICENSE-MIT
================================================
Copyright (c) 2017-2022 by the respective authors
Copyright (c) 2016 Jorge Aparicio
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
[](https://crates.io/crates/cross)
[](https://crates.io/crates/cross)
[](https://github.com/cross-rs/cross/actions/workflows/ci.yml?query=branch)
[](https://matrix.to/#/#cross-rs:matrix.org)
# `cross`
> “Zero setup” cross compilation and “cross testing” of Rust crates
This project is developed and maintained by the [cross-rs] team.
It was previously maintained by the Rust Embedded Working Group Tools team.
New contributors are welcome! Please join our [Matrix room] and say hi.
`cross test`ing a crate for the aarch64-unknown-linux-gnu target
## Features
- `cross` will provide all the ingredients needed for cross compilation without
touching your system installation.
- `cross` provides an environment, cross toolchain and cross compiled libraries,
that produces the most portable binaries.
- “cross testing”, `cross` can test crates for architectures other than i686 and
x86_64.
- The stable, beta and nightly channels are supported.
## Dependencies
See our [Getting Started](./docs/getting-started.md) guide for detailed
installation instructions.
- [rustup](https://rustup.rs/)
- A Linux kernel with [binfmt_misc] support is required for cross testing.
One of these container engines is required. If both are installed, `cross` will
default to `docker`.
- [Docker]. Note that on Linux non-sudo users need to be in the `docker` group or use rootless docker.
Read the container engine [install guide][docker_install] for the required installation and post-installation steps. Requires version 20.10 (API 1.40) or later.
- [Podman]. Requires version 3.4.0 or later.
## Installation
```sh
cargo install cross --git https://github.com/cross-rs/cross
```
It's also possible to directly download the pre-compiled [release
binaries](https://github.com/cross-rs/cross/releases) or use
[cargo-binstall](https://github.com/cargo-bins/cargo-binstall).
## Usage
`cross` has the exact same CLI as [Cargo](https://github.com/rust-lang/cargo)
but relies on Docker or Podman. For Docker, you'll have to start
the daemon before you can use it.
```
# (ONCE PER BOOT, on Linux)
# Start the Docker daemon, if it's not already running using systemd
# on WSL2 and other systems using SysVinit, use `sudo service docker start`.
$ sudo systemctl start docker
# MAGIC! This Just Works
$ cross build --target aarch64-unknown-linux-gnu
# EVEN MORE MAGICAL! This also Just Works
$ cross test --target mips64-unknown-linux-gnuabi64
# Obviously, this also Just Works
$ cross rustc --target powerpc-unknown-linux-gnu --release -- -C lto
```
Additional documentation can be found on the
[wiki](https://github.com/cross-rs/cross/wiki) or the `docs/` subfolder.
## Configuration
### Configuring cross behavior
You have four options to configure `cross`. All of these options use the TOML
format for configuration and the possible configuration values are documented
[here][config_file].
#### Option 1: Configuring `cross` directly in your `Cargo.toml`
You can directly set [configuration values][config_file] in your `Cargo.toml`
file, under the `[workspace.metadata.cross]` table, i.e. key prefix. An example
config snippet would look like this:
```toml,cargo
[workspace.metadata.cross.target.aarch64-unknown-linux-gnu]
# Install libssl-dev:arm64, see
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get --assume-yes install libssl-dev:$CROSS_DEB_ARCH"
]
[workspace.metadata.cross.target.armv7-unknown-linux-gnueabi]
image = "my/image:latest"
[workspace.metadata.cross.build]
env.volumes = ["A_DIRECTORY=/path/to/volume"]
```
#### Option 2: Configuring `cross` via a `Cross.toml` file
You can put your [configuration][config_file] inside a `Cross.toml` file
in your project root directory.
#### Option 3: Using `CROSS_CONFIG` to specify the location of your configuration
By setting the `CROSS_CONFIG` environment variable, you can tell `cross` where
it should search for the config file. This way you are not limited to a
`Cross.toml` file in the project root.
#### Option 4: Configuring `cross` through environment variables
Besides the TOML-based configuration files, config can be passed through
[environment variables][docs_env_vars], too.
### Docker in Docker
When running `cross` from inside a container, `cross` needs access to
the hosts docker daemon itself. This is normally achieved by mounting the
docker daemons socket `/var/run/docker.sock`. For example:
```
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v .:/project \
-w /project my/development-image:tag cross build --target mips64-unknown-linux-gnuabi64
```
The image running `cross` requires the rust development tools to be installed.
With this setup `cross` must find and mount the correct host paths into the
container used for cross compilation. This includes the original project
directory as well as the root path of the parent container to give access to
the rust build tools.
To inform `cross` that it is running inside a container set
`CROSS_CONTAINER_IN_CONTAINER=true`.
A development or CI container can be created like this:
```
FROM rust:1
# set CROSS_CONTAINER_IN_CONTAINER to inform `cross` that it is executed from within a container
ENV CROSS_CONTAINER_IN_CONTAINER=true
# install `cross`
RUN cargo install cross
...
```
**Limitations**: Finding the mount point for the containers root directory is
currently only available for the overlayfs2 storage driver. In order to access
the parent containers rust setup, the child container mounts the parents
overlayfs. The parent must not be stopped before the child container, as the
overlayfs can not be unmounted correctly by Docker if the child container still
accesses it.
### Explicitly choose the container engine
By default, `cross` tries to use [Docker] or [Podman], in that order.
If you want to choose a container engine explicitly, you can set the
binary name (or path) using the `CROSS_CONTAINER_ENGINE`
environment variable.
For example in case you want use [Podman], you can set `CROSS_CONTAINER_ENGINE=podman`.
## Supported targets
A target is considered as “supported” if `cross` can cross compile a
“non-trivial” (binary) crate, usually Cargo, for that target.
Testing support (`cross test`) is more complicated. It relies on [QEMU]
emulation, so testing may fail due to QEMU bugs rather than bugs in your crate.
That said, a target has a ✓ in `test` column of the table below if it can run
the [`compiler-builtins`] test suite.
[QEMU]: https://www.qemu.org/
[`compiler-builtins`]: https://github.com/rust-lang-nursery/compiler-builtins
Also, testing is very slow. `cross test` runs units tests *sequentially* because
QEMU gets upset when you spawn multiple threads. This means that, if one of your
unit tests spawns threads, then it's more likely to fail or, worst, never
terminate.
| Target | libc | GCC | C++ | QEMU | `test` |
|----------------------------------------|-------:|-------:|:---:|------:|:------:|
| `aarch64-linux-android` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `aarch64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `aarch64-unknown-linux-gnu:centos` [7] | 2.17 | 4.8.5 | | 4.2.1 | ✓ |
| `aarch64-unknown-linux-musl` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `aarch64_be-unknown-linux-gnu` | 2.36 | 14.2.0 | ✓ | 6.1.0 | ✓ |
| `arm-linux-androideabi` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `arm-unknown-linux-gnueabi` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `arm-unknown-linux-gnueabihf` | 2.31 | 8.5.0 | ✓ | 6.1.0 | ✓ |
| `arm-unknown-linux-musleabi` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `arm-unknown-linux-musleabihf` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `armv5te-unknown-linux-gnueabi` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `armv5te-unknown-linux-musleabi` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `armv7-linux-androideabi` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `armv7-unknown-linux-gnueabi` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `armv7-unknown-linux-gnueabihf` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `armv7-unknown-linux-musleabi` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `armv7-unknown-linux-musleabihf` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `i586-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | N/A | ✓ |
| `i586-unknown-linux-musl` | 1.2.3 | 9.2.0 | ✓ | N/A | ✓ |
| `i686-unknown-freebsd` | 1.6 | 13.3.0 | ✓ | N/A | |
| `i686-linux-android` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `i686-pc-windows-gnu` | N/A | 9.4 | ✓ | N/A | ✓ |
| `i686-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `loongarch64-unknown-linux-gnu` | 2.36 | 14.2.0 | ✓ | 8.2.2 | ✓ |
| `loongarch64-unknown-linux-musl` | 1.2.5 | 14.2.0 | ✓ | 8.2.2 | ✓ |
| `mips-unknown-linux-gnu` | 2.30 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `mips-unknown-linux-musl` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `mips64-unknown-linux-gnuabi64` | 2.30 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `mips64-unknown-linux-muslabi64` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `mips64el-unknown-linux-gnuabi64` | 2.30 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `mips64el-unknown-linux-muslabi64` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `mipsel-unknown-linux-gnu` | 2.30 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `mipsel-unknown-linux-musl` | 1.2.3 | 9.2.0 | ✓ | 6.1.0 | ✓ |
| `powerpc-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `powerpc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `powerpc64le-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `riscv64gc-unknown-linux-gnu` | 2.35 | 11.4.0 | ✓ | 8.2.2 | ✓ |
| `riscv64gc-unknown-linux-musl` | 1.2.5 | 14.2.0 | ✓ | 8.2.2 | ✓ |
| `s390x-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `sparc64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `sparcv9-sun-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | |
| `thumbv6m-none-eabi` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv7em-none-eabi` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv7em-none-eabihf` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv7m-none-eabi` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv7neon-linux-androideabi` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `thumbv7neon-unknown-linux-gnueabihf` | 2.31 | 9.4.0 | ✓ | N/A | ✓ |
| `thumbv8m.base-none-eabi` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv8m.main-none-eabi` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `thumbv8m.main-none-eabihf` [4] | 3.3.0 | 9.2.1 | | N/A | |
| `wasm32-unknown-emscripten` [6] | 3.1.14 | 15.0.0 | ✓ | N/A | ✓ |
| `x86_64-linux-android` [1] | 9.0.8 | 9.0.8 | ✓ | 6.1.0 | ✓ |
| `x86_64-pc-windows-gnu` | N/A | 9.3 | ✓ | N/A | ✓ |
| `x86_64-pc-solaris` | 1.22.7 | 8.4.0 | ✓ | N/A | |
| `x86_64-unknown-freebsd` | 1.6 | 13.3.0 | ✓ | N/A | |
| `x86_64-unknown-dragonfly` [2] [3] | 6.0.1 | 10.3.0 | ✓ | N/A | |
| `x86_64-unknown-illumos` | 1.20.4 | 8.4.0 | ✓ | N/A | |
| `x86_64-unknown-linux-gnu` | 2.31 | 9.4.0 | ✓ | 6.1.0 | ✓ |
| `x86_64-unknown-linux-gnu:centos` [5] | 2.17 | 4.8.5 | ✓ | 4.2.1 | ✓ |
| `x86_64-unknown-linux-musl` | 1.2.3 | 9.2.0 | ✓ | N/A | ✓ |
| `x86_64-unknown-netbsd` [3] | 9.2.0 | 9.4.0 | ✓ | N/A | |
[1] libc = bionic; Only works with native tests, that is, tests that do not
depends on the Android Runtime. For i686 some tests may fails with the
error `assertion failed: signal(libc::SIGPIPE, libc::SIG_IGN) !=
libc::SIG_ERR`, see [issue
#140](https://github.com/cross-rs/cross/issues/140) for more information.
[2] No `std` component available.
[3] For some \*BSD and Solaris targets, the libc column indicates the OS
release version from which libc was extracted.
[4] libc = newlib
[5] Must change
`image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main-centos"` in
`Cross.toml` for `[target.x86_64-unknown-linux-gnu]` to use the
CentOS7-compatible target.
[6] libc = emscripten and GCC = clang
[7] Must change
`image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main-centos"` in
`Cross.toml` for `[target.aarch64-unknown-linux-gnu]` to use the
CentOS7-compatible target.
Additional Dockerfiles for other targets can be found in
[cross-toolchains](https://github.com/cross-rs/cross-toolchains). These include
MSVC and Apple Darwin targets, which we cannot ship pre-built images of.
## Debugging
### QEMU_STRACE (v0.1.9+)
You can set the QEMU_STRACE variable when you use `cross run` to get a backtrace
of system calls from “foreign” (non x86_64) binaries.
```
$ cargo new --bin hello && cd $_
$ QEMU_STRACE=1 cross run --target aarch64-unknown-linux-gnu
9 brk(NULL) = 0x0000004000023000
9 uname(0x4000823128) = 0
(..)
9 write(1,0xa06320,14)Hello, world!
= 14
9 sigaltstack(0x4000823588,(nil)) = 0
9 munmap(0x0000004000b16000,16384) = 0
9 exit_group(0)
```
## Minimum Supported Rust Version (MSRV)
This crate is guaranteed to compile on stable Rust 1.92.0 and up. It *might*
compile with older versions but that may change in any new patch release.
Some cross-compilation targets require a later Rust version, and using Xargo
requires a nightly Rust toolchain.
## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
## Code of Conduct
Contribution to this crate is organized under the terms of the [Rust Code of
Conduct][CoC], the maintainer of this crate, the [cross-rs] team, promises
to intervene to uphold that code of conduct.
[CoC]: CODE_OF_CONDUCT.md
[cross-rs]: https://github.com/cross-rs
[Docker]: https://www.docker.com
[Podman]: https://podman.io
[Matrix room]: https://matrix.to/#/#cross-rs:matrix.org
[docker_install]: https://github.com/cross-rs/cross/wiki/Getting-Started#installing-a-container-engine
[binfmt_misc]: https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html
[config_file]: ./docs/config_file.md
[docs_env_vars]: ./docs/environment_variables.md
================================================
FILE: ci/build_release.sh
================================================
#!/usr/bin/env bash
set -eux
cargo install --path . --force
if [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]]; then
# for this particular target, `cross` command below will try to reuse the artifacts (e.g. build
# script binaries) generated by the previous `cargo` command. that will fail to run because the
# cross environment has glibc 2.17 and the CI env (ubuntu 20.04) produces binaries that depend
# on glibc 2.18+
# to avoid the issue discard the build script artifacts produced by the previous command
cargo clean
fi
cross build --target "${TARGET}" --release
rm -rf "${BUILD_BINARIESDIRECTORY}"
mkdir "${BUILD_BINARIESDIRECTORY}"
if [[ -f "target/${TARGET}/release/cross.exe" ]]; then
mv "target/${TARGET}/release/cross.exe" "${BUILD_BINARIESDIRECTORY}/"
else
mv "target/${TARGET}/release/cross" "${BUILD_BINARIESDIRECTORY}/"
fi
================================================
FILE: ci/shared.sh
================================================
#!/usr/bin/env bash
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
PROJECT_HOME=$(dirname "${ci_dir}")
export PROJECT_HOME
CARGO_TMP_DIR="${PROJECT_HOME}/target/tmp"
export CARGO_TMP_DIR
if [[ -n "${CROSS_CONTAINER_ENGINE}" ]]; then
CROSS_ENGINE="${CROSS_CONTAINER_ENGINE}"
elif command -v docker >/dev/null 2>&1; then
CROSS_ENGINE=docker
else
CROSS_ENGINE=podman
fi
export CROSS_ENGINE
function retry {
local tries="${TRIES-5}"
local timeout="${TIMEOUT-1}"
local try=0
local exit_code=0
while (( try < tries )); do
if "${@}"; then
return 0
else
exit_code=$?
fi
sleep "${timeout}"
echo "Retrying ..." 1>&2
try=$(( try + 1 ))
timeout=$(( timeout * 2 ))
done
return ${exit_code}
}
function mkcargotemp {
local td=
td="$CARGO_TMP_DIR"/$(mktemp -u "${@}" | xargs basename)
mkdir -p "$td"
echo '# Cargo.toml
[workspace]
members = ["'"$(basename "$td")"'"]
' > "$CARGO_TMP_DIR"/Cargo.toml
echo "$td"
}
function binary_path() {
local binary="${1}"
local home="${2}"
local build_mode="${3}"
local cross="${home}/target/${build_mode}/${binary}"
case "$OSTYPE" in
msys*|cygwin*)
cross="${cross}.exe"
;;
*)
;;
esac
echo "${cross}"
}
================================================
FILE: ci/test-bisect.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC1090
# test to see that custom toolchains work
set -x
set -eo pipefail
if [[ -z "${TARGET}" ]]; then
export TARGET="aarch64-unknown-linux-gnu"
fi
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
local td=
local err=
retry cargo fetch
cargo build
cargo install cargo-bisect-rustc --debug
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS
td="$(mktemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
pushd "${td}"
retry cargo fetch
# shellcheck disable=SC2016
echo '#!/usr/bin/env bash
export CROSS_CUSTOM_TOOLCHAIN=1
"${CROSS}" run --target '"${TARGET}"'
cargo -V | grep 2022-06
' > bisect.sh
chmod +x bisect.sh
if ! err=$(cargo-bisect-rustc --start 2022-07-01 --end 2022-07-03 --script=./bisect.sh --target "${TARGET}" 2>&1); then
if [[ "${err}" != *"does not reproduce the regression"* ]]; then
echo "${err}"
exit 1
fi
else
echo "should have failed, instead succeeded" 1>&2
exit 1
fi
popd
rm -rf "${td}"
}
main
================================================
FILE: ci/test-cross-image.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC2086,SC1091,SC1090
set -x
set -eo pipefail
if [[ -z "${TARGET}" ]]; then
export TARGET="aarch64-unknown-linux-gnu"
fi
# ^^subst is not supported on macOS bash (bash <4)
# shellcheck disable=SC2155
export TARGET_UPPER=$(echo "$TARGET" | awk '{print toupper($0)}')
if [[ "${IMAGE}" ]]; then
# shellcheck disable=SC2140
export "CROSS_TARGET_${TARGET_UPPER//-/_}_IMAGE"="${IMAGE}"
fi
if [[ -z "${CROSS_TARGET_CROSS_IMAGE}" ]]; then
CROSS_TARGET_CROSS_IMAGE="ghcr.io/cross-rs/cross:main"
fi
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
docker run --rm -e TARGET -e "CROSS_TARGET_${TARGET_UPPER//-/_}_IMAGE" \
-v /var/run/docker.sock:/var/run/docker.sock \
"${CROSS_TARGET_CROSS_IMAGE}" sh -c '
#!/usr/bin/env sh
td="$(mktemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
cd "${td}"
cross run --target "${TARGET}"
'
td="$(mkcargotemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
cd "${td}"
echo '# Cross.toml
[target.'${TARGET}']
pre-build = ["exit 0"]
' > Cross.toml
docker run --rm -e TARGET -e CROSS_CONTAINER_IN_CONTAINER=1 -e "CROSS_TARGET_${TARGET_UPPER//-/_}_IMAGE" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD:/mount -w /mount \
"${CROSS_TARGET_CROSS_IMAGE}" cross build --target "${TARGET}"
}
main "${@}"
================================================
FILE: ci/test-docker-in-docker.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1004,SC1091,SC1090
# test to see that running docker-in-docker works
set -x
set -eo pipefail
if [[ -z "${TARGET}" ]]; then
export TARGET="aarch64-unknown-linux-gnu"
fi
# ^^subst is not supported on macOS bash (bash <4)
# shellcheck disable=SC2155
export TARGET_UPPER=$(echo "$TARGET" | awk '{print toupper($0)}')
if [[ "${IMAGE}" ]]; then
# shellcheck disable=SC2140
export "CROSS_TARGET_${TARGET_UPPER//-/_}_IMAGE"="${IMAGE}"
fi
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
docker run --platform linux/amd64 -v "${PROJECT_HOME}":"${PROJECT_HOME}" -w "${PROJECT_HOME}" \
--rm -e TARGET -e TARGET_UPPER -e RUSTFLAGS -e RUST_TEST_THREADS \
-e LLVM_PROFILE_FILE -e CARGO_INCREMENTAL \
-e "CROSS_TARGET_${TARGET_UPPER//-/_}_IMAGE" \
-v /var/run/docker.sock:/var/run/docker.sock \
docker:20.10-dind sh -c '
#!/usr/bin/env sh
set -x
set -euo pipefail
apk add curl
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "${HOME}/.cargo/env"
# building on release is slow
apk add libgcc gcc musl-dev
cargo test --workspace
cargo install --path . --force --debug
export CROSS_CONTAINER_IN_CONTAINER=1
apk add git
td="$(mktemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
cd "${td}"
cross run --target "${TARGET}" --verbose
td="$(mktemp -d)"
git clone --depth 1 https://github.com/cross-rs/test-workspace "${td}"
cd "${td}"
cross build --target "${TARGET}" --workspace \
--manifest-path="./workspace/Cargo.toml" --verbose
eval CROSS_TARGET_${TARGET_UPPER//-/_}_PRE_BUILD="exit" cross build --target "${TARGET}" --workspace \
--manifest-path="./workspace/Cargo.toml" --verbose
cd workspace
cross build --target "${TARGET}" --workspace --verbose
eval CROSS_TARGET_${TARGET_UPPER//-/_}_PRE_BUILD="exit" cross build --target "${TARGET}" --workspace --verbose
cd binary
cross run --target "${TARGET}" --verbose
eval CROSS_TARGET_${TARGET_UPPER//-/_}_PRE_BUILD="exit" cross run --target "${TARGET}" --verbose
'
}
main
================================================
FILE: ci/test-foreign-toolchain.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC1090
# test to see that foreign toolchains work
set -x
set -eo pipefail
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
local td=
retry cargo fetch
cargo build
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS
td="$(mkcargotemp -d)"
pushd "${td}"
cargo init --bin --name foreign_toolchain
# shellcheck disable=SC2016
echo '# Cross.toml
[build]
default-target = "x86_64-unknown-linux-musl"
[target."x86_64-unknown-linux-musl"]
image.name = "alpine:edge"
image.toolchain = ["x86_64-unknown-linux-musl"]
pre-build = ["apk add --no-cache gcc musl-dev"]' >"${CARGO_TMP_DIR}"/Cross.toml
"${CROSS}" run -v
local tmp_basename
tmp_basename=$(basename "${CARGO_TMP_DIR}")
"${CROSS_ENGINE}" images --format '{{.Repository}}:{{.Tag}}' --filter 'label=org.cross-rs.for-cross-target' | grep "cross-custom-${tmp_basename}" | xargs -t "${CROSS_ENGINE}" rmi
echo '# Cross.toml
[build]
default-target = "x86_64-unknown-linux-gnu"
[target.x86_64-unknown-linux-gnu]
pre-build = [
"apt-get update && apt-get install -y libc6 g++-x86-64-linux-gnu libc6-dev-amd64-cross",
]
[target.x86_64-unknown-linux-gnu.env]
passthrough = [
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc",
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=/qemu-runner x86_64",
"CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc",
"CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++",
]
[target.x86_64-unknown-linux-gnu.image]
name = "ubuntu:20.04"
toolchain = ["aarch64-unknown-linux-gnu"]
' >"${CARGO_TMP_DIR}"/Cross.toml
"${CROSS}" build -v
"${CROSS_ENGINE}" images --format '{{.Repository}}:{{.Tag}}' --filter 'label=org.cross-rs.for-cross-target' | grep "cross-custom-${tmp_basename}" | xargs "${CROSS_ENGINE}" rmi
popd
rm -rf "${td}"
}
main
================================================
FILE: ci/test-podman.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC1090
# test to see that running and building images with podman works.
set -x
set -eo pipefail
export CROSS_CONTAINER_ENGINE=podman
if [[ -z "${TARGET}" ]]; then
export TARGET="aarch64-unknown-linux-gnu"
fi
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
local td=
local parent=
local target="${TARGET}"
retry cargo fetch
cargo build
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS
td="$(mkcargotemp -d)"
parent=$(dirname "${td}")
pushd "${td}"
cargo init --bin --name "hello" .
echo '[build]
pre-build = ["apt-get update"]' > "${parent}/Cross.toml"
CROSS_CONTAINER_ENGINE="${CROSS_ENGINE}" "${CROSS}" build --target "${target}" --verbose
popd
rm -rf "${td}"
}
main
================================================
FILE: ci/test-remote.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC1090
# test to see that remote docker support works.
set -x
set -eo pipefail
export CROSS_REMOTE=1
if [[ -z "${TARGET}" ]]; then
export TARGET="aarch64-unknown-linux-gnu"
fi
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
main() {
local err=
retry cargo fetch
cargo build
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS
CROSS_UTIL=$(binary_path cross-util "${PROJECT_HOME}" debug)
export CROSS_UTIL
# if the create volume fails, ensure it exists.
if ! err=$("${CROSS_UTIL}" volumes create 2>&1 >/dev/null); then
if [[ "${err}" != *"already exists"* ]]; then
echo "${err}"
exit 1
fi
fi
cross_test_cpp
"${CROSS_UTIL}" volumes remove
# ensure the data volume was removed.
cross_test_cpp
}
cross_test_cpp() {
local td=
td="$(mkcargotemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
pushd "${td}"
retry cargo fetch
"${CROSS}" run --target "${TARGET}" | grep "Hello, world!"
sed -i 's/Hello, world/Hello, test/g' hellopp.cc
"${CROSS}" run --target "${TARGET}" | grep "Hello, test!"
popd
rm -rf "${td}"
}
main
================================================
FILE: ci/test-zig-image.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC2086,SC1091,SC1090
set -x
set -eo pipefail
# NOTE: "${@}" is an unbound variable for bash 3.2, which is the
# installed version on macOS. likewise, "${var[@]}" is an unbound
# error if var is an empty array.
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
# zig cc is very slow: only use a few targets.
TARGETS=(
"aarch64-unknown-linux-gnu"
"aarch64-unknown-linux-musl"
# disabled, see https://github.com/cross-rs/cross/issues/1425
#"i586-unknown-linux-gnu"
#"i586-unknown-linux-musl"
)
# on CI, it sets `CROSS_TARGET_ZIG_IMAGE` rather than `CROSS_BUILD_ZIG_IMAGE`
if [[ -n "${CROSS_TARGET_ZIG_IMAGE}" ]]; then
export CROSS_BUILD_ZIG_IMAGE="${CROSS_TARGET_ZIG_IMAGE}"
unset CROSS_TARGET_ZIG_IMAGE
fi
main() {
export CROSS_BUILD_ZIG=1
local td=
local target=
retry cargo fetch
cargo build
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS
td="$(mktemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
pushd "${td}"
for target in "${TARGETS[@]}"; do
CROSS_CONTAINER_ENGINE="${CROSS_ENGINE}" "${CROSS}" build --target "${target}" --verbose
# note: ensure #724 doesn't replicate during CI.
# https://github.com/cross-rs/cross/issues/724
cargo clean
done
popd
rm -rf "${td}"
}
main "${@}"
================================================
FILE: ci/test.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC2086,SC1091,SC1090
set -x
set -eo pipefail
# NOTE: "${@}" is an unbound variable for bash 3.2, which is the
# installed version on macOS. likewise, "${var[@]}" is an unbound
# error if var is an empty array.
ci_dir=$(dirname "${BASH_SOURCE[0]}")
ci_dir=$(realpath "${ci_dir}")
. "${ci_dir}"/shared.sh
workspace_test() {
"${CROSS[@]}" build --target "${TARGET}" --workspace "$@" ${CROSS_FLAGS}
"${CROSS[@]}" run --target "${TARGET}" -p binary "$@" ${CROSS_FLAGS}
"${CROSS[@]}" run --target "${TARGET}" --bin dependencies \
--features=dependencies "$@" ${CROSS_FLAGS}
}
main() {
local td=
retry cargo fetch
cargo build
# Unset RUSTFLAGS
export RUSTFLAGS=""
export QEMU_STRACE=1
# ensure we have the proper toolchain and optional rust flags
CROSS=$(binary_path cross "${PROJECT_HOME}" debug)
export CROSS=("${CROSS}")
export CROSS_FLAGS="-v"
if (( ${BUILD_STD:-0} )); then
# use build-std instead of xargo, due to xargo being
# maintenance-only. build-std requires a nightly compiler
rustup toolchain add nightly
CROSS_FLAGS="${CROSS_FLAGS} -Zbuild-std"
CROSS+=("+nightly")
if [[ "${TARGET}" == *"mips"* ]]; then
# workaround for https://github.com/cross-rs/cross/issues/1322 & https://github.com/rust-lang/rust/issues/108835
[[ ! "$RUSTFLAGS" =~ opt-level ]] && export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C opt-level=1"
fi
elif ! (( ${STD:-0} )); then
# don't use xargo: should have native support just from rustc
rustup toolchain add nightly
CROSS+=("+nightly")
fi
if (( ${STD:-0} )); then
# test `cross check`
td=$(mkcargotemp -d)
cargo init --lib --name foo "${td}"
pushd "${td}"
echo '#![no_std]' > src/lib.rs
"${CROSS[@]}" check --target "${TARGET}" ${CROSS_FLAGS}
popd
rm -rf "${td}"
else
# `cross build` test for targets where `std` is not available
td=$(mkcargotemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/rust-lang-nursery/compiler-builtins "${td}"
pushd "${td}"
retry cargo fetch
# don't use xargo: should have native support just from rustc
rustup toolchain add nightly
cross_build --lib --target "${TARGET}"
popd
rm -rf "${td}"
fi
# `cross build` test for the other targets
if [[ "${TARGET}" == *-unknown-emscripten ]]; then
td=$(mkcargotemp -d)
pushd "${td}"
cargo init --lib --name foo .
retry cargo fetch
cross_build --target "${TARGET}"
popd
rm -rf "${td}"
# thumb targets are tested in later steps
elif [[ "${TARGET}" != thumb* ]]; then
td=$(mkcargotemp -d)
pushd "${td}"
# test that linking works
cargo init --bin --name hello .
retry cargo fetch
cross_build --target "${TARGET}"
popd
rm -rf "${td}"
fi
if (( ${RUN:-0} )); then
# `cross test` test
if (( ${DYLIB:-0} )); then
td=$(mkcargotemp -d)
pushd "${td}"
cargo init --lib --name foo .
cross_test --target "${TARGET}"
cross_bench --target "${TARGET}"
popd
rm -rf "${td}"
fi
# `cross run` test
case "${TARGET}" in
thumb*-none-eabi*)
td=$(mkcargotemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/japaric/cortest "${td}"
pushd "${td}"
cross_run --target "${TARGET}" --example hello --release
popd
rm -rf "${td}"
;;
*)
td=$(mkcargotemp -d)
cargo init --bin --name hello "${td}"
pushd "${td}"
mkdir examples tests
echo "fn main() { println!(\"Example!\"); }" > examples/e.rs
echo "#[test] fn t() {}" > tests/t.rs
cross_run --target "${TARGET}"
cross_run --target "${TARGET}" --example e
cross_test --target "${TARGET}"
cross_bench --target "${TARGET}"
popd
rm -rf "${td}"
td=$(mkcargotemp -d)
git clone \
--depth 1 \
--recursive \
https://github.com/cross-rs/test-workspace "${td}"
pushd "${td}"
TARGET="${TARGET}" workspace_test --manifest-path="./workspace/Cargo.toml"
pushd "workspace"
TARGET="${TARGET}" workspace_test
pushd "binary"
"${CROSS[@]}" run --target "${TARGET}" ${CROSS_FLAGS}
popd
popd
popd
;;
esac
fi
# Test C++ support in a no_std context
if (( ${CPP:-0} )); then
td="$(mkcargotemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-accumulate "${td}"
pushd "${td}"
retry cargo fetch
cross_build --target "${TARGET}"
popd
rm -rf "${td}"
fi
# Test C++ support
if (( ${STD:-0} )) && (( ${CPP:-0} )); then
td="$(mkcargotemp -d)"
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}"
pushd "${td}"
retry cargo fetch
if (( ${RUN:-0} )); then
cross_run --target "${TARGET}"
else
cross_build --target "${TARGET}"
fi
popd
rm -rf "${td}"
fi
# special tests for a shared C runtime, since we disable the shared c++ runtime
# https://github.com/cross-rs/cross/issues/902
if [[ "${TARGET}" == *-linux-musl* ]]; then
td=$(mkcargotemp -d)
pushd "${td}"
cargo init --bin --name hello .
retry cargo fetch
RUSTFLAGS="$RUSTFLAGS -C target-feature=-crt-static" \
cross_build --target "${TARGET}"
popd
rm -rf "${td}"
fi
# test cmake support
td="$(mkcargotemp -d)"
git clone \
--recursive \
--depth 1 \
https://github.com/cross-rs/rust-cmake-hello-world "${td}"
pushd "${td}"
retry cargo fetch
if [[ "${TARGET}" == "arm-linux-androideabi" ]]; then
# ARMv5te isn't supported anymore by Android, which produces missing
# symbol errors with re2 like `__libcpp_signed_lock_free`.
cross_run --target "${TARGET}" --features=tryrun
elif (( ${STD:-0} )) && (( ${RUN:-0} )) && (( ${CPP:-0} )); then
cross_run --target "${TARGET}" --features=re2,tryrun
elif (( ${STD:-0} )) && (( ${CPP:-0} )); then
cross_build --target "${TARGET}" --features=re2
elif (( ${STD:-0} )) && (( ${RUN:-0} )); then
cross_run --target "${TARGET}" --features=tryrun
elif (( ${STD:-0} )); then
cross_build --target "${TARGET}" --features=tryrun
else
cross_build --lib --target "${TARGET}"
fi
popd
rm -rf "${td}"
# test running binaries with cleared environment
# Command is not implemented for wasm32-unknown-emscripten
if (( ${RUN:-0} )) && [[ "${TARGET}" != "wasm32-unknown-emscripten" ]]; then
td="$(mkcargotemp -d)"
pushd "${td}"
cargo init --bin --name foo .
mkdir src/bin
upper_target=$(echo "${TARGET}" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
cat < src/bin/launch.rs
fn main() {
let runner = std::env::var("CARGO_TARGET_${upper_target}_RUNNER");
let mut command = if let Ok(runner) = runner {
runner.split(' ').map(str::to_string).collect()
} else {
vec![]
};
let executable = format!("/target/${TARGET}/debug/foo{}", std::env::consts::EXE_SUFFIX);
command.push(executable.to_string());
let status = dbg!(std::process::Command::new(&command[0])
.args(&command[1..])
.env_clear()) // drop all environment variables
.status()
.unwrap();
std::process::exit(status.code().unwrap());
}
EOF
cross_build --target "${TARGET}"
cross_run --target "${TARGET}" --bin launch
popd
rm -rf "${td}"
fi
}
cross_build() {
"${CROSS[@]}" build "$@" ${CROSS_FLAGS}
}
cross_run() {
if [[ -z "${RUNNERS:-}" ]]; then
"${CROSS[@]}" run "$@" ${CROSS_FLAGS}
else
for runner in ${RUNNERS}; do
echo -e "[target.${TARGET}]\nrunner = \"${runner}\"" > "${CARGO_TMP_DIR}"/Cross.toml
"${CROSS[@]}" run "$@" ${CROSS_FLAGS}
done
fi
}
cross_test() {
if [[ -z "${RUNNERS:-}" ]]; then
"${CROSS[@]}" test "$@" ${CROSS_FLAGS}
else
for runner in ${RUNNERS}; do
echo -e "[target.${TARGET}]\nrunner = \"${runner}\"" > "${CARGO_TMP_DIR}"/Cross.toml
"${CROSS[@]}" test "$@" ${CROSS_FLAGS}
done
fi
}
cross_bench() {
if [[ -z "${RUNNERS:-}" ]]; then
"${CROSS[@]}" bench "$@" ${CROSS_FLAGS}
else
for runner in ${RUNNERS}; do
echo -e "[target.${TARGET}]\nrunner = \"${runner}\"" > "${CARGO_TMP_DIR}"/Cross.toml
"${CROSS[@]}" bench "$@" ${CROSS_FLAGS}
done
fi
}
main
================================================
FILE: clippy.toml
================================================
disallowed-methods = [
{ path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" },
]
allow-unwrap-in-tests = true
msrv = "1.92.0"
================================================
FILE: crosstool-ng/arm-unknown-linux-gnueabihf.config.in
================================================
CT_CONFIG_VERSION="4"
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_DOWNLOAD_AGENT_CURL=y
CT_ARCH_ARM=y
CT_ARCH_ARCH="armv6"
CT_ARCH_FPU="vfp"
CT_ARCH_FLOAT_HW=y
CT_KERNEL_LINUX=y
%CT_LINUX_V%
%CT_LINUX%
CT_BINUTILS_V_2_32=y
%CT_GLIBC_V%
%CT_GLIBC%
%CT_GCC_V%
%CT_GCC%
CT_CC_LANG_CXX=y
CT_GETTEXT_V_0_19_8_1=y
CT_GMP_V_6_1=y
CT_ISL_V_0_20=y
CT_LIBICONV_V_1_15=y
CT_NCURSES_V_6_1=y
================================================
FILE: crosstool-ng/loongarch64-unknown-linux-gnu.config.in
================================================
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
%CT_LINUX_V%
%CT_LINUX%
%CT_GLIBC_V%
%CT_GLIBC%
%CT_GCC_V%
%CT_GCC%
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
================================================
FILE: crosstool-ng/loongarch64-unknown-linux-musl.config.in
================================================
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
%CT_LINUX_V%
%CT_LINUX%
CT_LIBC_MUSL=y
%CT_MUSL_V%
%CT_GCC_V%
%CT_GCC%
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
================================================
FILE: deny.toml
================================================
[graph]
# only check for the targets we currently publish
targets = [
{ triple = "x86_64-apple-darwin" },
{ triple = "x86_64-unknown-linux-gnu" },
{ triple = "x86_64-unknown-linux-musl" },
{ triple = "x86_64-pc-windows-msvc" },
]
[advisories]
version = 2
[bans]
multiple-versions = "deny"
deny = []
skip-tree = [
{ name = "supports-color", depth = 1, version = "2.1.0", reason = "owo-colors pulls in two versions of supports-color" },
]
[sources]
unknown-registry = "deny"
unknown-git = "deny"
allow-git = []
[licenses]
version = 2
# need this since to suppress errors in case we add crates with these allowed licenses
unused-allowed-license = "allow"
confidence-threshold = 0.93
allow = [
"Apache-2.0",
"MIT",
"CC0-1.0",
"ISC",
"0BSD",
"BSD-2-Clause",
"BSD-3-Clause",
"Unlicense",
"Unicode-DFS-2016",
"Unicode-3.0",
"MPL-2.0",
]
[licenses.private]
ignore = true
================================================
FILE: docker/.dockerignore
================================================
# don't copy any of the python artifacts to the docker context
__pycache__/
.pytest_cache/
*.py[cod]
*$py.class
**/*.egg-info/
*.egg
.tox
# also skip our test suite
android/tests/
================================================
FILE: docker/.gitattributes
================================================
* text eol=lf
================================================
FILE: docker/Dockerfile.aarch64-linux-android
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh aarch64
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh arm64
COPY android-ndk.sh /
RUN /android-ndk.sh arm64
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh arm64
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-linux-android-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh aarch64 aarch64-linux-android
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CROSS_TARGET_RUNNER="/android-runner aarch64"
ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER="$CROSS_TARGET_RUNNER" \
AR_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"as \
CC_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_aarch64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_aarch64_linux_android=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include"/ \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="-DANDROID -ffunction-sections -fdata-sections -fPIC"
================================================
FILE: docker/Dockerfile.aarch64-unknown-freebsd
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN echo "export ARCH=aarch64" > /freebsd-arch.sh
COPY freebsd-common.sh /
COPY freebsd.sh /
RUN /freebsd.sh
COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-unknown-freebsd13-
ENV CROSS_SYSROOT=/usr/local/aarch64-unknown-freebsd13
COPY freebsd-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY toolchain.cmake /opt/toolchain.cmake
COPY freebsd-fetch-best-mirror.sh /
COPY freebsd-setup-packagesite.sh /
COPY freebsd-install-package.sh /
ENV CARGO_TARGET_AARCH64_UNKNOWN_FREEBSD_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
AR_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_unknown_freebsd=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_freebsd="--sysroot=$CROSS_SYSROOT" \
AARCH64_UNKNOWN_FREEBSD_OPENSSL_DIR="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=FreeBSD \
CROSS_CMAKE_SYSTEM_PROCESSOR=amd64 \
CROSS_CMAKE_CRT=freebsd \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.aarch64-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-aarch64-linux-gnu \
gfortran-aarch64-linux-gnu \
libc6-dev-arm64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=arm64 /deny-debian-packages.sh \
binutils \
binutils-aarch64-linux-gnu
COPY qemu.sh /
RUN /qemu.sh aarch64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh aarch64
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-linux-gnu-
ENV CROSS_SYSROOT=/usr/aarch64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner aarch64"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.aarch64-unknown-linux-gnu.centos
================================================
FROM ubuntu:20.04 AS base
COPY lib.sh /
COPY linux-image.sh /
RUN /linux-image.sh aarch64
FROM centos:7
# From https://github.com/rust-lang/rust/blob/672e3aaf28ab1e5cbe80b3ff012cd3a8e4ef98af/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile#L9-L12
# CentOS 7 EOL is June 30, 2024, but the repos remain in the vault.
RUN sed -i /etc/yum.repos.d/*.repo -e 's!^mirrorlist!#mirrorlist!' \
-e 's!^#baseurl=http://mirror.centos.org/!baseurl=https://vault.centos.org/!'
RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
COPY qemu.sh /
RUN /qemu.sh aarch64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY --from=0 /qemu /qemu
COPY linux-runner base-runner.sh /
COPY aarch64-linux-gnu-glibc.sh /
RUN /aarch64-linux-gnu-glibc.sh
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-linux-gnu-
ENV CROSS_SYSROOT=/usr/aarch64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner aarch64"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.aarch64-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh aarch64
COPY musl.sh /
RUN /musl.sh TARGET=aarch64-linux-musl
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=aarch64-linux-musl-
ENV CROSS_SYSROOT=/usr/local/aarch64-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT aarch64
COPY musl-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner aarch64"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_aarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_aarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC" \
CROSS_BUILTINS_PATCHED_MINOR_VERSION=48
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.aarch64_be-unknown-linux-gnu
================================================
FROM ubuntu:24.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/aarch64_be-unknown-linux-gnu.config /
RUN /crosstool-ng.sh aarch64_be-unknown-linux-gnu.config 5
ENV PATH=/x-tools/aarch64_be-unknown-linux-gnu/bin/:$PATH
COPY qemu.sh /
RUN /qemu.sh aarch64_be
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=aarch64_be-unknown-linux-gnu-
ENV CROSS_SYSROOT=/x-tools/aarch64_be-unknown-linux-gnu/aarch64_be-unknown-linux-gnu/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner aarch64_be"
ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_aarch64_be_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_aarch64_be_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_aarch64_be_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_aarch64_be_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_aarch64_be_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=aarch64_be \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.arm-linux-androideabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh arm
COPY android-ndk.sh /
RUN /android-ndk.sh arm
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh arm
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-androideabi-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh arm arm-linux-androideabi
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CROSS_TARGET_RUNNER="/android-runner arm"
ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"as \
CC_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_arm_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_arm_linux_androideabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_arm_linux_androideabi="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include/" \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv5te \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="--target=arm-linux-androideabi -DANDROID -ffunction-sections -fdata-sections -fPIC --target=arm-linux-androideabi"
================================================
FILE: docker/Dockerfile.arm-unknown-linux-gnueabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-arm-linux-gnueabi \
gfortran-arm-linux-gnueabi \
libc6-dev-armel-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=armel /deny-debian-packages.sh \
binutils \
binutils-arm-linux-gnueabi
COPY qemu.sh /
RUN /qemu.sh arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-gnueabi-
ENV CROSS_SYSROOT=/usr/arm-linux-gnueabi
ENV CROSS_TARGET_RUNNER="/qemu-runner arm"
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_arm_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_arm_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_arm_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_arm_unknown_linux_gnueabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_arm_unknown_linux_gnueabi="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabi/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfloat-abi=soft"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.arm-unknown-linux-gnueabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/arm-unknown-linux-gnueabihf.config /
RUN /crosstool-ng.sh arm-unknown-linux-gnueabihf.config 5
ENV PATH=/x-tools/arm-unknown-linux-gnueabihf/bin/:$PATH
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=armhf /deny-debian-packages.sh
COPY qemu.sh /
RUN /qemu.sh arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-unknown-linux-gnueabihf-
ENV CROSS_SYSROOT=/x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner armhf"
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
AR_arm_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_arm_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_arm_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_arm_unknown_linux_gnueabihf=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_arm_unknown_linux_gnueabihf="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfpu=vfp"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.arm-unknown-linux-musleabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
COPY musl.sh /
RUN /musl.sh \
TARGET=arm-linux-musleabi \
"COMMON_CONFIG += --with-arch=armv6 \
--with-float=soft \
--with-mode=arm"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-musleabi-
ENV CROSS_SYSROOT=/usr/local/arm-linux-musleabi
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner arm"
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_arm_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_arm_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_arm_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_arm_unknown_linux_musleabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_arm_unknown_linux_musleabi="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfloat-abi=soft"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.arm-unknown-linux-musleabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
COPY musl.sh /
RUN /musl.sh \
TARGET=arm-linux-musleabihf \
"COMMON_CONFIG += --with-arch=armv6 \
--with-fpu=vfp \
--with-float=hard \
--with-mode=arm"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-musleabihf-
ENV CROSS_SYSROOT=/usr/local/arm-linux-musleabihf
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT armhf
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner armhf"
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
AR_arm_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_arm_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_arm_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_arm_unknown_linux_musleabihf=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_arm_unknown_linux_musleabihf="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfpu=vfp"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.armv5te-unknown-linux-gnueabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-arm-linux-gnueabi \
gfortran-arm-linux-gnueabi \
crossbuild-essential-armel \
libc6-dev-armel-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=armel /deny-debian-packages.sh \
binutils \
binutils-arm-linux-gnueabi
COPY qemu.sh /
RUN /qemu.sh arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-gnueabi-
ENV CROSS_SYSROOT=/usr/arm-linux-gnueabi
ENV CROSS_TARGET_RUNNER="/qemu-runner arm"
ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_GNUEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_GNUEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv5te_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv5te_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv5te_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv5te_unknown_linux_gnueabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv5te_unknown_linux_gnueabi="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabi/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv5te -marm -mfloat-abi=soft"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.armv5te-unknown-linux-musleabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
COPY musl.sh /
RUN /musl.sh TARGET=arm-linux-musleabi "COMMON_CONFIG += --with-arch=armv5te --with-float=soft --with-mode=arm"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-musleabi-
ENV CROSS_SYSROOT=/usr/local/arm-linux-musleabi
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT arm
COPY musl-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner arm"
ENV CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_MUSLEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv5te_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv5te_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv5te_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv5te_unknown_linux_musleabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv5te_unknown_linux_musleabi="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv5te -marm -mfloat-abi=soft" \
CROSS_BUILTINS_PATCHED_MINOR_VERSION=65
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.armv7-linux-androideabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh arm
COPY android-ndk.sh /
RUN /android-ndk.sh arm
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh arm
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-androideabi-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh arm arm-linux-androideabi
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CROSS_TARGET_RUNNER="/android-runner arm"
ENV CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"as \
CC_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_armv7_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_armv7_linux_androideabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv7_linux_androideabi="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include/" \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv7-a \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="--target=arm-linux-androideabi -DANDROID -ffunction-sections -fdata-sections -fPIC --target=armv7-linux-androideabi"
================================================
FILE: docker/Dockerfile.armv7-unknown-linux-gnueabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get install --assume-yes --no-install-recommends \
g++-arm-linux-gnueabi \
gfortran-arm-linux-gnueabi \
libc6-dev-armel-cross
COPY qemu.sh /
RUN /qemu.sh arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-gnueabi-
ENV CROSS_SYSROOT=/usr/arm-linux-gnueabi
ENV CROSS_TARGET_RUNNER="/qemu-runner armv7"
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv7_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv7_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv7_unknown_linux_gnueabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv7_unknown_linux_gnueabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv7_unknown_linux_gnueabi="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabi/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv7-a"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.armv7-unknown-linux-gnueabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-arm-linux-gnueabihf \
gfortran-arm-linux-gnueabihf \
libc6-dev-armhf-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=armhf /deny-debian-packages.sh \
binutils \
binutils-arm-linux-gnueabihf
COPY qemu.sh /
RUN /qemu.sh arm softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh armv7
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-gnueabihf-
ENV CROSS_SYSROOT=/usr/arm-linux-gnueabihf
ENV CROSS_TARGET_RUNNER="/linux-runner armv7hf"
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv7_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv7_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv7_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv7_unknown_linux_gnueabihf=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv7_unknown_linux_gnueabihf="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv7-a -mfpu=vfpv3-d16"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.armv7-unknown-linux-musleabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
COPY musl.sh /
RUN /musl.sh \
TARGET=arm-linux-musleabi \
"COMMON_CONFIG += --with-arch=armv7-a \
--with-float=soft \
--with-mode=thumb \
--with-mode=arm"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-musleabi-
ENV CROSS_SYSROOT=/usr/local/arm-linux-musleabi
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT arm
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner armv7"
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv7_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv7_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv7_unknown_linux_musleabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv7_unknown_linux_musleabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv7_unknown_linux_musleabi="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv7-a"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.armv7-unknown-linux-musleabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
COPY musl.sh /
RUN /musl.sh \
TARGET=arm-linux-musleabihf \
"COMMON_CONFIG += --with-arch=armv7-a \
--with-float=hard \
--with-mode=thumb \
--with-fpu=vfp"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-musleabihf-
ENV CROSS_SYSROOT=/usr/local/arm-linux-musleabihf
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT armhf
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner armv7hf"
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
AR_armv7_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_armv7_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_armv7_unknown_linux_musleabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_armv7_unknown_linux_musleabihf=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_armv7_unknown_linux_musleabihf="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv7-a -mfpu=vfpv3-d16"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.asmjs-unknown-emscripten
================================================
FROM emscripten/emsdk:3.1.14
WORKDIR /
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
libxml2 \
python
ENV CROSS_TOOLCHAIN_PREFIX=em
ENV CROSS_SYSROOT=/emsdk/upstream/emscripten/cache/sysroot
ENV CROSS_TARGET_RUNNER="node"
ENV CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER="$CROSS_TARGET_RUNNER" \
BINDGEN_EXTRA_CLANG_ARGS_asmjs_unknown_emscripten="--sysroot=$CROSS_SYSROOT" \
CMAKE_TOOLCHAIN_FILE_asmjs_unknown_emscripten=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
================================================
FILE: docker/Dockerfile.cross
================================================
FROM ubuntu:20.04 AS rust
ENV DEBIAN_FRONTEND=noninteractive
COPY docker/lib.sh docker/cross.sh /
COPY ./ /project
RUN /cross.sh /project
# we build our images in 2 steps, to ensure we have a compact
# image, since we want to add our current subdirectory
FROM ubuntu:20.04 AS base
COPY --from=rust /root/.cargo /root/.cargo
COPY --from=rust /root/.rustup /root/.rustup
# need some basic devtools, and requirements for docker
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
ca-certificates \
curl \
git
RUN curl -fsSL https://get.docker.com | sh
ENV CROSS_CONTAINER_IN_CONTAINER=1 \
PATH=/root/.cargo/bin:$PATH
================================================
FILE: docker/Dockerfile.i586-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-i686-linux-gnu \
gfortran-i686-linux-gnu \
libc6-dev-i386-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=i386 /deny-debian-packages.sh \
binutils \
binutils-i686-linux-gnu
COPY qemu.sh /
RUN /qemu.sh i386
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=i686-linux-gnu-
ENV CROSS_SYSROOT=/usr/i686-linux-gnu
ENV CROSS_TARGET_RUNNER="/qemu-runner i586"
ENV CARGO_TARGET_I586_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_I586_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i586_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i586_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i586_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_i586_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i586_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/i386-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m32 -march=pentium"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.i586-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY musl.sh /
RUN /musl.sh TARGET=i586-linux-musl
COPY qemu.sh /
RUN /qemu.sh i386
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=i586-linux-musl-
ENV CROSS_SYSROOT=/usr/local/i586-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT i386
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner i586"
ENV CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i586_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i586_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i586_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_i586_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i586_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m32 -march=pentium -Wl,-melf_i386"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.i686-linux-android
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
# We could supposedly directly run i686 binaries like we do for x86_64, but
# doing so generates an assertion failure:
# ... assertion failed: signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR
# ... src/libstd/sys/unix/mod.rs
# fatal runtime error: failed to initiate panic, error 5
#
# Running with qemu works as expected. it also ensures that're we're
# running on a CPU that only supports 32-bit x86 systems.
COPY qemu.sh /
RUN /qemu.sh i386
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh x86
COPY android-ndk.sh /
RUN /android-ndk.sh x86
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh x86
ENV CROSS_TOOLCHAIN_PREFIX=i686-linux-android-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh i386 i686-linux-android
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CROSS_TARGET_RUNNER="/android-runner i686"
ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_I686_LINUX_ANDROID_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"as \
CC_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_i686_linux_android="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_i686_linux_android=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i686_linux_android="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include/" \
LIBZ_SYS_STATIC=1 \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=i686 \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="--target=i686-linux-android -DANDROID -ffunction-sections -fdata-sections -fPIC --target=i686-linux-android"
================================================
FILE: docker/Dockerfile.i686-pc-windows-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN dpkg --add-architecture i386 && apt-get update && \
apt-get install --assume-yes --no-install-recommends libz-mingw-w64-dev
COPY wine.sh /
RUN /wine.sh
# Build mingw tools using dwarf exceptions
COPY mingw.sh /
RUN bash mingw.sh
# run-detectors are responsible for calling the correct interpreter for exe
# files. For some reason it does not work inside a docker container (it works
# fine in the host). So we replace the usual paths of run-detectors to run wine
# directly. This only affects the guest, we are not messing up with the host.
#
# See /usr/share/doc/binfmt-support/detectors
RUN mkdir -p /usr/lib/binfmt-support/ && \
rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \
ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \
ln -s /usr/bin/wine /usr/bin/run-detectors
COPY windows-entry.sh /
ENTRYPOINT ["/windows-entry.sh"]
COPY toolchain.cmake /opt/toolchain.cmake
# for why we always link with pthread support, see:
# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148
ENV CROSS_TOOLCHAIN_PREFIX=i686-w64-mingw32-
ENV CROSS_TOOLCHAIN_SUFFIX=-posix
ENV CROSS_SYSROOT=/usr/i686-w64-mingw32
ENV CROSS_TARGET_RUNNER="env -u CARGO_TARGET_I686_PC_WINDOWS_GNU_RUNNER wine"
ENV CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
CARGO_TARGET_I686_PC_WINDOWS_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i686_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i686_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
CXX_i686_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++"$CROSS_TOOLCHAIN_SUFFIX" \
CMAKE_TOOLCHAIN_FILE_i686_pc_windows_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i686_pc_windows_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
CROSS_CMAKE_SYSTEM_NAME=Windows \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -m32"
================================================
FILE: docker/Dockerfile.i686-unknown-freebsd
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN echo "export ARCH=i686" > /freebsd-arch.sh
COPY freebsd-common.sh /
COPY freebsd.sh /
RUN /freebsd.sh
COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh
ENV CROSS_TOOLCHAIN_PREFIX=i686-unknown-freebsd13-
ENV CROSS_SYSROOT=/usr/local/i686-unknown-freebsd13
COPY freebsd-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY toolchain.cmake /opt/toolchain.cmake
COPY freebsd-fetch-best-mirror.sh /
COPY freebsd-setup-packagesite.sh /
COPY freebsd-install-package.sh /
ENV CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
AR_i686_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i686_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i686_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_i686_unknown_freebsd=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i686_unknown_freebsd="--sysroot=$CROSS_SYSROOT" \
I686_UNKNOWN_FREEBSD_OPENSSL_DIR="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=FreeBSD \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=freebsd \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m32"
================================================
FILE: docker/Dockerfile.i686-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-i686-linux-gnu \
gfortran-i686-linux-gnu \
libc6-dev-i386-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=i386 /deny-debian-packages.sh \
binutils \
binutils-i686-linux-gnu
COPY qemu.sh /
RUN /qemu.sh i386 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh i686
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=i686-linux-gnu-
ENV CROSS_SYSROOT=/usr/i686-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner i686"
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i686_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i686_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i686_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_i686_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i686_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/i386-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m32 -march=i686"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.i686-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY musl.sh /
RUN /musl.sh TARGET=i686-linux-musl
COPY qemu.sh /
RUN /qemu.sh i386
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=i686-linux-musl-
ENV CROSS_SYSROOT=/usr/local/i686-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT i386
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner i686"
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_i686_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_i686_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_i686_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_i686_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_i686_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m32 -march=i686 -Wl,-melf_i386"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.loongarch64-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/loongarch64-unknown-linux-gnu.config /
RUN /crosstool-ng.sh loongarch64-unknown-linux-gnu.config 5
ENV PATH=/x-tools/loongarch64-unknown-linux-gnu/bin/:$PATH
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=loong64 /deny-debian-packages.sh
COPY qemu.sh /
RUN /qemu.sh loongarch64
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=loongarch64-unknown-linux-gnu-
ENV CROSS_SYSROOT=/x-tools/loongarch64-unknown-linux-gnu/loongarch64-unknown-linux-gnu/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner loongarch64"
ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_loongarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_loongarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_loongarch64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_loongarch64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_loongarch64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=loongarch64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN mv $CROSS_SYSROOT/lib/* $CROSS_SYSROOT/lib64/
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.loongarch64-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/loongarch64-unknown-linux-musl.config /
RUN /crosstool-ng.sh loongarch64-unknown-linux-musl.config 5
ENV PATH=/x-tools/loongarch64-unknown-linux-musl/bin/:$PATH
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=loong64 /deny-debian-packages.sh
COPY qemu.sh /
RUN /qemu.sh loongarch64
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV PATH=/x-tools/loongarch64-unknown-linux-musl/bin/:$PATH
ENV CROSS_TOOLCHAIN_PREFIX=loongarch64-unknown-linux-musl-
ENV CROSS_SYSROOT=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner loongarch64"
ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_loongarch64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_loongarch64_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_loongarch64_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=loongarch64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mips-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get install --assume-yes --no-install-recommends \
g++-mips-linux-gnu \
gfortran-mips-linux-gnu \
libc6-dev-mips-cross
COPY qemu.sh /
RUN /qemu.sh mips
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=mips-linux-gnu-
ENV CROSS_SYSROOT=/usr/mips-linux-gnu
ENV CROSS_TARGET_RUNNER="/qemu-runner mips"
ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/mips-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mips-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh mips
# this is a soft-float target for the mips32r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips_unknown_linux_musl.rs#L7
COPY musl.sh /
RUN /musl.sh \
TARGET=mips-linux-muslsf \
"COMMON_CONFIG += -with-arch=mips32r2"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=mips-linux-muslsf-
ENV CROSS_SYSROOT=/usr/local/mips-linux-muslsf
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT mips-sf
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner mips"
ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mips64-unknown-linux-gnuabi64
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-mips64-linux-gnuabi64 \
gfortran-mips64-linux-gnuabi64 \
libc6-dev-mips64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=mips64 /deny-debian-packages.sh \
binutils \
binutils-mips64-linux-gnuabi64
COPY qemu.sh /
RUN /qemu.sh mips64
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=mips64-linux-gnuabi64-
ENV CROSS_SYSROOT=/usr/mips64-linux-gnuabi64
ENV CROSS_TARGET_RUNNER="/qemu-runner mips64"
ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips64_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips64_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips64_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips64_unknown_linux_gnuabi64=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips64_unknown_linux_gnuabi64="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/mips64-linux-gnuabi64/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mips64-unknown-linux-muslabi64
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh mips64
# this is a hard-float target for the mips64r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips64_unknown_linux_muslabi64.rs#L7
COPY musl.sh /
RUN /musl.sh \
TARGET=mips64-linux-musl \
"COMMON_CONFIG += -with-arch=mips64r2"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=mips64-linux-musl-
ENV CROSS_SYSROOT=/usr/local/mips64-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT mips64
RUN mkdir -p $CROSS_SYSROOT/usr/lib64
# needed for the C/C++ runners
RUN ln -s $CROSS_SYSROOT/usr/lib/libc.so $CROSS_SYSROOT/usr/lib64/libc.so
RUN ln -s $CROSS_SYSROOT/usr/lib/libc.so.1 $CROSS_SYSROOT/usr/lib64/libc.so.1
COPY musl-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner mips64"
ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_MUSLABI64_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips64_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips64_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips64_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips64_unknown_linux_muslabi64=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips64_unknown_linux_muslabi64="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC" \
CROSS_BUILTINS_PATCHED_MINOR_VERSION=65
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mips64el-unknown-linux-gnuabi64
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-mips64el-linux-gnuabi64 \
gfortran-mips64el-linux-gnuabi64 \
libc6-dev-mips64el-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=mips64el /deny-debian-packages.sh \
binutils \
binutils-mips64el-linux-gnuabi64
COPY qemu.sh /
RUN /qemu.sh mips64el softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh mips64el
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=mips64el-linux-gnuabi64-
ENV CROSS_SYSROOT=/usr/mips64el-linux-gnuabi64
ENV CROSS_TARGET_RUNNER="/linux-runner mips64el"
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips64el_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips64el_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips64el_unknown_linux_gnuabi64="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips64el_unknown_linux_gnuabi64=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips64el_unknown_linux_gnuabi64="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/mips64el-linux-gnuabi64/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.mips64el-unknown-linux-muslabi64
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh mips64el
# this is a hard-float target for the mips64r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mips64el_unknown_linux_muslabi64.rs#L6
COPY musl.sh /
RUN /musl.sh \
TARGET=mips64el-linux-musl \
"COMMON_CONFIG += -with-arch=mips64r2"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=mips64el-linux-musl-
ENV CROSS_SYSROOT=/usr/local/mips64el-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT mips64el
RUN mkdir -p $CROSS_SYSROOT/usr/lib64
# needed for the C/C++ runners
RUN ln -s $CROSS_SYSROOT/usr/lib/libc.so $CROSS_SYSROOT/usr/lib64/libc.so
RUN ln -s $CROSS_SYSROOT/usr/lib/libc.so.1 $CROSS_SYSROOT/usr/lib64/libc.so.1
COPY musl-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner mips64el"
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_MUSLABI64_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mips64el_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mips64el_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mips64el_unknown_linux_muslabi64="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mips64el_unknown_linux_muslabi64=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mips64el_unknown_linux_muslabi64="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC" \
CROSS_BUILTINS_PATCHED_MINOR_VERSION=65
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.mipsel-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-mipsel-linux-gnu \
gfortran-mipsel-linux-gnu \
libc6-dev-mipsel-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=mipsel /deny-debian-packages.sh \
binutils \
binutils-mipsel-linux-gnu
COPY qemu.sh /
RUN /qemu.sh mipsel softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh mipsel
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=mipsel-linux-gnu-
ENV CROSS_SYSROOT=/usr/mipsel-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner mipsel"
ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mipsel_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mipsel_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mipsel_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mipsel_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mipsel_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/mipsel-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.mipsel-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh mipsel
# this is a soft-float target for the mips32r2 architecture
# https://github.com/rust-lang/rust/blob/75d3027fb5ce1af6712e4503c9574802212101bd/compiler/rustc_target/src/spec/mipsel_unknown_linux_musl.rs#L6
COPY musl.sh /
RUN /musl.sh \
TARGET=mipsel-linux-muslsf \
"COMMON_CONFIG += -with-arch=mips32r2"
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=mipsel-linux-muslsf-
ENV CROSS_SYSROOT=/usr/local/mipsel-linux-muslsf
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT mipsel-sf
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner mipsel"
ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_mipsel_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_mipsel_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_mipsel_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_mipsel_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_mipsel_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=mips \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.native
================================================
# This dockerfile is used when the target matches the images platform in `build-docker-image`
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG TARGETARCH
ARG TARGETVARIANT
ARG CROSS_TARGET_TRIPLE
COPY qemu.sh native-qemu.sh /
RUN /native-qemu.sh
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh native-linux-image.sh /
RUN /native-linux-image.sh
COPY linux-runner native-linux-runner base-runner.sh /
ENV CROSS_TARGETARCH=$TARGETARCH
ENV CROSS_TARGETVARIANT=$TARGETVARIANT
ENV CROSS_TOOLCHAIN_PREFIX=
ENV CROSS_SYSROOT=/
ENV CARGO_TARGET_${CROSS_TARGET_TRIPLE}_RUNNER="/native-linux-runner"
RUN sed -e "s#@DEFAULT_CROSS_TARGETARCH@#$CROSS_TARGETARCH#g" -i /native-linux-runner
RUN sed -e "s#@DEFAULT_CROSS_TARGETVARIANT@#$CROSS_TARGETVARIANT#g" -i /native-linux-runner
================================================
FILE: docker/Dockerfile.native.centos
================================================
FROM ubuntu:20.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETARCH
ARG TARGETVARIANT
ARG CROSS_TARGET_TRIPLE
COPY lib.sh /
COPY linux-image.sh native-linux-image.sh /
RUN /native-linux-image.sh
FROM centos:7
# From https://github.com/rust-lang/rust/blob/672e3aaf28ab1e5cbe80b3ff012cd3a8e4ef98af/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile#L9-L12
# CentOS 7 EOL is June 30, 2024, but the repos remain in the vault.
RUN sed -i /etc/yum.repos.d/*.repo -e 's!^mirrorlist!#mirrorlist!' \
-e 's!^#baseurl=http://mirror.centos.org/!baseurl=https://vault.centos.org/!'
RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
# these need to be present in **both** FROM sections
ARG TARGETARCH
ARG TARGETVARIANT
ARG CROSS_TARGET_TRIPLE
COPY qemu.sh native-qemu.sh /
RUN /native-qemu.sh
COPY dropbear.sh /
RUN /dropbear.sh
COPY --from=0 /qemu /qemu
COPY linux-runner native-linux-runner base-runner.sh /
ENV CROSS_TARGETARCH=$TARGETARCH
ENV CROSS_TARGETVARIANT=$TARGETVARIANT
ENV CROSS_TOOLCHAIN_PREFIX=
ENV CROSS_SYSROOT=/
ENV CARGO_TARGET_${CROSS_TARGET_TRIPLE}_RUNNER="/native-linux-runner"
RUN sed -e "s#@DEFAULT_CROSS_TARGETARCH@#$CROSS_TARGETARCH#g" -i /native-linux-runner
RUN sed -e "s#@DEFAULT_CROSS_TARGETVARIANT@#$CROSS_TARGETVARIANT#g" -i /native-linux-runner
================================================
FILE: docker/Dockerfile.powerpc-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-powerpc-linux-gnu \
gfortran-powerpc-linux-gnu \
libc6-dev-powerpc-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=powerpc /deny-debian-packages.sh \
binutils \
binutils-powerpc-linux-gnu
COPY qemu.sh /
RUN /qemu.sh ppc softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh powerpc
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=powerpc-linux-gnu-
ENV CROSS_SYSROOT=/usr/powerpc-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner powerpc"
ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_powerpc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_powerpc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_powerpc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_powerpc_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_powerpc_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/powerpc-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=ppc \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.powerpc64-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-powerpc64-linux-gnu \
gfortran-powerpc64-linux-gnu \
libc6-dev-ppc64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=ppc64 /deny-debian-packages.sh \
binutils \
binutils-powerpc64-linux-gnu
COPY qemu.sh /
RUN /qemu.sh ppc64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh powerpc64
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=powerpc64-linux-gnu-
ENV CROSS_SYSROOT=/usr/powerpc64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner powerpc64"
ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_powerpc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_powerpc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_powerpc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_powerpc64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_powerpc64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/powerpc64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=ppc64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.powerpc64le-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-powerpc64le-linux-gnu \
gfortran-powerpc64le-linux-gnu \
libc6-dev-ppc64el-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=ppc64el /deny-debian-packages.sh \
binutils \
binutils-powerpc64le-linux-gnu
COPY qemu.sh /
RUN /qemu.sh ppc64le softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh powerpc64le
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=powerpc64le-linux-gnu-
ENV CROSS_SYSROOT=/usr/powerpc64le-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner powerpc64le"
ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_powerpc64le_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_powerpc64le_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_powerpc64le_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_powerpc64le_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_powerpc64le_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/powerpc64le-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=ppc64le \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.riscv64gc-unknown-linux-gnu
================================================
FROM ubuntu:22.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install -y --no-install-recommends \
g++-riscv64-linux-gnu \
gfortran-riscv64-linux-gnu \
libc6-dev-riscv64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=riscv64 /deny-debian-packages.sh \
binutils \
binutils-riscv64-linux-gnu
COPY qemu.sh /
RUN /qemu.sh riscv64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh riscv64
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=riscv64-linux-gnu-
ENV CROSS_SYSROOT=/usr/riscv64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner riscv64"
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_riscv64gc_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=riscv64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -mcmodel=medany"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.riscv64gc-unknown-linux-musl
================================================
FROM ubuntu:24.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
adduser
ARG VERBOSE
COPY crosstool-ng.sh /
COPY crosstool-config/riscv64gc-unknown-linux-musl.config /
RUN /crosstool-ng.sh riscv64gc-unknown-linux-musl.config 5
ENV PATH=/x-tools/riscv64-unknown-linux-musl/bin/:$PATH
COPY qemu.sh /
RUN /qemu.sh riscv64
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV PATH=/x-tools/riscv64-unknown-linux-musl/bin/:$PATH
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=riscv64-unknown-linux-musl-
ENV CROSS_SYSROOT=/x-tools/riscv64-unknown-linux-musl/riscv64-unknown-linux-musl/sysroot/
ENV CROSS_TARGET_RUNNER="/qemu-runner riscv64"
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_riscv64gc_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_riscv64gc_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=riscv64gc \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -mcmodel=medany"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.s390x-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-s390x-linux-gnu \
gfortran-s390x-linux-gnu \
libc6-dev-s390x-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=s390x /deny-debian-packages.sh \
binutils \
binutils-s390x-linux-gnu
COPY qemu.sh /
RUN /qemu.sh s390x softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh s390x
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=s390x-linux-gnu-
ENV CROSS_SYSROOT=/usr/s390x-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner s390x"
ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_s390x_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_s390x_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_s390x_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_s390x_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_s390x_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/s390x-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=s390x \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.sparc64-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-sparc64-linux-gnu \
gfortran-sparc64-linux-gnu \
libc6-dev-sparc64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=sparc64 /deny-debian-packages.sh \
binutils \
binutils-sparc64-linux-gnu
COPY qemu.sh /
RUN /qemu.sh sparc64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh sparc64
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=sparc64-linux-gnu-
ENV CROSS_SYSROOT=/usr/sparc64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner sparc64"
ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_sparc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_sparc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_sparc64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_sparc64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_sparc64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/sparc64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=sparc64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.sparcv9-sun-solaris
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY solaris.sh /
RUN /solaris.sh sparcv9 sun
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=sparcv9-sun-solaris2.10-
ENV CROSS_SYSROOT=/usr/local/sparcv9-sun-solaris2.10
ENV CARGO_TARGET_SPARCV9_SUN_SOLARIS_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_sparcv9_sun_solaris="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_sparcv9_sun_solaris="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_sparcv9_sun_solaris="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_sparcv9_sun_solaris=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_sparcv9_sun_solaris="--sysroot=$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=SunOS \
CROSS_CMAKE_SYSTEM_PROCESSOR=sparc64 \
CROSS_CMAKE_CRT=solaris \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC"
================================================
FILE: docker/Dockerfile.thumbv6m-none-eabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m1 \
AR_thumbv6m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv6m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv6m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_thumbv6m_none_eabi=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv6-m \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -march=armv6s-m"
================================================
FILE: docker/Dockerfile.thumbv7em-none-eabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m4 \
AR_thumbv7em_none_eabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv7em_none_eabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv7em_none_eabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_thumbv7em_none_eabi=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV7EM_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv7e-m \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -march=armv7e-m"
================================================
FILE: docker/Dockerfile.thumbv7em-none-eabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m4 \
AR_thumbv7em_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv7em_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv7em_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_thumbv7em_none_eabihf=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV7EM_NONE_EABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv7e-m \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -mfloat-abi=hard -march=armv7e-m -mfpu=fpv4-sp-d16"
================================================
FILE: docker/Dockerfile.thumbv7m-none-eabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m3 \
AR_thumbv7m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv7m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv7m_none_eabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_thumbv7m_none_eabi=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv7-m \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -march=armv7-m"
================================================
FILE: docker/Dockerfile.thumbv7neon-linux-androideabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY qemu.sh /
RUN /qemu.sh arm
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh arm
COPY android-ndk.sh /
RUN /android-ndk.sh arm
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh arm
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-androideabi-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh arm arm-linux-androideabi
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
# likewise, the toolchains expect the prefix `thumbv7neon-linux-androideabi`,
# which we don't have, so just export every possible variable, such as AR.
# Also export all target binutils just in case required.
ENV CROSS_TARGET_RUNNER="/android-runner arm"
ENV CARGO_TARGET_THUMBV7NEON_LINUX_ANDROIDEABI_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_THUMBV7NEON_LINUX_ANDROIDEABI_RUNNER="$CROSS_TARGET_RUNNER" \
AR_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"as \
CC_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_thumbv7neon_linux_androideabi="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_thumbv7neon_linux_androideabi=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_thumbv7neon_linux_androideabi="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include/" \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=armv7-a \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="--target=arm-linux-androideabi -DANDROID -ffunction-sections -fdata-sections -fPIC --target=thumbv7neon-linux-androideabi"
================================================
FILE: docker/Dockerfile.thumbv7neon-unknown-linux-gnueabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-arm-linux-gnueabihf \
gfortran-arm-linux-gnueabihf \
libc6-dev-armhf-cross
COPY qemu.sh /
RUN /qemu.sh arm softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh armv7
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
# Export all target binutils just in case required.
ENV CROSS_TOOLCHAIN_PREFIX=arm-linux-gnueabihf-
ENV CROSS_SYSROOT=/usr/arm-linux-gnueabihf
ENV CROSS_TARGET_RUNNER="/linux-runner armv7hf"
ENV CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$CROSS_TARGET_RUNNER" \
AR_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"as \
CC_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_thumbv7neon_unknown_linux_gnueabihf="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_thumbv7neon_unknown_linux_gnueabihf=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_thumbv7neon_unknown_linux_gnueabihf="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=arm \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -march=armv7-a -mfpu=vfpv3-d16 -mfpu=neon-vfpv4 -mthumb -mfloat-abi=hard"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.thumbv8m.base-none-eabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m23 \
AR_thumbv8m.base_none_eabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv8m.base_none_eabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv8m.base_none_eabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
# cmake-rs does not accept CMAKE_TOOLCHAIN_FILE_thumbv8m.base_none_eabi
TARGET_CMAKE_TOOLCHAIN_FILE=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV8M.BASE_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR="armv8-m.base" \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -march=armv8-m.base"
================================================
FILE: docker/Dockerfile.thumbv8m.main-none-eabi
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m33 \
AR_thumbv8m.main_none_eabi="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv8m.main_none_eabi="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv8m.main_none_eabi="$CROSS_TOOLCHAIN_PREFIX"g++ \
# cmake-rs does not accept CMAKE_TOOLCHAIN_FILE_thumbv8m.main_none_eabi
TARGET_CMAKE_TOOLCHAIN_FILE=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV8M.BASE_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR="armv8-m.main" \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -march=armv8-m.main"
================================================
FILE: docker/Dockerfile.thumbv8m.main-none-eabihf
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
libstdc++-arm-none-eabi-newlib
COPY qemu.sh /
RUN /qemu.sh arm
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=arm-none-eabi-
ENV CROSS_SYSROOT="/usr/lib/arm-none-eabi"
ENV CROSS_TARGET_RUNNER=qemu-arm
ENV QEMU_CPU=cortex-m33 \
AR_thumbv8m.main_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_thumbv8m.main_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_thumbv8m.main_none_eabihf="$CROSS_TOOLCHAIN_PREFIX"g++ \
# cmake-rs does not accept CMAKE_TOOLCHAIN_FILE_thumbv8m.main_none_eabihf
TARGET_CMAKE_TOOLCHAIN_FILE=/opt/toolchain.cmake \
CARGO_TARGET_THUMBV8M.BASE_NONE_EABI_RUNNER="$CROSS_TARGET_RUNNER" \
CROSS_CMAKE_SYSTEM_NAME=Generic \
CROSS_CMAKE_SYSTEM_PROCESSOR="armv8-m.main" \
CROSS_CMAKE_CRT=newlib \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -mthumb -mfloat-abi=hard -march=armv8-m.main -mfpu=fpv5-sp-d16"
================================================
FILE: docker/Dockerfile.wasm32-unknown-emscripten
================================================
FROM emscripten/emsdk:3.1.14
WORKDIR /
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
libxml2 \
python
ENV CROSS_TOOLCHAIN_PREFIX=em
ENV CROSS_SYSROOT=/emsdk/upstream/emscripten/cache/sysroot
ENV CROSS_TARGET_RUNNER="node"
ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER="$CROSS_TARGET_RUNNER" \
BINDGEN_EXTRA_CLANG_ARGS_wasm32_unknown_emscripten="--sysroot=$CROSS_SYSROOT" \
CMAKE_TOOLCHAIN_FILE_wasm32_unknown_emscripten=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
================================================
FILE: docker/Dockerfile.x86_64-linux-android
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
# Using qemu allows older host cpus (without sse4) to execute the target binaries
COPY qemu.sh /
RUN /qemu.sh x86_64
ARG ANDROID_NDK=r25b
ARG ANDROID_SDK=28
ARG ANDROID_VERSION=9.0.0_r1
ARG ANDROID_SYSTEM_NONE=0
ARG ANDROID_SYSTEM_COMPLETE=0
ARG PYTHON_TMPDIR=/tmp/android
COPY validate-android-args.sh /
RUN /validate-android-args.sh x86_64
COPY android-ndk.sh /
RUN /android-ndk.sh x86_64
ENV PATH=$PATH:/android-ndk/bin
COPY android-system.sh /
RUN mkdir -p $PYTHON_TMPDIR
COPY android $PYTHON_TMPDIR
RUN /android-system.sh x86_64
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-linux-android-
ENV CROSS_SYSROOT=/android-ndk/sysroot
ENV CROSS_ANDROID_SDK=$ANDROID_SDK
COPY android-symlink.sh /
RUN /android-symlink.sh x86_64 x86_64-linux-android
COPY android-runner /
COPY android.cmake /opt/toolchain.cmake
# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CROSS_TARGET_RUNNER="/android-runner x86_64"
ENV CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_X86_64_LINUX_ANDROID_RUNNER="$CROSS_TARGET_RUNNER" \
AR_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ar \
AS_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"as \
CC_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"g++ \
LD_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ld \
NM_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"nm \
OBJCOPY_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"objcopy \
OBJDUMP_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"objdump \
RANLIB_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"ranlib \
READELF_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"readelf \
SIZE_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"size \
STRINGS_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strings \
STRIP_x86_64_linux_android="$CROSS_TOOLCHAIN_PREFIX"strip \
CMAKE_TOOLCHAIN_FILE_x86_64_linux_android=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_linux_android="--sysroot=$CROSS_SYSROOT" \
DEP_Z_INCLUDE="$CROSS_SYSROOT/usr/include/" \
RUST_TEST_THREADS=1 \
HOME=/tmp/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system \
CROSS_CMAKE_SYSTEM_NAME=Android \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=android \
CROSS_CMAKE_OBJECT_FLAGS="--target=x86_64-linux-android -DANDROID -ffunction-sections -fdata-sections -fPIC --target=x86_64-linux-android"
================================================
FILE: docker/Dockerfile.x86_64-pc-solaris
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY solaris.sh /
RUN /solaris.sh x86_64 pc
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-pc-solaris2.10-
ENV CROSS_SYSROOT=/usr/local/x86_64-pc-solaris2.10
ENV CARGO_TARGET_X86_64_PC_SOLARIS_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_x86_64_pc_solaris="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_pc_solaris="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_pc_solaris="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_pc_solaris=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_solaris="--sysroot=$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=SunOS \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=solaris \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.x86_64-pc-windows-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN dpkg --add-architecture i386 && apt-get update && \
apt-get install --assume-yes --no-install-recommends libz-mingw-w64-dev
COPY wine.sh /
RUN /wine.sh
RUN apt-get update && apt-get install --assume-yes --no-install-recommends g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64
# run-detectors are responsible for calling the correct interpreter for exe
# files. For some reason it does not work inside a docker container (it works
# fine in the host). So we replace the usual paths of run-detectors to run wine
# directly. This only affects the guest, we are not messing up with the host.
#
# See /usr/share/doc/binfmt-support/detectors
RUN mkdir -p /usr/lib/binfmt-support/ && \
rm -f /usr/lib/binfmt-support/run-detectors /usr/bin/run-detectors && \
ln -s /usr/bin/wine /usr/lib/binfmt-support/run-detectors && \
ln -s /usr/bin/wine /usr/bin/run-detectors
COPY windows-entry.sh /
ENTRYPOINT ["/windows-entry.sh"]
COPY toolchain.cmake /opt/toolchain.cmake
# for why we always link with pthread support, see:
# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-w64-mingw32-
ENV CROSS_TOOLCHAIN_SUFFIX=-posix
ENV CROSS_SYSROOT=/usr/x86_64-w64-mingw32
ENV CROSS_TARGET_RUNNER="env -u CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER wine"
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc"$CROSS_TOOLCHAIN_SUFFIX" \
CXX_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++"$CROSS_TOOLCHAIN_SUFFIX" \
CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
CROSS_CMAKE_SYSTEM_NAME=Windows \
CROSS_CMAKE_SYSTEM_PROCESSOR=AMD64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -m64"
================================================
FILE: docker/Dockerfile.x86_64-unknown-dragonfly
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY dragonfly.sh /
RUN /dragonfly.sh 5
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-unknown-dragonfly-
ENV CROSS_SYSROOT=/usr/local/x86_64-unknown-dragonfly
ENV CARGO_TARGET_X86_64_UNKNOWN_DRAGONFLY_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_x86_64_unknown_dragonfly="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_dragonfly="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_dragonfly="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_dragonfly=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_dragonfly="--sysroot=$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=DragonFly \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=dragonfly \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.x86_64-unknown-freebsd
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN echo "export ARCH=x86_64" > /freebsd-arch.sh
COPY freebsd-common.sh /
COPY freebsd.sh /
RUN /freebsd.sh
COPY freebsd-install.sh /
COPY freebsd-extras.sh /
RUN /freebsd-extras.sh
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-unknown-freebsd13-
ENV CROSS_SYSROOT=/usr/local/x86_64-unknown-freebsd13
COPY freebsd-gcc.sh /usr/bin/"$CROSS_TOOLCHAIN_PREFIX"gcc.sh
COPY toolchain.cmake /opt/toolchain.cmake
COPY freebsd-fetch-best-mirror.sh /
COPY freebsd-setup-packagesite.sh /
COPY freebsd-install-package.sh /
ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc.sh \
AR_x86_64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_freebsd="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_freebsd=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_freebsd="--sysroot=$CROSS_SYSROOT" \
X86_64_UNKNOWN_FREEBSD_OPENSSL_DIR="$CROSS_SYSROOT" \
PKG_CONFIG_PATH="${CROSS_SYSROOT}/libdata/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=FreeBSD \
CROSS_CMAKE_SYSTEM_PROCESSOR=amd64 \
CROSS_CMAKE_CRT=freebsd \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.x86_64-unknown-illumos
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY illumos.sh /
RUN /illumos.sh x86_64
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-unknown-illumos-
ENV CROSS_SYSROOT=/usr/local/x86_64-unknown-illumos/sysroot
ENV PATH=$PATH:/usr/local/x86_64-unknown-illumos/bin/ \
CARGO_TARGET_X86_64_UNKNOWN_ILLUMOS_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_x86_64_unknown_illumos="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_illumos="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_illumos="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_illumos=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_illumos="--sysroot=$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=illumos \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=solaris \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.x86_64-unknown-linux-gnu
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
g++-x86-64-linux-gnu \
gfortran-x86-64-linux-gnu \
libc6-dev-amd64-cross
COPY deny-debian-packages.sh /
RUN TARGET_ARCH=amd64 /deny-debian-packages.sh \
binutils \
binutils-x86-64-linux-gnu
COPY qemu.sh /
RUN /qemu.sh x86_64 softmmu
COPY dropbear.sh /
RUN /dropbear.sh
COPY linux-image.sh /
RUN /linux-image.sh x86_64
COPY linux-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-linux-gnu-
ENV CROSS_SYSROOT=/usr/x86_64-linux-gnu
ENV CROSS_TARGET_RUNNER="/linux-runner x86_64"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="$CROSS_TARGET_RUNNER" \
AR_x86_64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT -idirafter/usr/include" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}" \
PKG_CONFIG_ALLOW_CROSS=1 \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=gnu \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /linux-runner
================================================
FILE: docker/Dockerfile.x86_64-unknown-linux-gnu.centos
================================================
# HACK: this file is currently never used and only exists for usage with `Dockerfile.native.centos`
# it will be supported for aarch64 hosts, see #751 and #975
FROM ubuntu:20.04 AS base
================================================
FILE: docker/Dockerfile.x86_64-unknown-linux-musl
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY musl.sh /
RUN /musl.sh TARGET=x86_64-linux-musl
COPY qemu.sh /
RUN /qemu.sh x86_64
COPY tidyup.sh /
RUN /tidyup.sh
FROM scratch AS final
COPY --from=build / /
CMD ["/bin/bash"]
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-linux-musl-
ENV CROSS_SYSROOT=/usr/local/x86_64-linux-musl
COPY musl-symlink.sh /
RUN /musl-symlink.sh $CROSS_SYSROOT x86_64
COPY qemu-runner base-runner.sh /
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TARGET_RUNNER="/qemu-runner x86_64"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER="$CROSS_TARGET_RUNNER" \
AR_x86_64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_linux_musl="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_musl=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_musl="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=Linux \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=musl \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
RUN sed -e "s#@DEFAULT_QEMU_LD_PREFIX@#$QEMU_LD_PREFIX#g" -i /qemu-runner
================================================
FILE: docker/Dockerfile.x86_64-unknown-netbsd
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
COPY netbsd.sh /
RUN /netbsd.sh
COPY toolchain.cmake /opt/toolchain.cmake
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-unknown-netbsd-
ENV CROSS_SYSROOT=/usr/local/x86_64-unknown-netbsd
ENV CARGO_TARGET_X86_64_UNKNOWN_NETBSD_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_x86_64_unknown_netbsd="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_x86_64_unknown_netbsd="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_x86_64_unknown_netbsd="$CROSS_TOOLCHAIN_PREFIX"g++ \
CMAKE_TOOLCHAIN_FILE_x86_64_unknown_netbsd=/opt/toolchain.cmake \
BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_netbsd="--sysroot=$CROSS_SYSROOT" \
CROSS_CMAKE_SYSTEM_NAME=NetBSD \
CROSS_CMAKE_SYSTEM_PROCESSOR=x86_64 \
CROSS_CMAKE_CRT=netbsd \
CROSS_CMAKE_OBJECT_FLAGS="-ffunction-sections -fdata-sections -fPIC -m64"
================================================
FILE: docker/Dockerfile.zig
================================================
FROM ubuntu:20.04 AS cross-base
ENV DEBIAN_FRONTEND=noninteractive
COPY common.sh lib.sh /
RUN /common.sh
COPY cmake.sh /
RUN /cmake.sh
FROM cross-base AS build
ARG TARGETPLATFORM
COPY zig.sh /
RUN /zig.sh $TARGETPLATFORM
# we don't export `BINDGEN_EXTRA_CLANG_ARGS`, `QEMU_LD_PREFIX`, or
# `PKG_CONFIG_PATH` since zig doesn't have a traditional sysroot structure,
# and we're not using standard, shared packages. none of the packages
# have runners either, since they do not ship with the required
# dynamic linker (`ld-linux-${arch}.so`).
ENV PATH=$PATH:/opt/zig
================================================
FILE: docker/aarch64-linux-gnu-glibc.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
unpack_rpm() {
local package="${1}"
curl --retry 3 "https://vault.centos.org/altarch/7/os/aarch64/Packages/${package}" -O
rpm2cpio "${package}" | cpio -idmv
}
symlink_gcc_lib() {
local prefix="${1}"
shift
local srcfile="${1}"
shift
local dstdir="/usr/lib/gcc/aarch64-linux-gnu"
ln -s "${prefix}/lib/${srcfile}" "${dstdir}/4.8.2/${srcfile}"
ln -s "${prefix}/lib/${srcfile}" "${dstdir}/4.8.5/${srcfile}"
local dstfile
for dstfile in "${@}"; do
ln -s "${prefix}/lib/${srcfile}" "${dstdir}/4.8.2/${dstfile}"
ln -s "${prefix}/lib/${srcfile}" "${dstdir}/4.8.5/${dstfile}"
done
}
cp_gcc_archive() {
local name="${1}"
local srcdir="usr/lib/gcc/aarch64-redhat-linux/"
local dstdir="/usr/lib/gcc/aarch64-linux-gnu/"
cp "${srcdir}/4.8.2/${name}" "${dstdir}/4.8.2/${name}"
cp "${srcdir}/4.8.5/${name}" "${dstdir}/4.8.5/${name}"
}
main() {
set_centos_ulimit
yum install -y epel-release
yum install -y gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu gfortran-c++-aarch64-linux-gnu binutils-aarch64-linux-gnu binutils gcc-c++ glibc-devel
yum clean all
local td
td="$(mktemp -d)"
pushd "${td}"
local target=aarch64-linux-gnu
local prefix="/usr/${target}"
local kernel_v4="4.18.20"
curl --retry 3 "https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-${kernel_v4}.tar.xz" -O
tar -xvf "linux-${kernel_v4}.tar.xz"
pushd "linux-${kernel_v4}"
make ARCH=arm64 INSTALL_HDR_PATH="${prefix}" headers_install
popd
curl --retry 3 http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.xz -O
tar -xvf glibc-2.17.tar.xz
mkdir build
pushd build
CC=/usr/bin/aarch64-linux-gnu-gcc \
CXX=/usr/bin/aarch64-linux-gnu-g++ \
LD=/usr/bin/aarch64-linux-gnu-ld \
AR=/usr/bin/aarch64-linux-gnu-ar \
RANLIB=/usr/bin/aarch64-linux-gnu-ranlib \
../glibc-2.17/configure \
--prefix="${prefix}" \
--build="${MACHTYPE}" \
--host="${target}" \
--target="${target}" \
--with-arch=aarch64 \
--with-headers="${prefix}/include" \
--libdir="${prefix}/lib" \
--libexecdir="${prefix}/lib"
make -j && make install
popd
mkdir -p "${prefix}"/{include,lib}
mkdir -p "/usr/lib/gcc/aarch64-linux-gnu"/{4.8.2,4.8.5}
mkdir libgcc
pushd libgcc
unpack_rpm "libgcc-4.8.5-44.el7.aarch64.rpm"
mv lib64/* "${prefix}/lib"
# C++ support needs `libgcc.so`, even though it warns about `libgcc_s.so`
symlink_gcc_lib "${prefix}" "libgcc_s.so.1" "libgcc_s.so" "libgcc.so"
popd
mkdir libstdcpp
pushd libstdcpp
unpack_rpm "libstdc++-4.8.5-44.el7.aarch64.rpm"
unpack_rpm "libstdc++-devel-4.8.5-44.el7.aarch64.rpm"
unpack_rpm "libstdc++-static-4.8.5-44.el7.aarch64.rpm"
mv usr/include/* "${prefix}/include"
mv usr/lib64/* "${prefix}/lib"
symlink_gcc_lib "${prefix}" "libstdc++.so.6" "libstdc++.so"
cp_gcc_archive "libstdc++.a"
cp_gcc_archive "libsupc++.a"
popd
local cpp_include=/usr/aarch64-linux-gnu/include/c++
local cpp_482="${cpp_include}/4.8.2"
local cpp_485="${cpp_include}/4.8.5"
local redhat_482="${cpp_482}/aarch64-redhat-linux"
local redhat_485="${cpp_485}/aarch64-redhat-linux"
mv "${redhat_482}/bits"/* "${cpp_482}/bits"
mv "${redhat_482}/ext"/* "${cpp_482}/ext"
# these are currently empty, but might contain content later
mv "${redhat_485}/bits"/* "${cpp_485}/bits" || true
mv "${redhat_485}/ext"/* "${cpp_485}/ext" || true
popd
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/android/README.md
================================================
android
=======
Utilities for working with the Android project, particularly, for modifying and working with the Android build system. This facilitates modifying both Soong and Make build files, to remove unittests to speed up builds and minimize the number of dependencies.
================================================
FILE: docker/android/android/__init__.py
================================================
import sys
# we run this script once every build, and we'd rather
# have much smaller image sizes, so copying without
# any bytecode is a better idea.
sys.dont_write_bytecode = True
__version__ = '0.0.0-dev.0'
__version_info__ = (0, 0, 0, 'dev.0')
__license__ = 'MIT OR Apache-2.0'
__all__ = [
"make",
"soong",
]
================================================
FILE: docker/android/android/make.py
================================================
'''
make
====
utilities to process makefiles. this parser is not sophisticated
nor correct, but it tries to avoid a few common pitfalls by
handling conditional blocks, and first separating all conditional
blocks into sections, and then parsing comment blocks within those
sections.
validate conditional directives are:
- ifeq
- ifneq
- ifdef
- ifndef
- else
- endif
makefiles are whitespace-sensitive, but not with leading whitespace
for conditional directives. for example, this is valid (replacing the
spaces with tabs):
# ---------------
# Section 1.
# ---------------
ifneq ($(USE_A),)
# -----------
# Section 2.
# -----------
ifneq ($(USE_B),)
SOURCES=b.cc
else
SOURCES=a.cc
endif
else
SOURCES=c.cc
endif
our goals are fairly different from a regular parser: we want to detect
and excise sections based on the comments, while ensuring that we do
not produce invalid output. other than unbalanced conditional directives,
we do not actually care about the actual contents.
for this, we use a 3 step parsing approach:
1. break up document into blocks separated by directives
- each block can be a regular or directive block
- directive blocks have a start and end directive as well as contents
- directives can be infinitely nested: the contents can also be a list
2. break each text block based on comment sections
3. group blocks within comment sections
for example, in the above, we want the entire makefile to be inside the
section 1 comment block, so removing it would remove that whole tree.
similarly, the inner directive block should be inside the section 2
comment block. we would therefore produce something like this:
CommentBlock: Section 1
Directive Block:
start=ifneq ($(USE_A),)
end=endif
children:
CommentBlock: Section 2
Directive Block:
start=ifneq ($(USE_B),)
end=endif
children:
Block: `SOURCES=b.cc\nelse\nSOURCES=a.cc`
Block: `else\nSOURCES=c.cc`
'''
import re2 as re
from . import util
def loads(contents, *_, **__):
return Makefile.loads(contents)
def load(fp, *_, **__):
return Makefile.load(fp)
def dumps(makefile, *_, **__):
return makefile.dumps()
def dump(makefile, fp, *_, **__):
return makefile.dump(fp)
class Makefile(list):
@staticmethod
def loads(contents, *_, **__):
directives = _split_directives(iter(contents.splitlines()))[0]
blocks = directives.split_comments()
blocks.group_comments()
return Makefile(blocks)
@staticmethod
def load(fp, *_, **__):
return Makefile.loads(fp.read())
def dumps(self, *_, **__):
return str(self)
def dump(self, fp, *_, **__):
fp.write(self.dumps() + '\n')
def filter(self, op):
return _filter_list(self, op)
def recurse(self, max_depth=-1, depth=0):
yield from _recurse_list(self, max_depth, depth)
def __repr__(self):
return f'Makefile({str(self)})'
def __str__(self):
return '\n'.join([str(i) for i in self])
class Node:
def is_block(self):
return False
def is_block_list(self):
return False
def is_comment(self):
return False
def is_directive(self):
return False
def is_test(self):
return False
def is_benchmark(self):
return False
def is_dev(self):
return self.is_test() or self.is_benchmark()
def has_block_list(self):
return False
def filter(self, op):
raise NotImplementedError
def recurse(self, max_depth=-1, depth=0):
raise NotImplementedError
class Block(str, Node):
@property
def child(self):
return str(self)
def __repr__(self):
return f'Block({str(self)})'
def __str__(self):
return super().__str__()
def is_block(self):
return True
def split_comments(self):
return _split_comments(str(self))
def group_comments(self):
pass
def filter(self, op):
return op(self)
class BlockList(list, Node):
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
assert all([isinstance(i, Node) for i in self])
@property
def child(self):
return self
def __repr__(self):
return f'BlockList({str(self)})'
def __str__(self):
return '\n'.join([str(i) for i in self])
def is_block_list(self):
return True
def split_comments(self):
return BlockList(util.flatten([i.split_comments() for i in self]))
def group_comments(self):
self[:] = _group_comments(self)
def filter(self, op):
return _filter_list(self, op)
def recurse(self, max_depth=-1, depth=0):
yield from _recurse_list(self, max_depth, depth)
class CommentBlock(Node):
# the child is either a Block or BlockList
def __init__(self, comment, title, child):
assert isinstance(child, Node)
self.comment = comment
self.title = title
self.child = child
def __eq__(self, other):
return (self.comment, self.title, self.child) == (other.comment, other.title, other.child)
def __repr__(self):
return f'CommentBlock({str(self)})'
def __str__(self):
return f'{self.comment}\n{str(self.child)}'
def is_comment(self):
return True
def is_test(self):
return self.title is not None and util.is_test(self.title)
def is_benchmark(self):
return self.title is not None and util.is_benchmark(self.title)
def has_block_list(self):
return self.child.is_block_list()
def split_comments(self):
raise NotImplementedError('cannot split comments in split comment block')
def group_comments(self):
raise NotImplementedError('grouping comments should be done outside a comment block')
def flatten_single(self):
if isinstance(self.child, list) and len(self.child) == 1:
self.child = self.child[0]
def filter(self, op):
return op(self) and self.child.filter(op)
class DirectiveBlock(Node):
# the child is either a Block or BlockList
def __init__(self, start, end, child):
assert isinstance(child, Node)
if isinstance(child, list) and len(child) == 1:
child = child[0]
self.start = start
self.end = end
self.child = child
def __eq__(self, other):
return (self.start, self.end, self.child) == (other.start, other.end, other.child)
def __repr__(self):
return f'DirectiveBlock({str(self)})'
def __str__(self):
result = f'{self.start}\n{str(self.child)}'
if self.end is not None:
result += f'\n{self.end}'
return result
def is_directive(self):
return True
def has_block_list(self):
return self.child.is_block_list()
def split_comments(self):
child = self.child.split_comments()
# every caller expects a list, so we return a single-element list
return BlockList([DirectiveBlock(self.start, self.end, child)])
def group_comments(self):
self.child.group_comments()
self.flatten_single()
def flatten_single(self):
if isinstance(self.child, list) and len(self.child) == 1:
self.child = self.child[0]
def filter(self, op):
return op(self) and self.child.filter(op)
# split on comment sections, for example the below will split on the
# benchmarks section.
#
# LOCAL_PATH := $(call my-dir)
#
# # -----------------------------------------------------------------------------
# # Benchmarks.
# # -----------------------------------------------------------------------------
#
# test_tags := tests
def _split_comments(contents):
def new_comment(match, nxt=None):
comment = match.group(1)
groups = match.groups()[1:]
lines = [i for i in groups if i is not None]
title = '\n'.join([re.sub(r'[ \t]*#[ \t]*', '', i) for i in lines])
if nxt is None:
data = contents[match.end():]
else:
data = contents[match.end():nxt.start()]
if nxt is not None:
assert data.endswith('\n')
data = data[:-1]
return CommentBlock(comment, title, Block(data))
# if we just have 1 or 2 characters, can falsely match.
# headers can be `# -----`, `# ======`, or `########`.
# the title can be prefixed, suffixed, or sandwiched by the header.
def title_pattern():
line = fr'{sp}*#{sp}*{comment}'
return fr'(?:(?:{line}{nl})*{line})'
def sandwich_pattern(sep):
# matches header-title-header
title = title_pattern()
return fr'{sp}*{sep}{nl}({title}){nl}{sp}*{sep}'
def suffix_pattern(sep):
# matches title-header
title = title_pattern()
return fr'({title}){nl}{sp}*{sep}'
def prefix_pattern(sep):
# matches header-title, needs to be last due to greedy regex
title = title_pattern()
return fr'{sp}*{sep}{nl}({title})'
def sep_pattern(sep):
sandwich = sandwich_pattern(sep)
suffix = suffix_pattern(sep)
prefix = prefix_pattern(sep)
return fr'(?:{sandwich})|(?:{prefix})|(?:{suffix})'
def create_pattern(*seps):
groups = []
for sep in seps:
groups.append(fr'(?:{sep_pattern(sep)})')
return fr'(?m)^({"|".join(groups)}){nl}?'
sep1 = r'#\s+={5,}'
sep2 = r'#\s+-{5,}'
sep3 = r'#{6,}'
sp = r'[ \t]'
nl = r'(?:\r\n|\r|\n)'
# can have empty headers, such as `#####\n#`
comment = r'[^\x00-\x08\x0A-\x1F]*'
pattern = create_pattern(sep1, sep2, sep3)
blocks = BlockList()
if not contents:
return blocks
matches = list(re.finditer(pattern, contents))
if len(matches) == 0:
blocks.append(Block(contents))
else:
first = matches[0]
last = matches[-1]
if first.start() != 0:
assert contents[first.start() - 1] == '\n'
blocks.append(Block(contents[:first.start() - 1]))
for (match, nxt) in util.windows(matches, 2):
blocks.append(new_comment(match, nxt))
blocks.append(new_comment(last))
return blocks
# lines is an iterable over each line in the content. splits like something
# above into a start token of `ifneq ($(ENV2),)`, and end of `endif`,
# and the internal contents as a `Block`.
#
# ifneq ($(ENV2),)
# benchmark_src_files += bench1.cc
# else
# benchmark_src_files += bench2.cc
# endif
def _split_directives(lines, in_scope=False):
def add_current(blocks, current):
if current:
blocks.append(Block('\n'.join(current)))
# we ignore else since removing it won't actually affect the code
start_directives = ('ifeq', 'ifneq', 'ifdef', 'ifndef')
end_directives = ('endif',)
blocks = BlockList()
current = []
for line in lines:
trimmed = line.lstrip()
if trimmed.startswith(start_directives):
start = line
add_current(blocks, current)
child, end = _split_directives(lines, True)
directive = DirectiveBlock(start, end, child)
directive.flatten_single()
blocks.append(directive)
current = []
elif in_scope and trimmed.startswith(end_directives):
end = line
add_current(blocks, current)
return blocks, end
else:
current.append(line)
add_current(blocks, current)
return blocks, None
# this groups directives and comments so any directives within a
# comment block are properly grouped. say i have the following:
#
# LOCAL_PATH := $(call my-dir)
#
# # -----------------------------------------------------------------------------
# # Section 1.
# # -----------------------------------------------------------------------------
# LOCAL_SRC_FILES := src.c
# ifneq ($(ENV2),)
# benchmark_src_files += bench1.cc
# else
# benchmark_src_files += bench2.cc
# endif
#
# # -----------------------------------------------------------------------------
# # Section 2.
# # -----------------------------------------------------------------------------
# LOCAL_CFLAGS := $(test_c_flags)
#
# normally, we'd have 5 sections: block, comment, directive, block, comment
# however, we want to group it in block, comment, comment, where the directive
# and subsequent block are in the comment.
def _group_comments(blocks):
def add_current(result, current):
if isinstance(current.child, list) and len(current.child) == 1:
current.child = current.child[0]
result.append(current)
def new_comment(block):
current = CommentBlock(block.comment, block.title, BlockList())
if block.child:
current.child.append(block.child)
return current
result = BlockList()
current = BlockList()
for block in blocks:
# any comments cannot have been grouped already, so we assume str values
assert not block.is_comment() or isinstance(block.child, str)
assert not block.is_block_list()
if not block.is_comment():
block.group_comments()
if current.is_comment() and block.is_comment():
# new comment replaces the old one
current.flatten_single()
result.append(current)
current = new_comment(block)
elif block.is_comment():
# first comment block seen in the file
result += current
current = new_comment(block)
elif current.is_comment():
# regular block after a comment block
current.child.append(block)
else:
# regular block before any comment blocks
current.append(block)
if current.is_comment():
current.flatten_single()
result.append(current)
else:
result += current
return result
# retain all items matching the condition in a list
def _filter_list(lst, op):
# use slice assignment to ensure this happens in-place
lst[:] = [i for i in lst if i.filter(op)]
return lst
# yield iteratively all child blocks
def _recurse_list(lst, max_depth=-1, depth=0):
if depth != max_depth:
for node in lst:
yield node
if node.has_block_list():
yield from node.child.recurse(max_depth, depth + 1)
================================================
FILE: docker/android/android/soong.py
================================================
'''
soong
=====
utilities to process soong blueprint files. these are a go-like,
json-like data file format similar. they support nested maps, lists,
bools, strings, and use of variables. for example:
array = ["..."]
cc_defaults {
name: "target",
options: array,
flags: ["..."],
}
cc_test {
name: "test",
defaults: ["target"],
srcs: ["test.cc"],
nested: {
array: {
option: false,
},
},
}
the specification can be found below:
https://source.android.com/docs/core/tests/development/blueprints
https://android.googlesource.com/platform/build/soong/+/refs/heads/master/README.md
they also support single-line C++-style and multiline C-style comments.
the valid types are:
- bool (`true`, `false`)
- int
- string
- list (of strings)
- map
both lists and maps support optional trailing commas. any value type
can be present in a map, while only strings are allowed in lists.
integers, strings, arrays and maps also also support the `+` operator,
where `+` sums up integers. for strings and arrays, it appends the new
data. for maps, it produces the union of both keys, and for keys present
in both, it appends the value on the right-operand to the value in the
left one.
variable assignment produces immutable types, except for the `+=` operator.
`+=` does the described operation above in-place.
this parser doesn't need to be exactly correct: it does not need to reject
subtley invalid input. for example `name = { }` may or may not be correct,
but it's fine to accept it as long as we output it identically. this is
supposed to handle all correct input and outputs it as correct output:
it doesn't need to validate type correctness.
this uses LALR parsing since it makes the grammar very easy to define and
the parsing simple. since the build step and repository synchronization
is much slower, the performance here is practically irrelevant.
'''
import json
import sys
import sly
from . import util
# dictionaries got insertion order in 3.6, guaranteed in 3.7
assert sys.version_info >= (3, 6)
# base character defs
_H = r'[0-9a-f]'
_NL = r'\n|\r\n|\r|\f'
_UNICODE = fr'\\{_H}{1,6}(\r\n|[ \t\r\n\f])?'
_ESCAPE = r'{_UNICODE}|\\[^\r\n\f0-9a-f]'
_SINGLELINE_COMMENT = r'\/\/.*'
# can't use reflags without setting them for all, so do manual dotall
_MULTILINE_COMMENT = r'\/\*[\u0000-\U0010FFFF]*?\*\/'
_COMMENT = fr'(?:{_SINGLELINE_COMMENT})|(?:{_MULTILINE_COMMENT})'
def loads(contents, *_, **__):
return Ast.loads(contents)
def load(fp, *_, **__):
return Ast.load(fp)
def dumps(soong, pretty=True, indent=4, *_, **__):
return soong.dumps(pretty, indent)
def dump(soong, fp, pretty=True, indent=4, *_, **__):
return soong.dump(fp, pretty, indent)
class Lexer(sly.Lexer):
tokens = {
BOOL,
INTEGER,
IDENT,
STRING,
LBRACKET,
RBRACKET,
LBRACE,
RBRACE,
COLON,
COMMA,
EQUALS,
PLUS,
}
ignore = ' \t'
ignore_comment = _COMMENT
# Tokens
# this uses a string regex based on the CSS2.1 grammar
STRING = fr'"([^\n\r\f\\"]|\\{_NL}|{_ESCAPE})*"'
INTEGER = r'\d+'
BOOL = '(?:true)|(?:false)'
IDENT = r'[a-zA-Z_][a-zA-Z0-9_]*'
LBRACKET = r'\['
RBRACKET = r'\]'
LBRACE = r'\{'
RBRACE = r'\}'
COLON = r':'
COMMA = r','
EQUALS = r'='
PLUS = r'\+'
@_(r'\n+')
def newline(self, token):
self.lineno += token.value.count('\n')
def error(self, token):
raise ValueError(f'Illegal character \'{token.value[0]}\'')
class Parser(sly.Parser):
tokens = Lexer.tokens
precedence = (
('left', PLUS),
)
@_('rules')
def ast(self, prod):
return Ast(prod.rules)
@_('empty')
def ast(self, prod):
return Ast()
@_('rules rule')
def rules(self, prod):
return prod.rules + [prod.rule]
@_('rule')
def rules(self, prod):
return [prod.rule]
@_('assignment', 'binary_operator_assignment', 'scope')
def rule(self, prod):
return prod[0]
@_('ident EQUALS expr')
def assignment(self, prod):
return Assignment(prod.ident, prod.expr)
@_('ident PLUS EQUALS expr')
def binary_operator_assignment(self, prod):
return BinaryOperatorAssignment(
prod.ident,
f'{prod[1]}{prod[2]}',
prod.expr,
)
@_('expr PLUS expr')
def binary_operator(self, prod):
return BinaryOperator(prod[0], prod[1], prod[2])
@_('ident map')
def scope(self, prod):
return Scope(prod.ident, prod.map)
@_('LBRACE pairs RBRACE', 'LBRACE pairs COMMA RBRACE')
def map(self, prod):
return Map(prod.pairs)
@_('LBRACE RBRACE')
def map(self, prod):
return Map()
@_('pairs COMMA pair')
def pairs(self, prod):
return prod.pairs + [prod.pair]
@_('pair')
def pairs(self, prod):
return [prod.pair]
@_('ident COLON expr', 'ident EQUALS expr')
def pair(self, prod):
return (prod.ident, MapValue(prod[1], prod.expr))
@_('ident', 'binary_operator', 'map', 'list', 'string', 'integer', 'bool')
def expr(self, prod):
return prod[0]
@_('LBRACKET sequence RBRACKET', 'LBRACKET sequence COMMA RBRACKET')
def list(self, prod):
return List(prod.sequence)
@_('LBRACKET RBRACKET')
def list(self, prod):
return List()
@_('sequence COMMA list_item')
def sequence(self, prod):
return prod.sequence + [prod.list_item]
@_('list_item')
def sequence(self, prod):
return [prod.list_item]
@_('list_item PLUS list_item')
def list_item(self, prod):
return BinaryOperator(prod[0], '+', prod[2])
@_('string', 'ident', 'map')
def list_item(self, prod):
return prod[0]
@_('IDENT')
def ident(self, prod):
return Ident(prod.IDENT)
@_('STRING')
def string(self, prod):
return String(prod.STRING)
@_('INTEGER')
def integer(self, prod):
return Integer(prod.INTEGER)
@_('BOOL')
def bool(self, prod):
return Bool(json.loads(prod.BOOL))
# needed in case no tokens are produced
@_('')
def empty(self, p):
pass
def error(self, token):
raise ValueError(f'Illegal token {repr(token)}')
class Node:
def is_assignment(self):
return False
def is_binary_operator_assignment(self):
return False
def is_binary_operator(self):
return False
def is_scope(self):
return False
def is_map(self):
return False
def is_list(self):
return False
def is_map_value(self):
return False
def is_ident(self):
return False
def is_string(self):
return False
def is_integer(self):
return False
def is_bool(self):
return False
class Ast(list, Node):
def __init__(self, values=None):
if values is None:
values = []
valid_nodes = (Assignment, BinaryOperatorAssignment, Scope)
assert all(isinstance(i, valid_nodes) for i in values)
super().__init__(values)
def __repr__(self):
return f'Ast({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
assert depth == 0
return '\n'.join([i.to_str(pretty, indent, depth) for i in self])
@staticmethod
def loads(contents, *_, **__):
lexer = Lexer()
tokens = lexer.tokenize(contents)
parser = Parser()
return parser.parse(tokens)
@staticmethod
def load(fp, *_, **__):
return Ast.loads(fp.read())
def dumps(self, pretty=True, indent=4, *_, **__):
return self.to_str(pretty, indent)
def dump(self, fp, pretty=True, indent=4, *_, **__):
# always write a trailing newline
fp.write(self.dumps(pretty, indent) + '\n')
def filter(self, op):
# use slice assignment to ensure this happens in-place
self[:] = [i for i in self if op(i)]
class Assignment(Node):
def __init__(self, name, expr):
self.name = name
self.expr = expr
def __repr__(self):
return f'Assignment({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
return f'{str(self.name)} = {self.expr.to_str(pretty, indent, depth)}'
def is_assignment(self):
return True
def __eq__(self, other):
return (self.name, self.expr) == (other.name, other.expr)
class BinaryOperatorAssignment(Node):
def __init__(self, name, op, expr):
self.name = name
self.op = op
self.expr = expr
def __repr__(self):
return f'BinaryOperatorAssignment({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
expr = self.expr.to_str(pretty, indent, depth)
return f'{str(self.name)} {self.op} {expr}'
def is_binary_operator_assignment(self):
return True
def __eq__(self, other):
return (self.name, self.op, self.expr) == (other.name, other.op, other.expr)
class BinaryOperator(Node):
def __init__(self, lhs, op, rhs):
self.lhs = lhs
self.op = op
self.rhs = rhs
def __repr__(self):
return f'BinaryOperator({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
lhs = self.lhs.to_str(pretty, indent, depth)
rhs = self.rhs.to_str(pretty, indent, depth)
return f'{lhs} {self.op} {rhs}'
def is_binary_operator(self):
return True
def str_op(self, cmp):
return (
(self.lhs.is_string() and self.lhs.str_op(cmp))
or (self.rhs.is_string() and self.rhs.str_op(cmp))
)
def __eq__(self, other):
return (self.lhs, self.op, self.rhs) == (other.lhs, other.op, other.rhs)
class Scope(Node):
def __init__(self, name, map):
self.name = name
self.map = map
def __repr__(self):
return f'Scope({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
return f'{str(self.name)} {self.map.to_str(pretty, indent, depth)}'
def is_scope(self):
return True
def __eq__(self, other):
return (self.name, self.map) == (other.name, other.map)
def is_art_check(self):
return 'art-check' in self.name.lower() or self.map.is_art_check()
def is_test(self):
return util.is_test(self.name) or self.map.is_test()
def is_benchmark(self):
return util.is_benchmark(self.name) or self.map.is_benchmark()
def is_dev(self):
return self.is_art_check() or self.is_test() or self.is_benchmark()
class Map(dict, Node):
def __repr__(self):
return f'Map({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
fmt = lambda x: x.to_str(pretty, indent, depth + 1)
result = '{'
pairs = [f'{fmt(k)}{fmt(v)}' for k, v in self.items()]
if len(self) == 0:
result += '}'
elif pretty:
result += '\n'
for pair in pairs:
result += _indent(indent, depth + 1) + f'{pair},\n'
result += _indent(indent, depth) + '}'
else:
result += ', '.join(pairs) + '}'
return result
def is_map(self):
return True
def is_art_check(self):
name = self.get('name')
if name is None:
return False
return 'art-check' in name.value.lower()
def is_test(self):
name = self.get('name')
if name is None:
return False
# cannot remove `py2-c-module-_ctypes_test` type tests,
# since they're needed to be linked in the final binary.
lower = name.value.lower()
return util.is_test(lower) and 'py2-c-module' not in lower
def is_benchmark(self):
name = self.get('name')
if name is None:
return False
return util.is_benchmark(name.value)
def is_dev(self):
return self.is_test() or self.is_benchmark()
def filter(self, op):
filtered = {k: v for k, v in self.items() if op(k, v)}
self.clear()
self.update(filtered)
def recurse(self, max_depth=-1, depth=0):
# recursively find all key/value pairs the current and any submaps
if depth != max_depth:
for key, value in self.items():
yield (key, value, depth + 1, self)
if value.value.is_map():
yield from value.value.recurse(max_depth, depth + 1)
class List(list, Node):
def __repr__(self):
return f'List({str(self)})'
def __str__(self):
return self.to_str(pretty=False)
def to_str(self, pretty=True, indent=4, depth=0):
def fmt(x):
if x.is_map():
return x.to_str(pretty, indent, depth)
return x.to_str(pretty, indent, depth + 1)
result = '['
if len(self) <= 1 or not pretty:
result += ', '.join([fmt(i) for i in self]) + ']'
else:
result += '\n'
for element in self:
result += _indent(indent, depth + 1) + f'{fmt(element)},\n'
result += _indent(indent, depth) + ']'
return result
def is_list(self):
return True
def filter(self, op):
# use slice assignment to ensure this happens in-place
self[:] = [i for i in self if op(i)]
class MapValue(Node):
def __init__(self, delimiter, value):
# map key/value separators can be `:` or `=`.
assert delimiter in (':', '=')
self.delimiter = delimiter
self.value = value
def __repr__(self):
return f'MapValue({str(self)})'
def __str__(self):
return self.to_str(False)
def __eq__(self, other):
# delimiter doesn't matter for equality comparison
if isinstance(other, MapValue):
return self.value == other.value
return self.value == other
def __len__(self):
return len(self.value)
def to_str(self, pretty=True, indent=4, depth=0):
value = self.value.to_str(pretty, indent, depth)
if self.delimiter == '=':
return f' = {value}'
return f': {value}'
def str_op(self, cmp):
return self.value.str_op(cmp)
def is_map_value(self):
return True
def filter(self, op):
self.value.filter(op)
class Ident(str, Node):
def __repr__(self):
return f'Ident({str(self)})'
def __str__(self):
return super().__str__()
def to_str(self, *_, **__):
return str(self)
def is_ident(self):
return True
class String(str, Node):
def __repr__(self):
return f'String({self.to_str()})'
def to_str(self, *_, **__):
return f'{super().__str__()}'
def str_op(self, cmp):
return cmp(self)
def __str__(self):
# `"target"` should be shown as `'target'`, not `'"target"'`
return super().__str__()[1:-1]
def __eq__(self, other):
if type(other) is String:
return str(self) == str(other)
# we want to be compare equal to the string's value
return str(self) == other
def __ne__(self, other):
# need to override `__ne__` which normally uses a pyslot
return not self.__eq__(other)
def is_string(self):
return True
class Integer(int, Node):
def __repr__(self):
return f'Integer({str(self)})'
def __str__(self):
return str(int(self))
def to_str(self, *_, **__):
return str(self)
def is_integer(self):
return True
class Bool(Node):
def __init__(self, value=False):
self.value = value
def __bool__(self):
return self.value
def __repr__(self):
return f'Bool({json.dumps(self.value)})'
def __str__(self):
return json.dumps(self.value)
def to_str(self, *_, **__):
return str(self)
def is_bool(self):
return True
def __eq__(self, other):
return self.value == other.value
def _indent(indent=4, depth=0, char=' '):
return char * indent * depth
================================================
FILE: docker/android/android/util.py
================================================
import re2 as re
def windows(sequence, count):
for i in range(len(sequence) - count + 1):
yield sequence[i:i + count]
def flatten(lst):
return [i for sublist in lst for i in sublist]
def _is_match(pattern, string):
return re.search(pattern, string) is not None
def is_test(string):
# need to consider that works like `latest` exist
# also need to consider `non-test` for `fmtlib`.
if 'non-test' in string.lower():
return False
pattern = r'(?i)(?:^|[^A-Za-z0-9]|g)test'
return _is_match(pattern, string)
def is_benchmark(string):
pattern = r'(?i)(?:^|[^A-Za-z0-9])benchmark'
return _is_match(pattern, string)
================================================
FILE: docker/android/pyproject.toml
================================================
[project]
name = "android"
version = "0.0.0-dev.0"
license = { text = "MIT OR Apache-2.0" }
dependencies = ["sly==0.4", "google-re2==1.0"]
[build-system]
requires = [
"setuptools >= 35.0.2",
"setuptools_scm >= 2.0.0, <3"
]
build-backend = "setuptools.build_meta"
================================================
FILE: docker/android/scripts/build-system.py
================================================
#!/usr/bin/env python
'''
Remove most unittests from Android soong blueprint
files, most of which are identified via a `cc_test*`
scope identifier, as well as some additional `subdirs`
identifiers and Makefile specifiers.
This also allows you to backup and restore these scripts.
The build files are automatically backed up by default.
'''
import argparse
import glob
import os
import shutil
import subprocess
import sys
SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECT_DIR = os.path.dirname(SCRIPTS_DIR)
sys.path.insert(0, PROJECT_DIR)
import android
import android.make
import android.soong
def print_verbose(message, verbose):
if verbose:
print(message)
def backup(src, args, *_):
dst = src + '.bak'
print_verbose(f'creating backup of file "{src}" at "{dst}"', args.verbose)
shutil.copy2(src, dst)
def restore(dst, args, *_):
src = dst + '.bak'
if os.path.exists(src):
print_verbose(f'restoring from backup "{src}" to "{dst}"', args.verbose)
shutil.copy2(src, dst)
def filter_map(map, remove):
keys = list(map)
for key in keys:
if not item_op(map[key].value, remove):
del map[key]
return True
def filter_list(lst, remove):
lst.filter(lambda x: item_op(x, remove))
return True
def item_op(item, remove):
if item.is_map():
return filter_map(item, remove)
elif item.is_list():
return filter_list(item, remove)
elif item.is_string() or item.is_binary_operator():
return item.str_op(lambda y: not any(i in y.lower() for i in remove))
raise TypeError(f'got unexpected type of {type(item)}')
def remove_soong_tests(path, args, *_):
print_verbose(f'removing soong tests from "{path}"', args.verbose)
with open(path) as file:
ast = android.soong.load(file)
# remove the test or benchmark scopes, IE, this with `cc_test`
# or those with `{name: "test"}`, etc.
ast.filter(lambda x: not (x.is_scope() and x.is_dev()))
# need to remove test and benchmark subdirs
test_names = ('test', 'benchmark')
subdirs = [i for i in ast if i.name == 'subdirs']
for sub in subdirs:
assert type(sub.expr) is android.soong.List
filter_list(sub.expr, test_names)
# remove gtest dependencies from regular targets.
for node in ast:
map = None
if not node.is_scope() and not node.expr.is_map():
continue
if node.is_scope():
map = node.map
else:
map = node.expr
test_names = ('libgtest', 'test-proto', 'starlarktest')
for key, value, *_ in map.recurse():
if value.value.is_list():
if key == 'testSrcs':
value.value.clear()
else:
filter_list(value, test_names)
with open(path, 'w') as file:
ast.dump(file)
def remove_makefile_tests(path, args, *_):
print_verbose(f'removing makefile tests from "{path}"', args.verbose)
with open(path) as file:
makefile = android.make.load(file)
makefile.filter(lambda x: not x.is_dev())
with open(path, 'w') as file:
makefile.dump(file)
def remove_tests(path, args, processor):
if os.path.exists(path + '.bak'):
restore(path, args)
elif not args.disable_backup:
backup(path, args)
processor(path, args)
def stash(root):
git_glob = f'{root}/**/.git'
for path in glob.iglob(git_glob, recursive=True):
os.chdir(os.path.dirname(path))
subprocess.check_call(['git', 'stash'])
def main():
parser = argparse.ArgumentParser()
action_group = parser.add_mutually_exclusive_group(required=True)
action_group.add_argument(
'--backup',
help='backup build files',
action='store_true',
)
action_group.add_argument(
'--restore',
help='restore build files',
action='store_true',
)
action_group.add_argument(
'--remove-tests',
help='remove most tests from the build system.',
action='store_true',
)
action_group.add_argument(
'--stash',
help='stash all local changes.',
action='store_true',
)
parser.add_argument(
'--disable-backup',
help='disable automatic backup of build files during processing.',
action='store_false',
)
flags_group = parser.add_mutually_exclusive_group()
flags_group.add_argument(
'--soong-only',
help='only process soong build files.',
action='store_true',
)
flags_group.add_argument(
'--makefile-only',
help='only process makefiles.',
action='store_true',
)
parser.add_argument(
'-V',
'--version',
action='version',
version=android.__version__
)
parser.add_argument(
'-v',
'--verbose',
help='display verbose diagnostic info.',
action='store_true',
)
args = parser.parse_args()
if args.backup:
action = backup
elif args.restore:
action = restore
elif args.remove_tests:
action = remove_tests
elif args.stash:
action = stash
# root_dir is only available 3.10+
root = os.environ.get('ANDROID_ROOT')
if root is None:
root = os.getcwd()
if args.stash:
return stash(root)
if not args.makefile_only:
soong_glob = f'{root}/**/Android.bp'
for path in glob.iglob(soong_glob, recursive=True):
action(path, args, remove_soong_tests)
if not args.soong_only:
make_glob = f'{root}/**/Android.mk'
for path in glob.iglob(make_glob, recursive=True):
action(path, args, remove_makefile_tests)
if __name__ == '__main__':
main()
================================================
FILE: docker/android/tests/Addition.bp
================================================
// special file testing `+` and `+=` operators
// this is assignment + add assignment
list = ["value1"]
list += ["value2"]
number = 1
number += 2
string = "string"
string += "_suffix"
scope {
name: "target",
}
scope += {
name: "_suffix",
srcs: [
// sequence items just have to evaluate to strings
"tree.cc" + string,
"lib.cc",
],
}
// this is addition with lhs idents
lhs_sum = number + 4
lhs_string = string + "_suffix"
lhs_list = list + ["value3"]
lhs_scope = scope + {
name: "_suffix",
cflags: [
"-Wall",
],
}
// this is addition with rhs idents
rhs_sum = 4 + number
rhs_string = "prefix_" + string
rhs_list = ["value0"] + list
rhs_scope = {
name: "_suffix",
cflags: [
"-Wall",
],
} + scope
// this is addition with both being non-idents
expr_sum = 4 + 1
expr_string = "prefix_" + "suffix"
expr_list = ["value0"] + ["value1"]
expr_scope = {} + {
name: "target",
}
// test multiple binary ops
tri_sum = 4 + 1 + 2
tri_string = "prefix_" + "middle" + "_suffix"
tri_list = ["value0"] + ["value1"] + ["value2"]
tri_scope = {} + {
name: "target",
} + {}
// test sequence lhs and rhs strings
home = "dir/"
test = "test.c"
files = [
home + "file.c",
"test/" + test,
home + test,
]
================================================
FILE: docker/android/tests/Android.bp
================================================
// sample heading comment
sample_array = [
"value1",
"value2",
]
/**
sample
multiline
comment
*/
cc_defaults {
name: "target",
cflags: [
"-Wall",
"-fstrict-aliasing",
],
option: true,
tidy_checks: sample_array,
tidy_checks_as_errors: sample_array,
array: [
"-short",
"--root='/path/to/dir'",
],
}
cc_library_static {
name: "static_lib",
srcs: [
"tree.cc",
"lib.cc",
],
include_dirs: ["bionic/libc"],
export_include_dirs: ["."],
}
cc_library {
name: "lib",
srcs: [
"tree.cc",
"lib.cc",
],
include_dirs: ["bionic/libc"],
export_include_dirs: ["."],
}
cc_test {
name: "test",
defaults: ["target"],
srcs: ["test.cc"],
nested: {
array: {
option: false,
},
},
}
cc_test_host {
name: "host_test",
include_dirs: ["path/to/lib"],
compile_multilib: "64",
static_libs: [
"libm",
"libz",
],
host_ldlibs: [
"-ldl",
"-lzstd",
"-l" + "z",
],
shared_libs: [],
cflags = [
"-Wall",
"-fstrict-aliasing",
],
}
cc_defaults {
name: "custom",
shared_libs: ["libcustom"],
whole_static_libs: [
"libz",
"libgtest_main",
],
host_ldlibs: ["-lgtest"],
}
================================================
FILE: docker/android/tests/Android.mk
================================================
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := config.c
LOCAL_MODULE := config
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS := -Werror
include $(BUILD_HOST_EXECUTABLE)
LOCAL_PATH := $(call my-dir)
# -----------------------------------------------------------------------------
# Benchmarks.
# -----------------------------------------------------------------------------
test_tags := tests
benchmark_c_flags := \
-Wall -Wextra \
-Werror \
-fno-builtin \
benchmark_src_files := \
benchmark_main.cc \
bench.cc
# Build benchmarks.
include $(CLEAR_VARS)
LOCAL_MODULE := benchmarks
LOCAL_MODULE_TAGS := tests
LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_SHARED_LIBRARIES += libm libdl
LOCAL_SRC_FILES := $(benchmark_src_files)
# -----------------------------------------------------------------------------
# Unit tests.
# -----------------------------------------------------------------------------
test_c_flags := \
-g \
-Wall \
-Werror
##################################
# test executable
LOCAL_MODULE := module
LOCAL_SRC_FILES := src.c
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS := $(test_c_flags)
LOCAL_MODULE_RELATIVE_PATH := config-tests
# Unit tests.
# =========================================================
include $(CLEAR_VARS)
LOCAL_MODULE := init_tests
LOCAL_SRC_FILES := \
init_parser_test.cc \
property_service_test.cc \
service_test.cc \
util_test.cc \
##################################
# test executable
LOCAL_MODULE := module
LOCAL_SRC_FILES := src.c
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS := $(test_c_flags)
LOCAL_MODULE_RELATIVE_PATH := config-tests
LOCAL_SHARED_LIBRARIES += \
libcutils \
libbase \
LOCAL_STATIC_LIBRARIES := libinit
LOCAL_SANITIZE := integer
LOCAL_CLANG := true
LOCAL_CPPFLAGS := -Wall -Wextra -Werror
include $(BUILD_NATIVE_TEST)
# Other section.
# =========================================================
include $(call all-makefiles-under,$(LOCAL_PATH))
# =============================================================================
# Unit tests.
# =============================================================================
test_c_flags := \
-g \
-Wall \
-Werror
##################################
# test executable
LOCAL_MODULE := mod2
LOCAL_SRC_FILES := mod.c
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS := $(test_c_flags)
LOCAL_MODULE_RELATIVE_PATH := mod2-tests
================================================
FILE: docker/android/tests/Comments.mk
================================================
# 1) sample grouping:
# - text + suffix
# - some more text (the format)
# - API and policy info
# - more API + policy info
================================================
FILE: docker/android/tests/Empty.bp
================================================
// this file only has comments
================================================
FILE: docker/android/tests/Empty.mk
================================================
================================================
FILE: docker/android/tests/FakeTitle.mk
================================================
########################################################################
#
LOCAL_PATH := $(call my-dir)
================================================
FILE: docker/android/tests/Grouped.mk
================================================
LOCAL_PATH := $(call my-dir)
# -----------------------------------------------------------------------------
# Section 1.
# -----------------------------------------------------------------------------
LOCAL_SRC_FILES := src.c
ifneq ($(ENV1),)
# -----------------------------------------------------------------------------
# Section 2.
# -----------------------------------------------------------------------------
ifneq ($(ENV2),)
benchmark_src_files += bench1.cc
else
benchmark_src_files += bench2.cc
endif
else
benchmark_src_files += bench3.cc
endif
# -----------------------------------------------------------------------------
# Section 3.
# -----------------------------------------------------------------------------
LOCAL_CFLAGS := $(test_c_flags)
================================================
FILE: docker/android/tests/ListMap.bp
================================================
// this contains a list of maps
scope {
key: [
{
name: "art",
deps: ["dependency"],
},
],
}
================================================
FILE: docker/android/tests/Multiline.mk
================================================
# this is a special makefile checking support for multiline comments
LOCAL_PATH := $(call my-dir)
ifneq ($(ENV1),)
###########################################################
# new rules
# $(1): rule 1
# $(2): rule 2
###########################################################
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
================================================
FILE: docker/android/tests/Nested.mk
================================================
# this is a special makefile checking we handle nested
# conditionals properly, that removing sections won't
# cause unequal conditional blocks. it may still lead
# to missing definitions, but it won't fail due to
# unmatched if and endif directives.
LOCAL_PATH := $(call my-dir)
ifneq ($(ENV1),)
# -----------------------------------------------------------------------------
# Benchmarks.
# -----------------------------------------------------------------------------
test_tags := tests
benchmark_c_flags := \
-Wall -Wextra \
-Werror \
-fno-builtin \
benchmark_src_files := benchmark_main.cc
ifneq ($(ENV2),)
benchmark_src_files += bench1.cc
else
benchmark_src_files += bench2.cc
endif
# Build benchmarks.
include $(CLEAR_VARS)
LOCAL_MODULE := benchmarks
LOCAL_MODULE_TAGS := tests
LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_SHARED_LIBRARIES += libm libdl
LOCAL_SRC_FILES := $(benchmark_src_files)
endif
# Other section.
# =========================================================
include $(call all-makefiles-under,$(LOCAL_PATH))
# =============================================================================
# Unit tests.
# =============================================================================
test_c_flags := \
-g \
-Wall \
-Werror
##################################
# test executable
LOCAL_MODULE := mod2
LOCAL_SRC_FILES := mod.c
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS := $(test_c_flags)
LOCAL_MODULE_RELATIVE_PATH := mod2-tests
================================================
FILE: docker/android/tests/NonTest.bp
================================================
cc_defaults {
name: "lib-non-test-defaults",
cflags: ["-Wall"],
srcs: ["src/libc.cc"],
min_sdk_version: "29",
}
================================================
FILE: docker/android/tests/README.md
================================================
android
=======
Contains sample Soong blueprint files and Makefiles to test removal of unittests for build configurations.
This requires a Python3 interpreter, and therefore is not run as part of the core test suite. Running the test suite requires:
- sly >= 0.4
- google-re2 >= 1.0
- pytest >= 7
- toml >= 0.10
The module itself and the scripts only require:
- python >= 3.6
- sly >= 0.4
- google-re2 >= 1.0
google-re2 is needed to avoid backtracking regexes, which destroy performance on near-misses for section headers. The below example, if provided with 10,000 characters after the header, will likely never complete. With re2, this completes nearly instantly.
```Makefile
########################################################################
#
....
```
================================================
FILE: docker/android/tests/Single.mk
================================================
# this is a special makefile without any blocks
LOCAL_PATH := $(call my-dir)
test_tags := tests
benchmark_c_flags := \
-Wall -Wextra \
-Werror \
-fno-builtin \
benchmark_src_files := \
benchmark_main.cc \
bench.cc
# Build benchmarks.
include $(CLEAR_VARS)
LOCAL_MODULE := benchmarks
LOCAL_MODULE_TAGS := tests
LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_SHARED_LIBRARIES += libm libdl
LOCAL_SRC_FILES := $(benchmark_src_files)
================================================
FILE: docker/android/tests/test_make.py
================================================
import copy
import os
import sys
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECT_DIR = os.path.dirname(TEST_DIR)
sys.path.insert(0, PROJECT_DIR)
from android import make
def test():
path = os.path.join(TEST_DIR, 'Android.mk')
contents = open(path).read()
makefile = make.loads(contents)
stripped = contents[:-1]
assert repr(makefile) == f'Makefile({stripped})'
assert str(makefile) == stripped
assert len(makefile) == 9
assert not makefile[0].is_dev()
assert makefile[1].is_dev()
assert makefile[1].is_benchmark()
assert makefile[2].is_dev()
assert makefile[2].is_test()
assert makefile[6].title == 'Other section.'
filtered = copy.deepcopy(makefile)
filtered.filter(lambda x: not x.is_dev())
assert type(filtered) is make.Makefile
assert len(filtered) == 2
assert not filtered[0].is_comment()
assert filtered[1].title == 'Other section.'
assert makefile == make.load(open(path))
assert contents == makefile.dumps() + '\n'
def test_nested():
path = os.path.join(TEST_DIR, 'Nested.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 6
assert makefile[0].is_block()
assert makefile[0].child.startswith('# this is a special makefile')
assert makefile[1].is_directive()
assert len(makefile[1].child) == 2
assert makefile[1].child[0].is_block()
assert makefile[1].child[1].is_comment()
assert makefile[1].child[1].title == 'Benchmarks.'
outer = makefile[1].child[1]
assert len(outer.child) == 3
assert outer.child[0].is_block()
assert outer.child[1].is_directive()
assert outer.child[2].is_block()
inner = outer.child[1]
assert inner.child.is_block()
def test_comments():
path = os.path.join(TEST_DIR, 'Comments.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 1
assert makefile[0].is_block()
assert makefile[0].child.startswith('# 1) sample grouping:')
def test_grouped():
path = os.path.join(TEST_DIR, 'Grouped.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 3
assert makefile[0].is_block()
assert makefile[0].child.startswith('LOCAL_PATH := $(call my-dir)')
comment = makefile[1]
assert comment.is_comment()
assert len(comment.child) == 3
assert comment.child[0].child.startswith('LOCAL_SRC_FILES := src.c')
assert comment.child[1].is_directive()
assert len(comment.child[2].child) == 0
directives = comment.child[1]
inner_comment = directives.child
assert inner_comment.is_comment()
assert len(inner_comment.child) == 2
assert inner_comment.child[0].is_directive()
assert inner_comment.child[1].child.startswith('else')
inner = inner_comment.child[0]
assert inner.child.lstrip().startswith('benchmark_src_files')
assert makefile[2].is_comment()
def test_recurse():
path = os.path.join(TEST_DIR, 'Nested.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
nodes = list(makefile.recurse())
assert len(nodes) == 11
assert nodes[0] == makefile[0]
assert nodes[1] == makefile[1]
assert nodes[2] == makefile[1].child[0]
assert nodes[3] == makefile[1].child[1]
assert nodes[4] == makefile[1].child[1].child[0]
assert nodes[5] == makefile[1].child[1].child[1]
assert nodes[6] == makefile[1].child[1].child[2]
assert nodes[7] == makefile[2]
assert nodes[8] == makefile[3]
assert nodes[9] == makefile[4]
assert nodes[10] == makefile[5]
def test_multiline():
path = os.path.join(TEST_DIR, 'Multiline.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 2
assert makefile[0].is_block()
assert makefile[0].child.startswith('# this is a special makefile')
assert makefile[1].is_directive()
comment = makefile[1].child[1]
assert comment.is_comment()
assert comment.title == 'new rules\n$(1): rule 1\n$(2): rule 2'
assert str(comment.child).startswith('\ninclude')
def test_fake_title():
path = os.path.join(TEST_DIR, 'FakeTitle.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 1
comment = makefile[0]
assert comment.is_comment()
assert comment.title == ''
assert str(comment.child).startswith('LOCAL_PATH := $(call my-dir)')
def test_filter():
path = os.path.join(TEST_DIR, 'Nested.mk')
contents = open(path).read()
makefile = make.loads(contents)
assert str(makefile) + '\n' == contents
assert len(makefile) == 6
assert makefile[1].is_directive()
assert len(makefile[1].child) == 2
filtered = copy.deepcopy(makefile)
filtered.filter(lambda x: not x.is_dev())
assert len(filtered) == 4
assert filtered[0].is_block()
assert filtered[1].is_directive()
assert filtered[2].is_block()
assert filtered[3].is_comment()
directive = filtered[1]
assert len(directive.child) == 1
assert directive.child[0].is_block()
assert filtered[3].title.lstrip().startswith('Other section.')
def test_split_directives():
path = os.path.join(TEST_DIR, 'Nested.mk')
contents = open(path).read()
iterable = iter(contents.splitlines())
blocks = make._split_directives(iterable)[0]
assert len(blocks) == 3
assert blocks[0].is_block()
assert blocks[0].startswith('# this is a special makefile')
assert blocks[2].is_block()
assert blocks[2].lstrip().startswith('# Other section.')
assert not blocks[1].is_comment()
assert blocks[1].is_directive()
assert blocks[1].has_block_list()
directives = blocks[1].child
assert len(directives) == 3
assert directives[0].is_block()
assert directives[1].is_directive()
assert directives[2].is_block()
assert not directives[1].child.has_block_list()
assert directives[1].child.lstrip().startswith('benchmark_src_files')
path = os.path.join(TEST_DIR, 'Grouped.mk')
contents = open(path).read()
iterable = iter(contents.splitlines())
blocks = make._split_directives(iterable)[0]
assert len(blocks) == 3
assert blocks[0].is_block()
assert blocks[1].is_directive()
assert blocks[2].is_block()
directives = blocks[1].child
assert len(directives) == 3
assert directives[0].is_block()
assert directives[1].is_directive()
assert directives[2].is_block()
def test_split_comments():
path = os.path.join(TEST_DIR, 'Android.mk')
contents = open(path).read()
blocks = make._split_comments(contents)
assert repr(blocks) == f'BlockList({contents})'
assert str(blocks) == contents
assert len(blocks) == 9
assert not blocks[0].is_dev()
assert blocks[1].is_dev()
assert blocks[1].is_benchmark()
assert blocks[1].title == 'Benchmarks.'
assert blocks[2].is_dev()
assert blocks[2].is_test()
assert blocks[2].title == 'Unit tests.'
assert blocks[3].is_test()
assert blocks[3].title == 'test executable'
assert blocks[4].is_test()
assert blocks[4].title == 'Unit tests.'
assert blocks[5].is_test()
assert blocks[5].title == 'test executable'
assert not blocks[6].is_dev()
assert blocks[6].title == 'Other section.'
assert blocks[7].is_test()
assert blocks[7].title == 'Unit tests.'
assert blocks[8].is_test()
assert blocks[8].title == 'test executable'
path = os.path.join(TEST_DIR, 'Empty.mk')
contents = open(path).read()
blocks = make._split_comments(contents)
assert len(blocks) == 1
assert repr(blocks) == 'BlockList(\n)'
assert str(blocks) == '\n'
assert str(blocks[0]) == '\n'
blocks = make._split_comments('')
assert len(blocks) == 0
assert repr(blocks) == 'BlockList()'
assert str(blocks) == ''
def test_block():
data = '''LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)'''
block = make.Block(data)
assert repr(block) == f'Block({data})'
assert str(block) == data
assert block.is_block()
assert not block.is_block_list()
assert not block.is_comment()
assert not block.is_directive()
assert not block.is_dev()
def test_block_list():
data1 = 'LOCAL_PATH := $(call my-dir)'
data2 = 'test_tags := tests'
blocks = make.BlockList([make.Block(data1), make.Block(data2)])
assert repr(blocks) == f'BlockList({data1}\n{data2})'
assert str(blocks) == f'{data1}\n{data2}'
assert not blocks.is_block()
assert blocks.is_block_list()
assert not blocks.is_comment()
assert not blocks.is_directive()
assert not blocks.is_dev()
def test_comment_block():
# single block
comment = '''# -----------------------------------------------------------------------------
# Benchmarks.
# -----------------------------------------------------------------------------
'''
title = 'Benchmarks.'
data = 'test_tags := tests'
block = make.CommentBlock(comment, title, make.Block(data))
assert repr(block) == f'CommentBlock({comment}\n{data})'
assert str(block) == f'{comment}\n{data}'
assert not block.is_block()
assert not block.is_block_list()
assert block.is_comment()
assert not block.is_directive()
assert block.is_dev()
title = 'Other Section.'
blocks = make.BlockList([
make.Block('LOCAL_PATH := $(call my-dir)'),
make.Block('test_tags := tests'),
])
block = make.CommentBlock(comment, title, blocks)
assert repr(block) == f'CommentBlock({comment}\n{str(blocks)})'
assert str(block) == f'{comment}\n{str(blocks)}'
assert not block.is_block()
assert not block.is_block_list()
assert block.is_comment()
assert not block.is_directive()
assert not block.is_dev()
def test_directive_block():
start_inner = ' ifneq ($(USE_B),)'
end_inner = ' endif'
data_inner = ''' SOURCES=b.cc
else
SOURCES=a.cc'''
inner = make.DirectiveBlock(start_inner, end_inner, make.Block(data_inner))
str_inner = f'{start_inner}\n{data_inner}\n{end_inner}'
assert repr(inner) == f'DirectiveBlock({str_inner})'
assert str(inner) == str_inner
assert not inner.is_block()
assert not inner.is_block_list()
assert not inner.is_comment()
assert inner.is_directive()
assert not inner.is_dev()
data_else = '''else
SOURCES=c.cc'''
else_block = make.Block(data_else)
blocks = make.BlockList([inner, else_block])
str_blocks = '\n'.join([str(i) for i in blocks])
assert repr(blocks) == f'BlockList({str_blocks})'
assert str(blocks) == str_blocks
start = 'ifneq ($(USE_A),)'
end = 'endif'
block = make.DirectiveBlock(start, end, blocks)
str_block = f'{start}\n{str_blocks}\n{end}'
assert repr(block) == f'DirectiveBlock({str_block})'
assert str(block) == str_block
assert not block.is_block()
assert not block.is_block_list()
assert not block.is_comment()
assert block.is_directive()
assert not block.is_dev()
================================================
FILE: docker/android/tests/test_metadata.py
================================================
import os
import sys
import toml
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECT_DIR = os.path.dirname(TEST_DIR)
sys.path.insert(0, PROJECT_DIR)
import android
# ensure our pyproject and module metadata don't go out-of-date
def test_metadata():
pyproject_path = open(os.path.join(PROJECT_DIR, 'pyproject.toml'))
pyproject = toml.load(pyproject_path)
project = pyproject['project']
assert project['name'] == android.__name__
assert project['version'] == android.__version__
assert project['license']['text'] == android.__license__
version, dev = android.__version__.split('-')
major, minor, patch = [int(i) for i in version.split('.')]
assert (major, minor, patch, dev) == android.__version_info__
================================================
FILE: docker/android/tests/test_soong.py
================================================
import copy
import os
import sys
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECT_DIR = os.path.dirname(TEST_DIR)
sys.path.insert(0, PROJECT_DIR)
from android import soong
def test():
path = os.path.join(TEST_DIR, 'Android.bp')
contents = open(path).read()
lexer = soong.Lexer()
tokens = list(lexer.tokenize(contents))
assert (tokens[0].type, tokens[0].value) == ('IDENT', 'sample_array')
assert (tokens[51].type, tokens[51].value) == ('IDENT', 'srcs')
assert (tokens[52].type, tokens[52].value) == ('COLON', ':')
assert (tokens[53].type, tokens[53].value) == ('LBRACKET', '[')
assert (tokens[54].type, tokens[54].value) == ('STRING', '"tree.cc"')
parser = soong.Parser()
result = parser.parse(iter(tokens))
assert len(result) == 7
assert result[0].is_assignment()
assert result[0].to_str() == '''sample_array = [
"value1",
"value2",
]'''
assert result[1].is_scope()
assert result[1].name == 'cc_defaults'
assert result[1].name.is_ident()
assert result[1].map['name'] == 'target'
assert result[1].map['tidy_checks'] == 'sample_array'
assert result[1].map.get('srcs') is None
assert result[1].map.is_map()
assert result[2].is_scope()
assert result[2].name == 'cc_library_static'
assert result[2].map['name'] == 'static_lib'
ast = soong.loads(contents)
assert ast == result
ast = soong.load(open(path))
assert ast == result
lines = contents.splitlines()
assert ast.dumps() == '\n'.join(lines[1:5] + lines[10:])
assert ast[4].is_test()
assert ast[4].map.is_test()
filtered = copy.deepcopy(ast)
filtered.filter(lambda x: not (x.is_scope() and x.is_dev()))
assert type(filtered) is soong.Ast
assert len(filtered) == 5
assert filtered == ast[:4] + [ast[6]]
map = filtered[1].map
assert 'cflags' in map
map.filter(lambda k, v: k != 'cflags')
assert 'cflags' not in map
assert len(map['array']) == 2
map['array'].filter(lambda x: x != '-short')
assert len(map['array']) == 1
custom = filtered[4].map
assert 'whole_static_libs' in custom
custom['whole_static_libs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
assert custom['whole_static_libs'] == ['libz']
assert 'host_ldlibs' in custom
custom['host_ldlibs'].filter(lambda x: x.str_op(lambda y: 'gtest' not in y.lower()))
assert custom['host_ldlibs'] == []
def test_addition():
path = os.path.join(TEST_DIR, 'Addition.bp')
ast = soong.load(open(path))
assert len(ast) == 27
assert ast[0].is_assignment()
assert ast[1].is_binary_operator_assignment()
assert ast[2].is_assignment()
assert ast[3].is_binary_operator_assignment()
assert ast[4].is_assignment()
assert ast[5].is_binary_operator_assignment()
assert ast[6].is_scope()
assert ast[7].is_binary_operator_assignment()
assert ast[8].expr.is_binary_operator()
assert ast[0].name == 'list'
assert ast[0].expr == ['value1']
assert ast[1].name == 'list'
assert ast[1].op == '+='
assert ast[1].expr == ['value2']
assert ast[8].expr.lhs == 'number'
assert ast[8].expr.op == '+'
assert ast[8].expr.rhs == 4
assert ast[11].expr.lhs == 'scope'
assert ast[11].expr.op == '+'
assert ast[11].expr.rhs.is_map()
assert ast[12].expr.lhs == 4
assert ast[12].expr.op == '+'
assert ast[12].expr.rhs == 'number'
assert ast[15].expr.lhs.is_map()
assert ast[15].expr.op == '+'
assert ast[15].expr.rhs == 'scope'
assert ast[16].expr.lhs == 4
assert ast[16].expr.op == '+'
assert ast[16].expr.rhs == 1
assert ast[19].expr.lhs == {}
assert ast[19].expr.op == '+'
assert ast[19].expr.rhs == {'name': 'target'}
assert ast[20].expr.lhs.is_binary_operator()
assert ast[20].expr.lhs.lhs == 4
assert ast[20].expr.lhs.rhs == 1
assert ast[20].expr.op == '+'
assert ast[20].expr.rhs == 2
assert ast[26].name == 'files'
assert ast[26].expr.is_list()
assert len(ast[26].expr) == 3
assert ast[26].expr[0].lhs == 'home'
assert ast[26].expr[0].lhs.is_ident()
assert ast[26].expr[0].rhs == 'file.c'
assert ast[26].expr[0].rhs.is_string()
assert ast[26].expr[1].lhs == 'test/'
assert ast[26].expr[1].lhs.is_string()
assert ast[26].expr[1].rhs == 'test'
assert ast[26].expr[1].rhs.is_ident()
assert ast[26].expr[2].lhs == 'home'
assert ast[26].expr[2].lhs.is_ident()
assert ast[26].expr[2].rhs == 'test'
assert ast[26].expr[2].rhs.is_ident()
# test a few binops, just in case
binop = ast[26].expr[1]
assert binop.str_op(lambda x: 'test' in x.lower())
assert binop.lhs.str_op(lambda x: 'test' in x.lower())
def test_empty():
path = os.path.join(TEST_DIR, 'Empty.bp')
ast = soong.load(open(path))
assert len(ast) == 0
def test_list_map_parse():
path = os.path.join(TEST_DIR, 'ListMap.bp')
ast = soong.load(open(path))
assert len(ast) == 1
scope = ast[0]
assert scope.is_scope()
assert scope.name == 'scope'
map = scope.map['key']
assert map.value.is_list()
assert len(map.value) == 1
assert map.value[0].is_map()
inner = map.value[0]
assert len(inner) == 2
assert inner['name'] == 'art'
assert inner['deps'].value == soong.List([soong.String('"dependency"')])
def test_is_non_test():
path = os.path.join(TEST_DIR, 'NonTest.bp')
ast = soong.load(open(path))
assert len(ast) == 1
scope = ast[0]
assert scope.is_scope()
assert scope.name == 'cc_defaults'
assert scope.map['name'].value == 'lib-non-test-defaults'
def test_ast():
array = soong.List([soong.String('"value1"'), soong.String('"value2"')])
assignment = soong.Assignment(soong.Ident('name'), array)
value = soong.MapValue('=', soong.String('"value"'))
map = soong.Map({soong.Ident('key'): value})
scope = soong.Scope(soong.Ident('name'), map)
ast = soong.Ast([assignment, scope])
assert repr(ast) == '''Ast(name = ["value1", "value2"]
name {key = "value"})'''
assert str(ast) == '''name = ["value1", "value2"]
name {key = "value"}'''
assert ast.to_str() == '''name = [
"value1",
"value2",
]
name {
key = "value",
}'''
def test_assignment():
array = soong.List([soong.String('"value1"'), soong.String('"value2"')])
assignment = soong.Assignment(soong.Ident('name'), array)
assert repr(assignment) == 'Assignment(name = ["value1", "value2"])'
assert str(assignment) == 'name = ["value1", "value2"]'
assert assignment.to_str(pretty=False) == 'name = ["value1", "value2"]'
assert assignment.to_str() == '''name = [
"value1",
"value2",
]'''
assert assignment.to_str(depth=1) == '''name = [
"value1",
"value2",
]'''
def test_binary_operator_assignment():
ident = soong.Ident('name')
expr = soong.Integer('1')
assignment = soong.BinaryOperatorAssignment(ident, '+=', expr)
assert repr(assignment) == 'BinaryOperatorAssignment(name += 1)'
assert str(assignment) == 'name += 1'
assert assignment.to_str(pretty=False) == 'name += 1'
assert assignment.to_str() == 'name += 1'
def test_binary_operator():
ident = soong.Ident('name')
expr = soong.Integer('1')
operator = soong.BinaryOperator(ident, '+', expr)
assert repr(operator) == 'BinaryOperator(name + 1)'
assert str(operator) == 'name + 1'
assert operator.to_str(pretty=False) == 'name + 1'
assert operator.to_str() == 'name + 1'
def test_scope():
value = soong.MapValue(':', soong.String('"value"'))
map = soong.Map({soong.Ident('key'): value})
scope = soong.Scope(soong.Ident('name'), map)
assert repr(scope) == 'Scope(name {key: "value"})'
assert str(scope) == 'name {key: "value"}'
assert scope.to_str(pretty=False) == 'name {key: "value"}'
assert scope.to_str() == '''name {
key: "value",
}'''
assert scope.to_str(depth=1) == '''name {
key: "value",
}'''
def test_map():
value = soong.MapValue(':', soong.String('"value"'))
map = soong.Map({soong.Ident('key'): value})
assert repr(map) == 'Map({key: "value"})'
assert str(map) == '{key: "value"}'
assert map.to_str(pretty=False) == '{key: "value"}'
assert map.to_str() == '''{
key: "value",
}'''
assert map.to_str(depth=1) == '''{
key: "value",
}'''
map = soong.Map()
assert str(map) == '{}'
assert map.to_str() == '{}'
def test_recurse():
path = os.path.join(TEST_DIR, 'Android.bp')
ast = soong.load(open(path))
cc_defaults = ast[1]
assert cc_defaults.name == 'cc_defaults'
for (key, value, depth, parent) in cc_defaults.map.recurse():
assert depth == 1
cc_test = ast[4]
assert cc_test.name == 'cc_test'
seen = []
for (key, value, depth, parent) in cc_test.map.recurse():
if depth > 1 and parent.is_map():
seen.append(key)
assert seen == ['array', 'option']
def test_list():
sequence = soong.List([soong.String('"value1"'), soong.String('"value2"')])
assert repr(sequence) == 'List(["value1", "value2"])'
assert str(sequence) == '["value1", "value2"]'
assert sequence.to_str(pretty=False) == '["value1", "value2"]'
assert sequence.to_str() == '''[
"value1",
"value2",
]'''
assert sequence.to_str(depth=1) == '''[
"value1",
"value2",
]'''
sequence = soong.List([soong.String('"value"')])
assert repr(sequence) == 'List(["value"])'
assert str(sequence) == '["value"]'
assert sequence.to_str() == '["value"]'
sequence = soong.List([])
assert sequence.to_str() == '[]'
def test_map_value():
value = soong.MapValue(':', soong.String('"value"'))
assert repr(value) == 'MapValue(: "value")'
assert str(value) == ': "value"'
assert value.to_str() == ': "value"'
value = soong.MapValue('=', soong.String('"value"'))
assert repr(value) == 'MapValue( = "value")'
assert str(value) == ' = "value"'
assert value.to_str() == ' = "value"'
def test_list_map():
value = soong.MapValue(':', soong.String('"value"'))
map = soong.Map({soong.Ident('key'): value})
sequence = soong.List([map])
assert repr(sequence) == 'List([{key: "value"}])'
assert str(sequence) == '[{key: "value"}]'
assert sequence.to_str(pretty=False) == '[{key: "value"}]'
assert sequence.to_str() == '''[{
key: "value",
}]'''
def test_ident():
ident = soong.Ident('name')
assert repr(ident) == 'Ident(name)'
assert str(ident) == 'name'
assert ident.to_str() == 'name'
def test_string():
string = soong.String('"value1"')
assert repr(string) == 'String("value1")'
assert str(string) == 'value1'
assert string.to_str() == '"value1"'
def test_integer():
number = soong.Integer('3')
assert repr(number) == 'Integer(3)'
assert str(number) == '3'
assert number.to_str() == '3'
def test_bool():
boolean = soong.Bool(True)
assert repr(boolean) == 'Bool(true)'
assert str(boolean) == 'true'
assert boolean.to_str() == 'true'
================================================
FILE: docker/android/tests/test_util.py
================================================
import os
import sys
TEST_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECT_DIR = os.path.dirname(TEST_DIR)
sys.path.insert(0, PROJECT_DIR)
from android import util
def test_is_test():
assert not util.is_test('lib-non-test-defaults')
assert util.is_test('art-tests')
assert util.is_test('libgtest')
assert util.is_test('libgtest_main')
assert util.is_test('extra-tests')
def test_is_benchmark():
assert util.is_benchmark('benchmark')
assert util.is_benchmark('benchmarks')
assert util.is_benchmark('-benchmarks')
assert not util.is_benchmark('gbenchmarks')
================================================
FILE: docker/android/tox.ini
================================================
[tox]
envlist = py36,py3
skip_missing_interpreters = True
isolated_build = True
[testenv]
deps =
sly >= 0.4
google-re2 >= 1.0
pytest
toml
commands = pytest -o cache_dir={toxworkdir}/.pytest_cache
passenv =
PYTHONDONTWRITEBYTECODE
PYTHONPYCACHEPREFIX
PYTHON_EGG_CACHE
[flake8]
max-line-length = 100
ignore =
# we use lambdas for short, one-line conditions and formatters
E731
# opt-in to new behavior with operators after line breaks
W503
per-file-ignores =
# the sly grammar uses variables before they are defined via a metaclass
# likewise, it uses redefinitions to extend parsers via SLR grammar
android/soong.py: F811 F821
# need to add the project to the path for our tests and scripts
tests/*.py: E402
scripts/*.py: E402
================================================
FILE: docker/android-ndk.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch="${1}"
# python3 is still needed for newer NDK versions, just since it
# simplifies making symlinks even though the toolchain is prebuilt
install_packages curl python python3
get_ndk_info
if [[ "${NDK_VERSION}" -le 9 ]]; then
install_packages bzip2
else
install_packages unzip
fi
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "${NDK_URL}" -O
if [[ "${NDK_VERSION}" -le 9 ]]; then
tar -xjf "${NDK_FILENAME}"
else
unzip -q "${NDK_FILENAME}"
fi
rm "${NDK_FILENAME}"
pushd "android-ndk-${ANDROID_NDK}"
# android NDK versions <= 13 error without the verbose flag
local build_cmd=
local api=
if [[ "${NDK_VERSION}" -le 11 ]]; then
build_cmd=make-standalone-toolchain.sh
api=--platform="android-${ANDROID_SDK}"
else
build_cmd=make_standalone_toolchain.py
api=--api="${ANDROID_SDK}"
fi
"./build/tools/${build_cmd}" \
--install-dir=/android-ndk \
--arch="${arch}" \
"${api}" \
--verbose
# the android bash script installs the executables with 750, not 755
# permissions, and the other files without read permissions.
if [[ "${NDK_VERSION}" -le 11 ]]; then
chmod -R 755 /android-ndk/bin
chmod -R 755 /android-ndk/libexec
chmod -R +r /android-ndk
fi
# clean up unused toolchains to reduce image size
local triple
local triples
local triple_arch="${arch}"
case "${arch}" in
arm64)
triple_arch="aarch64"
;;
x86)
triple_arch="i686"
;;
esac
triples=(
"aarch64-linux-android"
"arm-linux-androideabi"
"i686-linux-android"
"x86_64-linux-android"
)
for triple in "${triples[@]}"; do
if ! [[ "${triple}" =~ ^"${triple_arch}".* ]]; then
rm -rf "/android-ndk/sysroot/usr/lib/${triple}"
fi
done
purge_packages
popd
popd
rm -rf "${td}"
rm "${0}"
}
get_ndk_info() {
local ndk_os=linux
local ndk_platform="${ndk_os}-x86_64"
# format is generally r21d, r25b, etc. it can however, be r24, for example.
NDK_VERSION=$(echo "${ANDROID_NDK}" | tr -dc '0-9')
# android NDK 23 and higher moved from `linux-x86_64` to `linux`
if [[ "${NDK_VERSION}" -ge 23 ]]; then
NDK_FILENAME="android-ndk-${ANDROID_NDK}-${ndk_os}.zip"
elif [[ "${NDK_VERSION}" -le 9 ]]; then
NDK_FILENAME="android-ndk-${ANDROID_NDK}-${ndk_platform}.tar.bz2"
else
NDK_FILENAME="android-ndk-${ANDROID_NDK}-${ndk_platform}.zip"
fi
if [[ "${NDK_VERSION}" -le 9 ]]; then
NDK_URL="https://dl.google.com/android/ndk/${NDK_FILENAME}"
else
NDK_URL="https://dl.google.com/android/repository/${NDK_FILENAME}"
fi
export NDK_VERSION
export NDK_FILENAME
export NDK_URL
}
main "${@}"
================================================
FILE: docker/android-runner
================================================
#!/usr/bin/env bash
set -e
# arch in the rust target
arch="${1}"
shift
if [ -n "${CROSS_DEBUG}" ]; then
set -x
fi
if [ "${CROSS_RUNNER}" = "" ]; then
CROSS_RUNNER=qemu-user
fi
# select android abi, and find the shared libc++ library
android_abi="${arch}-linux-android"
qarch="${arch}"
case "${arch}" in
arm)
android_abi="arm-linux-androideabi"
;;
i686)
qarch="i386"
qemu_args=("-cpu" "n270")
;;
x86_64)
qemu_args=("-cpu" "qemu64,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
;;
esac
libdir="/android-ndk/sysroot/usr/lib/${android_abi}"
# Android 5.x doesn't support C++.
if [[ -f "${libdir}/libc++_shared.so" ]]; then
export LD_PRELOAD="${libdir}/libc++_shared.so"
fi
case "${CROSS_RUNNER}" in
native)
exec "${@}"
;;
qemu-user)
exec "qemu-${qarch}" "${qemu_args[@]}" "${@}"
;;
*)
echo "Invalid runner: \"${CROSS_RUNNER}\"";
echo "Valid runners are: native and qemu-user"
exit 1
;;
esac
================================================
FILE: docker/android-symlink.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC2125,SC2207
set -x
set -euo pipefail
main() {
local arch="${1}"
local target="${2}"
local libdir="/android-ndk/lib64/clang/"*"/lib/linux/${arch}/"
local expanded=($(echo "/android-ndk/lib64/clang/"*"/lib/linux/${arch}/"))
if [[ "${#expanded[@]}" == "1" ]] && [[ "${expanded[0]}" != "${libdir}" ]]; then
libdir=$(realpath "/android-ndk/lib64/clang/"*"/lib/linux/${arch}/")
# In Android NDK versions r23-beta3, libgcc has been replaced by libunwind
# Older Rust versions always link to libgcc, so we need a symlink.
# https://github.com/rust-lang/rust/pull/85806
if [[ -f "${libdir}/libunwind.a" ]]; then
ln -s "${libdir}/libunwind.a" "${libdir}/libgcc.a"
fi
fi
# older SDK versions install the libraries directly in the lib directory.
local sysroot=/android-ndk/sysroot
local ndk_libdir="${sysroot}/usr/lib/${target}/"
if [[ "${ANDROID_SYSTEM_NONE}" != "1" ]]; then
if [[ -d "${ndk_libdir}/" ]]; then
cp "${ndk_libdir}/${ANDROID_SDK}/libz.so" /system/lib/
else
cp "${sysroot}/usr/lib/libz.so" /system/lib/
fi
fi
# later NDK versions switch to using `llvm-${tool}` rather than `${target}-tool`
# want to ensure we just have backwards-compatible aliases
local tool=
local tool_src=
local tool_dst=
for tool in ar as nm objcopy objdump ranlib readelf size string strip; do
tool_src="/android-ndk/bin/llvm-${tool}"
tool_dst="/android-ndk/bin/${target}-${tool}"
if [[ ! -f "${tool_dst}" ]] && [[ -f "${tool_src}" ]]; then
ln -s "${tool_src}" "${tool_dst}"
elif [[ "${tool}" == "ld" ]] && [[ ! -f "${tool_dst}" ]]; then
ln -s "/android-ndk/bin/${tool}" "${tool_dst}"
fi
done
# this is required for CMake builds, since the first pass doesn't
# add on the SDK API level to the linker search path. for example,
# it will set the linker search path to `${sysroot}/usr/lib/${target}/`,
# but not to `${sysroot}/usr/lib/${target}/${ANDROID_SDK}`. this isn't
# fixable seemingly with **any** environment variable or CMake option:
# cmake with `CMAKE_ANDROID_STANDALONE_TOOLCHAIN` seemingly ignores:
# - `LD_LIBRARY_PATH`
# - `CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES`
# - `CMAKE_C_COMPILER`
# - `CMAKE_CXX_COMPILER`
#
# running the cmake configuration a second time works, but this isn't
# adequate. the resulting config sets `CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES`
# but this is ignored in our toolchain file. likewise, not testing the
# compiler via `set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)` fails
# because during the build it will not add the API level to the linker
# search path.
local lib=
local libname=
if [[ -d "${ndk_libdir}" ]] && [[ -d "${ndk_libdir}/${ANDROID_SDK}" ]]; then
for lib in "${ndk_libdir}/${ANDROID_SDK}"/*; do
libname=$(basename "${lib}")
if [[ ! -f "${ndk_libdir}/${libname}" ]]; then
ln -s "${lib}" "${ndk_libdir}/${libname}"
fi
done
fi
rm "${0}"
}
main "${@}"
================================================
FILE: docker/android-system.sh
================================================
#!/usr/bin/env bash
# The API level details are mentioned here:
# https://developer.android.com/studio/releases/platforms
# These are controlled by `ANDROID_VERSION` and `ANDROID_SDK`,
# for example, `ANDROID_SDK=30` and `ANDROID_VERSION=11.0.0_r48`.
#
# You can also build the entire Android source tree with
# `ANDROID_SYSTEM_COMPLETE`, or skip it altogether with
# `ANDROID_SYSTEM_NONE`. Note that runners will not be
# available if the the Android system is not built.
#
# The versions are:
# 5.0: 21 (tested at NDK 10e and r13b, 5.0.0_r1)
# 5.1: 22 (tested at NDK r21d, 5.1.1_r38, unused DT)
# 6.0: 23 (tested at NDK r21dm 6.0.1_r81)
# 7.0: 24 (tested at NDK r21d, 7.0.0_r36)
# 7.1: 25 (tested at NDK r21d, 7.1.2_r39, not supported)
# 8.0: 26 (tested at NDK r21d, 8.0.0_r51)
# 8.1: 27 (tested at NDK r21d, 8.1.0_r81)
# 9.0: 28 (tested at NDK r21d and r25b, 9.0.0_r1)
# 10.0: 29 (tested at NDK r25b, 10.0.0_r47)
# 11.0: 30 (tested at NDK r25b, 11.0.0_r48)
# 12.0: 31 (unable to build at 12.0.0_r34)
# 12.1: 32 (unable to build at 12.1.0_r27)
# 13.0: 33
#
# API level 25 seems to be missing from Android NDK versions,
# and therefore is not supported.
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
export ARCH="${1}"
MAJOR_VERSION=$(echo "${ANDROID_VERSION}" | cut -d '.' -f 1)
MINOR_VERSION=$(echo "${ANDROID_VERSION}" | cut -d '.' -f 2)
TAG="android-${ANDROID_VERSION}"
export MAJOR_VERSION
export MINOR_VERSION
export TAG
if [[ "${ANDROID_SYSTEM_NONE}" == "1" ]]; then
rm -rf "${PYTHON_TMPDIR}"
rm "${0}"
return
fi
if [[ "${ANDROID_SYSTEM_COMPLETE}" != "1" ]] && [[ "${MAJOR_VERSION}" -ge 12 ]]; then
echo "Android versions 12 and higher couple APEX tightly into the build system." 1>&2
echo "These are currently unsupported, and are unlikely to ever be supported." 1>&2
echo "Try using a complete Android system build or disable building Android system." 1>&2
echo "Note that a complete Android system build is slow and creates massive images." 1>&2
echo "Disabling the Android system build will prevent the use of Android runners." 1>&2
echo "If you want support for newer versions, contributions are always appreciated." 1>&2
exit 1
elif [[ "${MAJOR_VERSION}" -eq 7 ]] && [[ "${MINOR_VERSION}" -eq 1 ]]; then
echo "Android version 7.1 is not supported." 1>&2
exit 1
fi
local td
td="$(mktemp -d)"
pushd "${td}"
fake_java
install_packages ca-certificates \
curl \
gcc-multilib \
git \
g++-multilib \
libncurses5 \
libtinfo5 \
make \
openssh-client \
python \
python3 \
xz-utils
curl --retry 3 -sSfL https://storage.googleapis.com/git-repo-downloads/repo -O
chmod +x repo
python3 ./repo init -u https://android.googlesource.com/platform/manifest -b "${TAG}"
local tools=(
cat chmod chown cmp cp ctrlaltdel date df dmesg du hd id ifconfig
iftop insmod ioctl ionice kill ln log ls lsmod lsof lsusb md5 mkdir
mount mv nandread netstat notify printenv ps reboot renice rm rmdir
rmmod route schedtop sendevent setconsole setprop sleep smd start
stop sync top touch umount uptime vmstat watchprops wipe
)
if [[ "${ANDROID_SYSTEM_COMPLETE}" == "1" ]]; then
android_repo_complete
else
case "${MAJOR_VERSION}" in
5)
android_repo_v5
tools+=(dd getevent getprop grep newfs_msdos)
;;
6)
android_repo_v6
;;
7)
android_repo_v7
;;
8)
android_repo_v8
;;
9)
android_repo_v9
;;
10)
android_repo_v10
;;
11)
android_repo_v11
;;
*)
echo "Currently unsupported Android version ${MAJOR_VERSION}." 1>&2
echo "Please submit a feature request if you need support." 1>&2
exit 1
;;
esac
fi
build_android
install_android "${tools[@]}"
remove_java
purge_packages
popd
rm -rf "${td}"
rm -rf "${PYTHON_TMPDIR}"
rm "${0}"
}
# java isn't required for the build, but the build expects to
# find a java compiler. the supported android versions are:
# https://source.android.com/docs/setup/start/older-versions
# Android 7: OpenJDK-8
fake_java() {
local java_type=
local java_version=
local jre_info=
local build_info=
case "${MAJOR_VERSION}" in
5|6)
java_type=java
java_version=1.7.0
jre_info="IcedTea 2.6.9"
build_info="build 24.131-b00, mixed mode"
;;
*)
java_type=openjdk
java_version=1.8.0_342
jre_info="build 1.8.0_342-8u342-b07-0ubuntu1~20.04-b07"
build_info="build 25.342-b07, mixed mode"
;;
esac
cat << EOF > /usr/bin/java
#!/usr/bin/env bash
echo "${java_type} version \"${java_version}\""
echo "OpenJDK Runtime Environment (${jre_info})"
echo "OpenJDK 64-Bit Server VM (${build_info})"
EOF
cat << EOF > /usr/bin/javac
#!/usr/bin/env bash
echo "javac ${java_version}"
EOF
chmod +x /usr/bin/java
chmod +x /usr/bin/javac
# more faking
export ANDROID_JAVA_HOME=/tmp
mkdir -p /tmp/lib/
touch /tmp/lib/tools.jar
}
remove_java() {
rm /usr/bin/java
rm /usr/bin/javac
rm /tmp/lib/tools.jar
}
build_android() {
if [[ "${ANDROID_SYSTEM_COMPLETE}" != "1" ]]; then
export ALLOW_MISSING_DEPENDENCIES=true
fi
set +u
# shellcheck disable=SC1091
source build/envsetup.sh
lunch "aosp_${ARCH}-user"
if [[ "${ANDROID_SYSTEM_COMPLETE}" != "1" ]]; then
mmma bionic/
mmma external/mksh/
mmma system/core/toolbox/
else
mma
fi
if [[ "${ANDROID_SYSTEM_COMPLETE}" != "1" ]] && [[ "${MAJOR_VERSION}" -ge 11 ]]; then
# for some reason, building bionic doesn't build linker64 on the first pass
# doing a partial build and a rebuild is just as fast though.
rm -rf out/target/product/generic
mmma bionic/
fi
set -u
}
install_android() {
local outdir=
if [[ "${ARCH}" = "arm" ]]; then
outdir=out/target/product/generic
else
outdir="out/target/product/generic_${ARCH}"
fi
mv "${outdir}/system/" /
if [[ "${ANDROID_SYSTEM_COMPLETE}" == "1" ]] && [[ -d "${outdir}/apex" ]]; then
# can use the APEX linker, no need to use the bootstrap one
mv "${outdir}/apex/" /
elif [[ "${MAJOR_VERSION}" -ge 10 ]]; then
symlink_bootstrap
fi
# list from https://elinux.org/Android_toolbox
local tool=
for tool in "${@}"; do
if [[ ! -f "/system/bin/${tool}" ]]; then
ln -s /system/bin/toolbox "/system/bin/${tool}"
fi
done
echo "127.0.0.1 localhost" > /system/etc/hosts
}
symlink_bootstrap() {
# for Android 10+, we need to use the bootstrap linker rather than
# the APEX linker, which is gigantic. we also symlink the ASAN
# linker just in case using the bootstrapped one.
local linker
local file
if compgen -G /system/bin/bootstrap/* >/dev/null 2>&1; then
for linker in /system/bin/bootstrap/*; do
file=$(basename "${linker}")
unlink "/system/bin/${file}"
ln -s "/system/bin/bootstrap/${file}" "/system/bin/${file}"
done
fi
# also need to ensure the shared libraries aren't symlinks
local lib
local libdir
for libdir in /system/lib{,64}; do
if compgen -G "${libdir}/bootstrap/"* >/dev/null 2>&1; then
for lib in "${libdir}/bootstrap/"*; do
file=$(basename "${lib}")
unlink "${libdir}/${file}"
ln -s "${libdir}/bootstrap/${file}" "${libdir}/${file}"
done
fi
done
}
# this are the minimum set of modules that are need to build bionic
# this was created by trial and error. this is based on the minimum
# set of modules required for each android version, starting with
# a minimal number of dependencies. for android 10+ versions, we use
# the bootstrap linker rather than the APEX linker for non-complete
# system builds, as the APEX linker drags in nearly the entire Android
# runtime, requiring 60+GB images. for minimal builds, we need to avoid
# APEX altogether, and this gets trickier starting in Android 10
# and much more difficult in newer versions.
android_repo_complete() {
python3 ./repo sync -c
}
# tested on 5.0.0_r1 (SDK 21)
# tested on 5.1.1_r38 (SDK 22)
android_repo_v5() {
sync bionic
sync build
sync external/compiler-rt
sync external/jemalloc
sync external/libcxx
sync external/libcxxabi
sync external/libselinux
sync external/mksh
sync external/openssl
sync external/pcre
sync external/stlport
sync prebuilts/clang/linux-x86/host/3.5
sync system/core
case "${ARCH}" in
arm)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8
;;
arm64)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.8
;;
esac
# avoid build tests
rm bionic/linker/tests/Android.mk
rm bionic/tests/Android.mk
rm bionic/benchmarks/Android.mk
# patch the linker to avoid the error
# FATAL: kernel did not supply AT_SECURE
sed -i -e 's/if (!kernel_supplied_AT_SECURE)/if (false)/g' bionic/linker/linker_environ.cpp
}
# tested on 6.0.1_r81 (SDK 23)
android_repo_v6() {
sync bionic
sync build
sync external/compiler-rt
sync external/elfutils
sync external/jemalloc
sync external/libcxx
sync external/libcxxabi
sync external/libselinux
sync external/mksh
sync external/pcre
sync external/safe-iop
sync external/zlib
sync libnativehelper
sync prebuilts/clang/linux-x86/host/3.6
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
sync prebuilts/misc
sync system/core
case "${ARCH}" in
arm)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/linker/tests/Android.mk
rm bionic/tests/Android.mk
rm bionic/benchmarks/Android.mk
# we don't need the relocation packer, and removing
# the unittests from it is a bit of work.
rm bionic/tools/relocation_packer/Android.mk
}
# tested on 7.0.0_r36 (SDK 24)
# tested on 7.1.2_r39 (SDK 25, not supported)
# API level 25, requires for Android 7.1, is not provided in NDKs
android_repo_v7() {
sync bionic
sync build
sync build/kati
sync external/boringssl
sync external/compiler-rt
sync external/elfutils
sync external/jemalloc
sync external/libcxx
sync external/libcxxabi
sync external/libselinux
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/mksh
sync external/pcre
sync external/safe-iop
sync external/zlib
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
sync prebuilts/misc
sync prebuilts/ndk
sync prebuilts/ninja/linux-x86
sync system/core
case "${ARCH}" in
arm)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/linker/tests/Android.mk
rm bionic/tests/Android.mk
rm bionic/benchmarks/Android.mk
rm prebuilts/misc/common/android-support-test/Android.mk
# we don't need the relocation packer, and removing
# the unittests from it is a bit of work.
rm bionic/tools/relocation_packer/Android.mk
remove_tests
}
# tested on 8.0.0_r51 (SDK 26)
# tested on 8.1.0_r81 (SDK 27)
android_repo_v8() {
# need to build LLVM components, or libLLVM is disabled.
export FORCE_BUILD_LLVM_COMPONENTS=true
sync bionic
sync build/blueprint
sync build/make
sync build/soong
sync external/boringssl
sync external/clang
sync external/compiler-rt
sync external/elfutils
sync external/jemalloc
sync external/libcxx
sync external/libcxxabi
sync external/libevent
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/lzma
sync external/mksh
sync external/pcre
sync external/safe-iop
sync external/selinux
sync external/zlib
sync libnativehelper
sync prebuilts/build-tools
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
sync prebuilts/go/linux-x86
# we only need the relocation packer binary. everything else
# interferes with the build, so we remove the makefiles below.
sync prebuilts/misc
sync prebuilts/ndk
sync system/core
sync toolchain/binutils
case "${ARCH}" in
arm)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/linker/tests/Android.mk
rm bionic/tests/Android.mk
rm bionic/tests/Android.bp
rm bionic/benchmarks/Android.bp
rm bionic/tests/libs/Android.bp
# remove extra utilities
rm system/core/libgrallocusage/Android.bp
rm system/core/libmemtrack/Android.bp
rm system/core/libsysutils/Android.bp
local path=
find prebuilts/misc/ -name 'Android.mk' | while IFS= read -r path; do
rm "${path}"
done
# avoid java dependencies
rm external/lzma/Java/Tukaani/Android.mk
remove_tests
}
# tested on 9.0.0_r1 (SDK 28)
android_repo_v9() {
sync art
sync bionic
sync build/blueprint
sync build/make
sync build/soong
sync external/clang
sync external/compiler-rt
sync external/elfutils
sync external/jemalloc
sync external/libcxx
sync external/libcxxabi
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/lzma
sync external/mksh
sync external/safe-iop
sync external/valgrind
sync external/vixl
sync external/zlib
sync frameworks/hardware/interfaces
sync hardware/interfaces
sync libnativehelper
sync prebuilts/build-tools
sync prebuilts/clang-tools
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
sync prebuilts/go/linux-x86
sync prebuilts/misc
sync prebuilts/sdk
sync system/core
sync system/libhidl
sync system/tools/hidl
case "${ARCH}" in
arm)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/linker/tests/Android.mk
rm bionic/tests/Android.mk
rm bionic/tests/Android.bp
rm bionic/benchmarks/Android.bp
rm bionic/tests/libs/Android.bp
rm bionic/tests/headers/Android.bp
rm bionic/tests/headers/posix/Android.bp
remove_tests
}
# tested on 10.0.0_r47 (SDK 29)
android_repo_v10() {
sync art
sync bionic
sync build/blueprint
sync build/make
sync build/soong
sync external/clang
sync external/compiler-rt
sync external/elfutils
sync external/golang-protobuf
sync external/jemalloc
sync external/jemalloc_new
sync external/libcxx
sync external/libcxxabi
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/lzma
sync external/mksh
sync external/vixl
sync external/zlib
sync libnativehelper
sync prebuilts/build-tools
sync prebuilts/clang-tools
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8
sync prebuilts/go/linux-x86
sync prebuilts/ndk
sync prebuilts/sdk
sync prebuilts/vndk/v28
sync system/core
sync system/sepolicy
case "${ARCH}" in
arm)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/tests/Android.mk
rm bionic/tests/Android.bp
rm bionic/benchmarks/Android.bp
rm bionic/tests/libs/Android.bp
rm bionic/tests/headers/Android.bp
rm bionic/tests/headers/posix/Android.bp
remove_tests
}
android_repo_v11() {
sync art
sync bionic
sync bootable/recovery
sync build/blueprint
sync build/make
sync build/soong
sync external/clang
sync external/compiler-rt
sync external/elfutils
sync external/fmtlib
sync external/golang-protobuf
sync external/gwp_asan
sync external/jemalloc
sync external/jemalloc_new
sync external/libcxx
sync external/libcxxabi
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/lzma
sync external/mksh
sync external/scudo
sync external/zlib
sync prebuilts/build-tools
sync prebuilts/clang-tools
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8
sync prebuilts/go/linux-x86
sync prebuilts/sdk
sync prebuilts/vndk/v28
sync prebuilts/vndk/v29
sync system/core
sync system/sepolicy
case "${ARCH}" in
arm)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/tests/Android.mk
rm bionic/tests/Android.bp
rm bionic/benchmarks/Android.bp
rm bionic/tests/libs/Android.bp
rm bionic/tests/headers/Android.bp
rm bionic/tests/headers/posix/Android.bp
# make sure we don't build benchmarks or apex
rm -r bionic/apex
rm -r bionic/benchmarks/
# libziparchive has tests in the header, remove them
local libziparchive_h="system/core/libziparchive/include/ziparchive/zip_writer.h"
sed -i -e 's/#include //g' "${libziparchive_h}"
sed -i -e 's/FRIEND_TEST(zipwriter, WriteToUnseekableFile);//g' "${libziparchive_h}"
remove_tests
}
android_repo_v12() {
# FIXME: this is a work in progress, and is unlikely to ever
# be completed, since apex is now heavily integrated into the
# build system. `external/mksh` and `system/core/toolbox` build,
# however, `bionic`, the most import module, does not.
#
# the error messages are of the following:
# internal error: panic in GenerateBuildActions for module "com.android.example.apex" variant "android_common_com.android.example.apex_image"
# fixing this requires either a comprehensive removal of APEX from the build
# or adding numerous APEX dependencies, which defeats the purpose of a
# minimal bionic build.
sync art
sync bionic
sync build/blueprint
sync build/make
sync build/soong
sync external/apache-xml
sync external/bouncycastle
sync external/clang
sync external/compiler-rt
sync external/conscrypt
sync external/elfutils
sync external/fmtlib
sync external/golang-protobuf
sync external/gwp_asan
sync external/icu
sync external/jemalloc
sync external/jemalloc_new
sync external/libcxx
sync external/libcxxabi
sync external/libunwind
sync external/libunwind_llvm
sync external/llvm
sync external/lzma
sync external/mksh
sync external/okhttp
sync external/scudo
sync external/starlark-go
sync external/zlib
sync libcore
sync prebuilts/build-tools
sync prebuilts/clang-tools
sync prebuilts/clang/host/linux-x86
sync prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8
sync prebuilts/go/linux-x86
sync prebuilts/sdk
sync prebuilts/vndk/v28
sync prebuilts/vndk/v29
sync prebuilts/vndk/v30
sync system/core
sync system/libbase
sync system/linkerconfig
sync system/logging
sync system/sepolicy
sync system/tools/xsdc
sync tools/metalava
# these tools also seem to be required, since apex is now tightly
# coupled with the bionic build. unfortunately, we want to avoid
# building apex at all costs.
#sync system/apex
#sync system/tools/aidl
case "${ARCH}" in
arm)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
;;
arm64)
sync external/arm-optimized-routines
sync prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
sync prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
;;
x86)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
x86_64)
sync prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
;;
esac
# avoid build tests
rm bionic/tests/Android.mk
rm bionic/tests/Android.bp
rm bionic/benchmarks/Android.bp
rm bionic/tests/libs/Android.bp
rm bionic/tests/headers/Android.bp
rm bionic/tests/headers/posix/Android.bp
# make sure we don't build benchmarks or apex
rm -r bionic/apex
rm -r bionic/benchmarks/
rm -r bionic/tests/
rm -r system/linkerconfig/testmodules
remove_tests
}
remove_tests() {
install_packages python3-pip
local version=
version=$(python3 -c 'import sys
major = sys.version_info.major
minor = sys.version_info.minor
print(f"{major}.{minor}")')
set +u
export PYTHONPATH="${PYTHON_TMPDIR}/lib/python${version}/site-packages/:${PYTHONPATH}"
set -u
mkdir -p "${PYTHON_TMPDIR}"
python3 -m pip install sly==0.4.0 --prefix "${PYTHON_TMPDIR}"
python3 -m pip install google-re2==1.0 --prefix "${PYTHON_TMPDIR}"
python3 "${PYTHON_TMPDIR}/scripts/build-system.py" \
--remove-tests \
--verbose
}
sync() {
python3 ./repo sync -c --no-clone-bundle "${1}"
}
main "${@}"
================================================
FILE: docker/android.cmake
================================================
# toolchain file for android targets, see #1110
set(CMAKE_SYSTEM_NAME "$ENV{CROSS_CMAKE_SYSTEM_NAME}")
set(CMAKE_SYSTEM_PROCESSOR "$ENV{CROSS_CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN /android-ndk)
set(CMAKE_ANDROID_API "$ENV{CROSS_ANDROID_SDK}")
if(DEFINED ENV{CROSS_TARGET_RUNNER})
set(runner "$ENV{CROSS_TARGET_RUNNER}")
separate_arguments(runner)
set(CMAKE_CROSSCOMPILING_EMULATOR ${runner})
endif()
# these are cached so any build system that compiled outside of the rust
# build system, such as a third-party cmake build and install of a shared
# library, will still work. however, cmake-rs can override these values
if(DEFINED ENV{CROSS_CMAKE_OBJECT_FLAGS})
set(CMAKE_C_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "C Compiler options")
set(CMAKE_CXX_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "C++ Compiler options")
set(CMAKE_ASM_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "ASM Compiler options")
endif()
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_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
================================================
FILE: docker/apt-cross-essential.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local narch
local -a packages
narch="$(dpkg --print-architecture)"
packages+=("libc6-dev-${TARGET_ARCH}-cross:${narch}")
# Install crossbuild-essential if CROSSBUILD_ESSENTIAL is set
if [ -n "${CROSSBUILD_ESSENTIAL:-}" ]; then
packages+=("crossbuild-essential-${TARGET_ARCH}:${narch}")
fi
if ! command -v "${CROSS_TOOLCHAIN_PREFIX}g++" &>/dev/null; then
packages+=("g++-${TARGET_TRIPLE}:${narch}")
fi
if ! command -v "${CROSS_TOOLCHAIN_PREFIX}gfortran" &>/dev/null; then
packages+=("gfortran-${TARGET_TRIPLE}:${narch}")
fi
install_packages "${packages[@]}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/base-runner.sh
================================================
#!/usr/bin/env bash
host_architecture() {
# there's numerous compatibility modes, so we want
# to ensure that these are valid. we also want to
# use dpkg if it's available since it gives hard-float
# information on compatible architectures
local host
local arch
if dpkg >/dev/null 2>&1; then
host=$(dpkg --print-architecture)
arch="${host}"
else
host=$(uname -m)
arch="${host}"
case "${arch}" in
aarch64|armv8b|armv8l)
arch=arm64
;;
aarch64_be)
arch=arm64be
;;
arm*)
arch=unknown
;;
ppc)
arch=powerpc
;;
ppc64le)
arch=ppc64el
;;
s390)
arch=s390x
;;
i?86)
arch=i386
;;
x64|x86_64)
arch=amd64
;;
*)
;;
esac
fi
echo "${arch}"
}
normalize_arch() {
local arch="${1}"
local debian
debian="${arch}"
case "${arch}" in
aarch64)
debian=arm64
;;
x86_64)
debian=amd64
;;
arm)
debian=armel
;;
armv7)
debian=arm
;;
armv7hf)
debian=armhf
;;
i?86)
debian=i386
;;
powerpc64)
debian=ppc64
;;
powerpc64le)
debian=ppc64el
;;
riscv64*)
debian=riscv64
;;
*)
;;
esac
echo "${debian}"
}
is_native_binary() {
# determines if the binary can run natively on the host
local arch="${1}"
local host
local target
host=$(host_architecture)
target=$(normalize_arch "${arch}")
# FIXME: this is not comprehensive. add more compatible architectures.
case "${host}" in
amd64)
if [[ "${target}" == i386 ]] || [[ "${target}" == amd64 ]]; then
return 0
fi
;;
*)
if [[ "${host}" == "${target}" ]]; then
return 0
fi
;;
esac
return 1
}
qemu_arch() {
# select qemu arch
local arch="${1}"
local qarch="${arch}"
case "${arch}" in
arm|armhf|armv7|armv7hf)
qarch="arm"
;;
i?86)
qarch="i386"
;;
powerpc)
qarch="ppc"
;;
powerpc64)
qarch="ppc64"
;;
powerpc64le)
if [ "${CROSS_RUNNER}" = "qemu-user" ]; then
qarch="ppc64le"
else
qarch="ppc64"
fi
;;
esac
echo "${qarch}"
}
================================================
FILE: docker/cmake.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local version=3.23.1
install_packages curl
local td
td="$(mktemp -d)"
pushd "${td}"
local cmake_arch
local cmake_sha256
local narch
narch="$(uname -p)"
echo "[INFO] $narch"
case "${narch}" in
x86_64)
cmake_arch="linux-x86_64"
cmake_sha256="da2a9b18c3bfb136917fa1a579aa5316b01c1d6c111043d03f18877ff05bda30"
;;
arm64)
cmake_arch="linux-aarch64"
cmake_sha256="86122bdfd030208aa36705ef421a218ccec52a14368020b2d67043af5e45490b"
;;
*)
echo "Unsupported architecture: ${narch}" 1>&2
exit 1
;;
esac
curl --retry 3 -sSfL "https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-${cmake_arch}.sh" -o cmake.sh
sha256sum --check <<<"${cmake_sha256} cmake.sh"
sh cmake.sh --skip-license --prefix=/usr/local
cmake --version
popd
purge_packages
rm -rf "${td}"
rm -rf /var/lib/apt/lists/*
rm "${0}"
}
main "${@}"
================================================
FILE: docker/common.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
# For non-native architectures, look for packages on ports.ubuntu.com instead.
# This is important if you enable additional architectures so you can install libraries to cross-compile against.
# Look for 'dpkg --add-architecture' in the README for more details.
if grep -i ubuntu /etc/os-release >/dev/null; then
NATIVE_ARCH=$(dpkg --print-architecture)
if [ "$NATIVE_ARCH" = "amd64" ]; then
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list
else
sed -i "s/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=${NATIVE_ARCH}] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g" /etc/apt/sources.list
sed -i "s/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=${NATIVE_ARCH}] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g" /etc/apt/sources.list
fi
fi
install_packages \
autoconf \
automake \
binutils \
ca-certificates \
curl \
file \
gcc \
git \
libtool \
m4 \
make
if_centos install_packages \
clang-devel \
gcc-c++ \
gcc-gfortran \
glibc-devel \
pkgconfig
if_ubuntu install_packages \
g++ \
gfortran \
libc6-dev \
libclang-dev \
pkg-config
================================================
FILE: docker/cross.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091
set -x
set -euo pipefail
. lib.sh
main() {
local project_dir="${1}"
install_packages ca-certificates curl gcc libc6-dev
cd "${project_dir}"
curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y
source "${HOME}"/.cargo/env
cargo install --path . --locked
purge_packages
rm -rf "${0}"
}
main "${@}"
================================================
FILE: docker/crosstool-config/aarch64_be-unknown-linux-gnu.config
================================================
CT_CONFIG_VERSION="4"
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_DOWNLOAD_AGENT_CURL=y
CT_ARCH_ARM=y
CT_ARCH_64=y
CT_ARCH_BE=y
CT_ARCH_FLOAT_HW=y
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_GLIBC_V_2_36=y
# CT_GLIBC_NO_VERSIONS is not set
CT_GLIBC_VERSION="2.36"
CT_GLIBC_2_17_or_later=y
CT_GLIBC_later_than_2_14=y
CT_GLIBC_2_14_or_later=y
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
================================================
FILE: docker/crosstool-config/arm-unknown-linux-gnueabihf.config
================================================
CT_CONFIG_VERSION="4"
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_DOWNLOAD_AGENT_CURL=y
CT_ARCH_ARM=y
CT_ARCH_ARCH="armv6"
CT_ARCH_FPU="vfp"
CT_ARCH_FLOAT_HW=y
CT_KERNEL_LINUX=y
CT_LINUX_V_4_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="4.19.287"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_BINUTILS_V_2_32=y
CT_GLIBC_V_2_31=y
# CT_GLIBC_NO_VERSIONS is not set
CT_GLIBC_VERSION="2.31"
CT_GLIBC_2_17_or_later=y
CT_GLIBC_later_than_2_14=y
CT_GLIBC_2_14_or_later=y
CT_GCC_V_8=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="8.5.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_LANG_CXX=y
CT_GETTEXT_V_0_19_8_1=y
CT_GMP_V_6_1=y
CT_ISL_V_0_20=y
CT_LIBICONV_V_1_15=y
CT_NCURSES_V_6_1=y
CT_CC_LANG_FORTRAN=y
================================================
FILE: docker/crosstool-config/loongarch64-unknown-linux-gnu.config
================================================
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_GLIBC_V_2_36=y
# CT_GLIBC_NO_VERSIONS is not set
CT_GLIBC_VERSION="2.36"
CT_GLIBC_2_17_or_later=y
CT_GLIBC_later_than_2_14=y
CT_GLIBC_2_14_or_later=y
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
================================================
FILE: docker/crosstool-config/loongarch64-unknown-linux-musl.config
================================================
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_LOONGARCH=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="loongarch64"
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_LIBC_MUSL=y
CT_MUSL_V_1_2_5=y
# CT_MUSL_NO_VERSIONS is not set
CT_MUSL_VERSION="1.2.5"
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
================================================
FILE: docker/crosstool-config/riscv64gc-unknown-linux-musl.config
================================================
CT_CONFIG_VERSION="4"
CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_ARCH_RISCV=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_ARCH="rv64g"
CT_ARCH_64=y
CT_KERNEL_LINUX=y
CT_LINUX_V_5_19=y
# CT_LINUX_NO_VERSIONS is not set
CT_LINUX_VERSION="5.19.16"
CT_LINUX_later_than_4_8=y
CT_LINUX_4_8_or_later=y
CT_LINUX_later_than_3_7=y
CT_LINUX_3_7_or_later=y
CT_LINUX_later_than_3_2=y
CT_LINUX_3_2_or_later=y
CT_LIBC_MUSL=y
CT_MUSL_V_1_2_5=y
# CT_MUSL_NO_VERSIONS is not set
CT_MUSL_VERSION="1.2.5"
CT_GCC_V_14=y
# CT_GCC_NO_VERSIONS is not set
CT_GCC_VERSION="14.2.0"
CT_GCC_later_than_7=y
CT_GCC_7_or_later=y
CT_GCC_later_than_6=y
CT_GCC_6_or_later=y
CT_GCC_later_than_5=y
CT_GCC_5_or_later=y
CT_GCC_later_than_4_9=y
CT_GCC_4_9_or_later=y
CT_GCC_later_than_4_8=y
CT_GCC_4_8_or_later=y
CT_CC_GCC_ENABLE_DEFAULT_PIE=y
CT_CC_LANG_CXX=y
CT_CC_LANG_FORTRAN=y
================================================
FILE: docker/crosstool-ng.sh
================================================
#!/bin/bash
set -x
set -eo pipefail
# shellcheck disable=SC1091
. lib.sh
silence_stdout() {
if [[ "${VERBOSE}" == "1" ]]; then
"${@}"
else
"${@}" >/dev/null
fi
}
main() {
local config="${1}"
local nproc="${2}"
local ctng_version=${3:-crosstool-ng-1.27.0}
local ctng_url="https://github.com/crosstool-ng/crosstool-ng"
local username=crosstool
local crosstooldir=/opt/crosstool
local buildir
local srcdir="/home/${username}/src"
local dstdir="/x-tools"
local sleep=15s
local timeout=5m
install_packages \
adduser \
autoconf \
bison \
bzip2 \
curl \
flex \
gawk \
help2man \
libncurses-dev \
libtool-bin \
patch \
python3 \
python3-dev \
python3-pip \
rsync \
texinfo \
wget \
unzip \
xz-utils
# configure and install crosstool-ng
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "crosstool-ng-${ctng_version}"
pushd "crosstool-ng-${ctng_version}"
git init
git fetch --depth=1 "${ctng_url}" "${ctng_version}"
git reset --hard FETCH_HEAD
./bootstrap
./configure --prefix="${crosstooldir}"
make -j"${nproc}"
make install
popd
popd
# configure and install our toolchain
buildir="$(mktemp -d)"
# copy our config files, and make sure the l
# crosstool-ng can't be run as root, so we do this instead.
adduser --disabled-password --gecos "" "${username}"
chown -R "${username}":"${username}" "${buildir}"
pushd "${buildir}"
cp /"${config}" .config
chown "${username}":"${username}" .config
su "${username}" -c "${crosstooldir}/bin/ct-ng olddefconfig"
# the download steps can stall indefinitely, so we want to set a timeout to
# ensure it always completes. we therefore attempt to download until
# this step completes or fails. the built toolchain installs to `/x-tools`.
mkdir -p "${dstdir}"
chown -R "${username}":"${username}" "${dstdir}"
local step=companion_tools_for_build
su "${username}" -c "mkdir -p ${srcdir}"
download() {
# timeout is a command, not a built-in, so it won't
# work with any bash functions: must call a command.
timeout "${timeout}" \
su "${username}" -c \
"STOP=${step} CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc}"
}
while silence_stdout download; [ $? -eq 124 ]; do
# Indicates a timeout, repeat the command.
sleep "${sleep}"
done
silence_stdout su "${username}" \
-c "CT_DEBUG_CT_SAVE_STEPS=1 ${crosstooldir}/bin/ct-ng build.${nproc}"
popd
purge_packages
rm -rf "${srcdir}"
rm -rf "${buildir}"
rm -rf "${crosstooldir}"
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/deny-debian-packages.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
deny_package() {
local package="${1}"
local filename="${2}"
echo "Package: ${package}:${TARGET_ARCH}
Pin: release *
Pin-Priority: -1" > "/etc/apt/preferences.d/${filename}"
}
main() {
if [[ $# -eq 0 ]]; then
deny_package '*' "all-packages"
else
local package
for package in "${@}"; do
deny_package "${package}" "${package}"
echo "${package}"
done
fi
rm "${0}"
}
main "${@}"
================================================
FILE: docker/dragonfly.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local nproc=
local binutils=2.32 \
dragonfly=6.0.1_REL \
gcc=10.3.0 \
target=x86_64-unknown-dragonfly
if [[ $# != "0" ]]; then
nproc="${1}"
fi
install_packages libarchive-tools \
bzip2 \
ca-certificates \
curl \
g++ \
make \
patch \
wget \
xz-utils
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/dragonfly"
download_binutils "${binutils}" "bz2"
tar -C "${td}/binutils" --strip-components=1 -xjf "binutils-${binutils}.tar.bz2"
download_gcc "${gcc}" "gz"
tar -C "${td}/gcc" --strip-components=1 -xf "gcc-${gcc}.tar.gz"
cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
patch libstdc++-v3/configure <<'EOF'
47159c47159
< *-freebsd*)
---
> *-freebsd* | *-dragonfly*)
EOF
cd ..
local mirrors=(
"https://mirror-master.dragonflybsd.org/iso-images"
"https://avalon.dragonflybsd.org/iso-images/"
)
download_mirrors "" "dfly-x86_64-${dragonfly}.iso.bz2" "${mirrors[@]}"
bzcat "dfly-x86_64-${dragonfly}.iso.bz2" | bsdtar xf - -C "${td}/dragonfly" ./usr/include ./usr/lib ./lib
cd binutils-build
../binutils/configure \
--target="${target}"
make "-j${nproc}"
make install
cd ..
# note: shell expansions can't be quoted
local destdir="/usr/local/${target}"
cp -r "${td}/dragonfly/usr/include" "${destdir}"/
cp "${td}/dragonfly/lib/libc.so.8" "${destdir}/lib"
cp "${td}/dragonfly/lib/libm.so.4" "${destdir}/lib"
cp "${td}/dragonfly/lib/libutil.so.4" "${destdir}/lib"
cp "${td}/dragonfly/usr/lib/libexecinfo.so.1" "${destdir}/lib"
cp "${td}/dragonfly/usr/lib/libpthread.so" "${destdir}/lib/libpthread.so"
cp "${td}/dragonfly/usr/lib/librt.so.0" "${destdir}/lib"
cp "${td}"/dragonfly/usr/lib/lib{c,m,util,kvm}.a "${destdir}/lib"
cp "${td}/dragonfly/usr/lib/thread/libthread_xu.so.2" "${destdir}/lib/libpthread.so.0"
cp "${td}"/dragonfly/usr/lib/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib/"
ln -s libc.so.8 "${destdir}/lib/libc.so"
ln -s libexecinfo.so.1 "${destdir}/lib/libexecinfo.so"
ln -s libm.so.4 "${destdir}/lib/libm.so"
ln -s librt.so.0 "${destdir}/lib/librt.so"
ln -s libutil.so.4 "${destdir}/lib/libutil.so"
cd gcc-build
../gcc/configure \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,fortran \
--target="${target}"
make "-j${nproc}"
make install
cd ..
# rust incorrectly adds link args to libgcc_pic, which is no longer
# a present target, and it should link to libgcc_s.
# https://github.com/rust-lang/rust/blob/60361f2/library/unwind/build.rs#L23-L38
ln -s "${destdir}"/lib/libgcc_s.so "${destdir}"/lib/libgcc_pic.so
# clean up
popd
purge_packages
# store the version info for the dragonfly release
echo "${dragonfly}" > /opt/dragonfly-version
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/dropbear.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local version=2022.82
local mirrors=(
"https://matt.ucc.asn.au/dropbear/releases"
"https://mirror.dropbear.nl/mirror"
)
install_packages \
autoconf \
automake \
bzip2 \
curl \
make
if_centos install_packages zlib-devel
if_ubuntu install_packages zlib1g-dev
local td
td="$(mktemp -d)"
pushd "${td}"
download_mirrors "" "dropbear-${version}.tar.bz2" "${mirrors[@]}"
tar --strip-components=1 -xjf "dropbear-${version}.tar.bz2"
# Remove some unwanted message
sed -i '/skipping hostkey/d' cli-kex.c
sed -i '/failed to identify current user/d' cli-runopts.c
./configure \
--disable-syslog \
--disable-shadow \
--disable-lastlog \
--disable-utmp \
--disable-utmpx \
--disable-wtmp \
--disable-wtmpx \
--disable-pututline \
--disable-pututxline
make "-j$(nproc)" PROGRAMS=dbclient
cp dbclient /usr/local/bin/
purge_packages
popd
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/emscripten.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
install_packages ca-certificates \
curl \
git \
libxml2 \
python
cd /
git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
cd /emsdk-portable
./emsdk install 1.38.46-upstream
./emsdk activate 1.38.46-upstream
# Compile and cache libc
echo 'int main() {}' > a.c
emcc a.c
emcc -s BINARYEN=1 a.c
echo -e '#include \n void hello(){ std::cout << std::endl; }' > a.cpp
emcc a.cpp
emcc -s BINARYEN=1 a.cpp
rm -f a.*
# Make emsdk usable by any user
chmod a+rwX -R "${EMSDK}"
purge_packages
rm "${0}"
}
main "${@}"
================================================
FILE: docker/freebsd-common.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. /freebsd-arch.sh
export FREEBSD_ARCH=
case "${ARCH}" in
aarch64) # releases are under http://ftp.freebsd.org/pub/FreeBSD/releases/
FREEBSD_ARCH=arm64 # http://ftp.freebsd.org/pub/FreeBSD/releases/arm64/
;;
x86_64)
FREEBSD_ARCH=amd64
;;
i686)
FREEBSD_ARCH=i386
;;
esac
export FREEBSD_MAJOR=13
================================================
FILE: docker/freebsd-extras.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. /lib.sh
# shellcheck disable=SC1091
. /freebsd-common.sh
# shellcheck disable=SC1091
. /freebsd-install.sh
case "${FREEBSD_ARCH}" in
arm64) # extras mirrors are under https://pkg.freebsd.org/
FREEBSD_ARCH=aarch64 # https://pkg.freebsd.org/FreeBSD:13:aarch64/
;;
esac
main() {
apt-get update && apt-get install --assume-yes --no-install-recommends \
curl \
dnsutils \
jq \
xz-utils \
zstd
local url=
url=$(fetch_best_freebsd_mirror)
FREEBSD_MIRROR="${url}" setup_freebsd_packagesite
FREEBSD_MIRROR="${url}" install_freebsd_package openssl sqlite3
rm "${0}"
}
main "${@}"
================================================
FILE: docker/freebsd-fetch-best-mirror.sh
================================================
#!/bin/bash
set -e
# shellcheck disable=SC1091
. /freebsd-install.sh
fetch_best_freebsd_mirror "$@"
================================================
FILE: docker/freebsd-gcc.sh
================================================
#!/bin/bash
# the freebsd images need libstdc++ to be linked as well
# otherwise, we get `undefined reference to `std::ios_base::Init::Init()'`
set -euo pipefail
main() {
if [[ $# -eq 0 ]]; then
exec "${CROSS_TOOLCHAIN_PREFIX}gcc"
else
exec "${CROSS_TOOLCHAIN_PREFIX}gcc" "${@}" -lc++ -lstdc++
fi
}
main "$@"
================================================
FILE: docker/freebsd-install-package.sh
================================================
#!/bin/bash
set -e
# shellcheck disable=SC1091
. /freebsd-install.sh
install_freebsd_package "$@"
================================================
FILE: docker/freebsd-install.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. /freebsd-common.sh
# list of SRV records to query if the default mirror fails
FREEBSD_HTTP_TCP_SOURCES=(
# these return all mirrors, including local ones
"_http._tcp.pkg.all.freebsd.org"
# this only returns geodns mirrors
"_http._tcp.pkg.freebsd.org"
)
FREEBSD_PACKAGEDIR="/opt/freebsd-packagesite"
FREEBSD_PACKAGESITE="${FREEBSD_PACKAGEDIR}/packagesite.yaml"
FREEBSD_TARGET="${ARCH}-unknown-freebsd${FREEBSD_MAJOR}"
FREEBSD_DEFAULT_MIRROR="pkg.freebsd.org"
# NOTE: these mirrors were known to work as of 2022-11-28.
# no availability guarantees are made for any of them.
FREEBSD_BACKUP_MIRRORS=(
"pkg0.syd.freebsd.org"
"pkg0.bme.freebsd.org"
"pkg0.bra.freebsd.org"
"pkg0.fra.freebsd.org"
"pkg0.jinx.freebsd.org"
"pkg0.kul.freebsd.org"
"pkg0.kwc.freebsd.org"
"pkg0.nyi.freebsd.org"
"pkg0.tuk.freebsd.org"
"pkg0.twn.freebsd.org"
)
# NOTE: out of convention, we use `url` for mirrors with the scheme,
# and `mirror` for those without the scheme for consistent naming.
freebsd_package_source() {
local url="${1}"
echo "${url}/FreeBSD:${FREEBSD_MAJOR}:${FREEBSD_ARCH}/quarterly"
}
freebsd_mirror_works() {
local mirror="${1}"
local scheme="${2}"
local pkg_source=
# meta.conf is a small file for quick confirmation the mirror works
pkg_source=$(freebsd_package_source "${scheme}://${mirror}")
local path="${pkg_source}/meta.conf"
timeout 20s curl --retry 3 -sSfL "${path}" >/dev/null 2>&1
}
_fetch_best_freebsd_mirror() {
# in case if the default mirror is down, we can use various known
# fallbacks, or at worst, SRV fallbacks to find the ideal package
# site. no individual mirror other than the default mirror is
# guaranteed to exist, so we use a tiered approach. only
# the default mirror supports https.
if freebsd_mirror_works "${FREEBSD_DEFAULT_MIRROR}" "https"; then
echo "https://${FREEBSD_DEFAULT_MIRROR}"
return 0
fi
# if we've gotten here, it could be a DNS issue, so using a DNS
# resolver to fetch SRV fallbacks may not work. let's first try
# a few previously tested mirrors and see if any work.
local mirror=
for mirror in "${FREEBSD_BACKUP_MIRRORS[@]}"; do
if freebsd_mirror_works "${mirror}" "http"; then
echo "http://${mirror}"
return 0
fi
done
local http_tcp_source=
local response=
local lines=
# shellcheck disable=SC2016
local regex='/\d+\s+\d+\s+\d+\s+(.*)\./; print $1'
for http_tcp_source in "${FREEBSD_HTTP_TCP_SOURCES[@]}"; do
# the output will have the following format, but we only want the
# target and ignore everything else:
# $priority $port $weight $target.
#
# some output may not match, so we skip those lines, for example:
# 96.47.72.71
response=$(dig +short srv "${http_tcp_source}")
readarray -t lines <<< "${response}"
for line in "${lines[@]}"; do
mirror=$(echo "${line}" | perl -nle "${regex}")
if [[ -n "${mirror}" ]]; then
if freebsd_mirror_works "${mirror}" "http"; then
echo "http://${mirror}"
return 0
fi
fi
done
done
echo -e "\e[31merror:\e[0m could not find a working FreeBSD package mirror." 1>&2
exit 1
}
fetch_best_freebsd_mirror() {
set +e
_fetch_best_freebsd_mirror
code=$?
set -e
return "${code}"
}
setup_freebsd_packagesite() {
local url="${FREEBSD_MIRROR:-}"
local pkg_source=
if [[ -z "${url}" ]]; then
url=$(fetch_best_freebsd_mirror)
fi
pkg_source=$(freebsd_package_source "${url}")
mkdir -p "${FREEBSD_PACKAGEDIR}"
curl --retry 3 -sSfL "${pkg_source}/packagesite.pkg" -O
tar -C "${FREEBSD_PACKAGEDIR}" --zstd -xf packagesite.pkg
}
# don't provide the mirror as a positional argument, so it can be optional
install_freebsd_package() {
local url="${FREEBSD_MIRROR:-}"
local pkg_source=
local name
local path
local pkg
local td
local destdir="/usr/local/${FREEBSD_TARGET}"
if [[ -z "${url}" ]]; then
url=$(fetch_best_freebsd_mirror)
fi
pkg_source=$(freebsd_package_source "${url}")
td="$(mktemp -d)"
pushd "${td}"
for name in "${@}"; do
path=$(jq -c '. | select ( .name == "'"${name}"'" ) | .repopath' "${FREEBSD_PACKAGESITE}")
if [[ -z "${path}" ]]; then
echo "Unable to find package ${name}" >&2
exit 1
fi
path=${path//'"'/}
pkg=$(basename "${path}")
mkdir "${td}"/package
curl --retry 3 -sSfL "${pkg_source}/${path}" -O
tar -C "${td}/package" -xJf "${pkg}"
cp -r "${td}/package/usr/local"/* "${destdir}"/
rm "${td:?}/${pkg}"
rm -rf "${td:?}/package"
done
# clean up
popd
rm -rf "${td:?}"
}
================================================
FILE: docker/freebsd-setup-packagesite.sh
================================================
#!/bin/bash
set -e
# shellcheck disable=SC1091
. /freebsd-install.sh
setup_freebsd_packagesite "$@"
================================================
FILE: docker/freebsd.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. /freebsd-common.sh
# shellcheck disable=SC1091
. /lib.sh
# we prefer those closer in geography to the US. they're triaged in
# order of ease of use, reliability, and then geography. the mirror
# list is at https://docs.freebsd.org/en/books/handbook/mirrors/.
# these mirrors were known to work as of 2022-11-27. this does
# not include any mirrors that are known to be rate-limited or
# commercial. everything returns HTML output.
MIRRORS=(
# this is a guaranteed mirror, unlike those below.
"http://ftp.freebsd.org/pub/FreeBSD/releases"
"http://ftp11.freebsd.org/pub/FreeBSD/releases"
"http://ftp3.br.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.uk.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.nl.freebsd.org/pub/FreeBSD/releases"
"http://ftp6.fr.freebsd.org/pub/FreeBSD/releases"
"http://ftp1.de.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.de.freebsd.org/pub/FreeBSD/releases"
"http://ftp5.de.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.ru.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.gr.freebsd.org/pub/FreeBSD/releases"
"http://ftp4.za.freebsd.org/pub/FreeBSD/releases"
"http://ftp2.za.freebsd.org/pub/FreeBSD/releases"
"http://ftp4.tw.freebsd.org/pub/FreeBSD/releases"
"http://ftp3.jp.freebsd.org/pub/FreeBSD/releases"
"http://ftp6.jp.freebsd.org/pub/FreeBSD/releases"
"http://ftp.uk.freebsd.org/pub/FreeBSD/releases"
"http://ftp.nl.freebsd.org/pub/FreeBSD/releases"
"http://ftp.fr.freebsd.org/pub/FreeBSD/releases"
"http://ftp.at.freebsd.org/pub/FreeBSD/releases"
"http://ftp.dk.freebsd.org/FreeBSD/releases"
"http://ftp.cz.freebsd.org/pub/FreeBSD/releases"
"http://ftp.se.freebsd.org/pub/FreeBSD/releases"
"http://ftp.lv.freebsd.org/freebsd/releases"
"http://ftp.pl.freebsd.org/pub/FreeBSD/releases"
"http://ftp.ua.freebsd.org/pub/FreeBSD/releases"
"http://ftp.gr.freebsd.org/pub/FreeBSD/releases"
"http://ftp.ru.freebsd.org/pub/FreeBSD/releases"
"http://ftp.nz.freebsd.org/pub/FreeBSD/releases"
"http://ftp.kr.freebsd.org/pub/FreeBSD/releases"
"http://ftp.jp.freebsd.org/pub/FreeBSD/releases"
)
max_freebsd() {
local best=
local minor=0
local version=
local release_major=
local release_minor=
for release in "${@}"; do
version=$(echo "${release}" | cut -d '-' -f 1)
release_major=$(echo "${version}"| cut -d '.' -f 1)
release_minor=$(echo "${version}"| cut -d '.' -f 2)
if [ "${release_major}" == "${FREEBSD_MAJOR}" ] && [ "${release_minor}" -gt "${minor}" ]; then
best="${release}"
minor="${release_minor}"
fi
done
if [[ -z "$best" ]]; then
echo -e "\e[31merror:\e[0m could not find best release for FreeBSD ${FREEBSD_MAJOR}." 1>&2
exit 1
fi
echo "${best}"
}
latest_freebsd() {
local mirror="${1}"
local response=
local line=
local lines=
local releases=
local max_release=
response=$(curl -4 --retry 3 -sSfL "${mirror}/${FREEBSD_ARCH}/" | grep RELEASE)
if [[ "${response}" != *RELEASE* ]]; then
echo -e "\e[31merror:\e[0m could not find a candidate release for FreeBSD ${FREEBSD_MAJOR}." 1>&2
exit 1
fi
readarray -t lines <<< "${response}"
# shellcheck disable=SC2016
local regex='/\s*(\d+\.\d+-RELEASE)\s*\/?\s*<\/a>/; print $1'
# not all lines will match: some return `*-RELEASE/` as a line
if [[ "${response}" == *"/dev/null
code=$?
if [[ "${code}" == 0 ]]; then
echo "${mirror}"
return 0
elif [[ "${code}" != 124 ]]; then
echo -e "\e[1;33mwarning:\e[0m mirror ${mirror} does not seem to work." 1>&2
fi
done
echo -e "\e[31merror:\e[0m could not find a working FreeBSD mirror." 1>&2
exit 1
}
freebsd_mirror() {
set +e
_freebsd_mirror
code=$?
set -e
return "${code}"
}
mirror=$(freebsd_mirror)
base_release=$(latest_freebsd "${mirror}")
bsd_url="${mirror}/${FREEBSD_ARCH}/${base_release}-RELEASE"
main() {
local binutils=2.40 \
gcc=13.3.0 \
target="${ARCH}-unknown-freebsd${FREEBSD_MAJOR}"
install_packages ca-certificates \
curl \
g++ \
make \
wget \
texinfo \
xz-utils \
bzip2
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/freebsd"
download_binutils "${binutils}" "gz"
tar -C "${td}/binutils" --strip-components=1 -xf "binutils-${binutils}.tar.gz"
download_gcc "${gcc}" "gz"
tar -C "${td}/gcc" --strip-components=1 -xf "gcc-${gcc}.tar.gz"
cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
curl -4 --retry 3 -sSfL "${bsd_url}/base.txz" -O
tar -C "${td}/freebsd" -xJf base.txz ./usr/include ./usr/lib ./lib
cd binutils-build
../binutils/configure \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
local destdir="/usr/local/${target}"
cp -r "${td}/freebsd/usr/include" "${destdir}"
cp -r "${td}/freebsd/lib/"* "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libc++.so.1" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libc++.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libcxxrt.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libcxxrt.so" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libcompiler_rt.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared,memstat}.a "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/lib{rt,execinfo,procstat}.so "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/libmemstat.so.3 "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/libkvm.a "${destdir}/lib"
local lib=
local base=
local link=
for lib in "${destdir}/lib/"*.so.*; do
base=$(basename "${lib}")
link="${base}"
# not strictly necessary since this will always work, but good fallback
while [[ "${link}" == *.so.* ]]; do
link="${link%.*}"
done
# just extra insurance that we won't try to overwrite an existing file
local dstlink="${destdir}/lib/${link}"
if [[ -n "${link}" ]] && [[ "${link}" != "${base}" ]] && [[ ! -f "${dstlink}" ]]; then
ln -s "${base}" "${dstlink}"
fi
done
ln -s libthr.so.3 "${destdir}/lib/libpthread.so"
cd gcc-build
../gcc/configure \
--disable-libada \
--disable-libcilkrt \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-nls \
--disable-multilib \
--enable-languages=c,c++,fortran \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
# clean up
popd
purge_packages
# store the version info for the FreeBSD release
bsd_revision=$(curl -4 --retry 3 -sSfL "${bsd_url}/REVISION")
echo "${base_release} (${bsd_revision})" > /opt/freebsd-version
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/illumos.sh
================================================
#!/usr/bin/env bash
# This script is based off of rust-lang/rust's implementation.
# https://github.com/rust-lang/rust/blob/47f291ec2d9d6e4820cca517e69b3efddec40c20/src/ci/docker/scripts/illumos-toolchain.sh
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch="${1}"
local binutils=2.38
local gcc=8.4.0
local target="${arch}-unknown-illumos"
local build_target="${arch}-pc-solaris2.10"
local prefix="/usr/local/${target}"
local sysroot_dir="${prefix}/sysroot"
local real_sum
install_packages ca-certificates \
curl \
g++ \
make \
texinfo \
wget \
xz-utils
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/illumos"
local binutils_sum="e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024"
download_binutils "${binutils}" "xz"
real_sum=$(sha256sum "binutils-${binutils}.tar.xz" | cut -d ' ' -f 1)
if [[ "${binutils_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for binutils." >&2
exit 1
fi
tar -C "${td}/binutils" --strip-components=1 -xJf "binutils-${binutils}.tar.xz"
local gcc_sum="e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4"
download_gcc "${gcc}" "xz"
real_sum=$(sha256sum "gcc-${gcc}.tar.xz" | cut -d ' ' -f 1)
if [[ "${gcc_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for gcc." >&2
exit 1
fi
tar -C "${td}/gcc" --strip-components=1 -xJf "gcc-${gcc}.tar.xz"
pushd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
popd
local mach
case "${arch}" in
x86_64)
mach='i386'
;;
*)
echo "ERROR: unknown architecture: ${arch}" >&2
exit 1
;;
esac
local sysroot_version="20181213-de6af22ae73b-v1"
local sysroot_file="illumos-sysroot-${mach}-${sysroot_version}.tar.gz"
local sysroot_repo="https://github.com/illumos/sysroot"
local sysroot_sum="ee792d956dfa6967453cebe9286a149143290d296a8ce4b8a91d36bea89f8112"
curl --retry 3 -sSfL "${sysroot_repo}/releases/download/${sysroot_version}/${sysroot_file}" -O
real_sum=$(sha256sum "${sysroot_file}" | cut -d ' ' -f 1)
if [[ "${sysroot_sum}" != "${real_sum}" ]]; then
echo "Error: invalid hash for illumos sysroot." >&2
exit 1
fi
mkdir -p "${sysroot_dir}"
pushd "${sysroot_dir}"
tar -xzf "${td}/${sysroot_file}"
popd
mkdir -p "${prefix}"
pushd binutils-build
../binutils/configure \
--target="${build_target}" \
--prefix="${prefix}" \
--program-prefix="${target}-" \
--with-sysroot="${sysroot_dir}"
make "-j$(nproc)"
make install
popd
# note: solaris2.10 is obsolete, so we can't upgrade to GCC 10 till then.
# for gcc 9.4.0, need `--enable-obsolete`.
export CFLAGS='-fPIC'
export CXXFLAGS='-fPIC'
export CXXFLAGS_FOR_TARGET='-fPIC'
export CFLAGS_FOR_TARGET='-fPIC'
mkdir -p "${prefix}"
pushd gcc-build
../gcc/configure \
--prefix="${prefix}" \
--target="${build_target}" \
--program-prefix="${target}-" \
--with-sysroot="${sysroot_dir}" \
--enable-languages=c,c++,fortran \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-shared \
--disable-nls \
--enable-tls \
--with-gnu-as \
--with-gnu-ld
make "-j$(nproc)"
make install
popd
# clean up
popd
purge_packages
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/lib.sh
================================================
#!/usr/bin/env bash
# shellcheck disable=SC2294
purge_list=()
set_centos_ulimit() {
# this is a bug affecting buildkit with yum when ulimit is unlimited
# https://github.com/docker/buildx/issues/379#issuecomment-1196517905
ulimit -n 1024000
}
install_packages() {
if grep -i ubuntu /etc/os-release; then
apt-get update
for pkg in "${@}"; do
if ! dpkg -L "${pkg}" >/dev/null 2>/dev/null; then
apt-get install --assume-yes --no-install-recommends "${pkg}"
purge_list+=( "${pkg}" )
fi
done
else
set_centos_ulimit
for pkg in "${@}"; do
if ! yum list installed "${pkg}" >/dev/null 2>/dev/null; then
yum install -y "${pkg}"
purge_list+=( "${pkg}" )
fi
done
fi
}
purge_packages() {
if (( ${#purge_list[@]} )); then
if grep -i ubuntu /etc/os-release; then
apt-get purge --assume-yes --auto-remove "${purge_list[@]}"
else
yum remove -y "${purge_list[@]}"
fi
fi
}
if_centos() {
if grep -q -i centos /etc/os-release; then
eval "${@}"
fi
}
if_ubuntu() {
if grep -q -i ubuntu /etc/os-release; then
eval "${@}"
fi
}
if_ubuntu_ge() {
if grep -q -i ubuntu /etc/os-release; then
local ver
ver="$(source /etc/os-release; echo $VERSION_ID)"
if dpkg --compare-versions "$ver" "ge" "$1"; then
shift
eval "${@}"
fi
fi
}
GNU_MIRRORS=(
"https://ftp.gnu.org/gnu/"
"https://ftpmirror.gnu.org/"
)
download_mirrors() {
local relpath="${1}"
shift
local filename="${1}"
shift
for mirror in "${@}"; do
if curl -4 --retry 3 -sSfL "${mirror}/${relpath}/${filename}" -O; then
break
fi
done
if [[ ! -f "${filename}" ]]; then
echo "Unable to download ${filename}" >&2
exit 1
fi
}
download_binutils() {
local mirror
local version="${1}"
local ext="${2}"
local filename="binutils-${version}.tar.${ext}"
download_mirrors "binutils" "${filename}" "${GNU_MIRRORS[@]}"
}
download_gcc() {
local mirror
local version="${1}"
local ext="${2}"
local filename="gcc-${version}.tar.${ext}"
download_mirrors "gcc/gcc-${version}" "${filename}" "${GNU_MIRRORS[@]}"
}
docker_to_qemu_arch() {
local arch="${1}"
case "${arch}" in
arm64)
echo "aarch64"
;;
386)
echo "i386"
;;
amd64)
echo "x86_64"
;;
arm|ppc64le|riscv64|s390x)
echo "${arch}"
;;
*)
echo "Unknown Docker image architecture, got \"${arch}\"." >&2
exit 1
;;
esac
}
docker_to_linux_arch() {
# variant may not be provided
local oldstate
oldstate="$(set +o)"
set +u
local arch="${1}"
local variant="${2}"
case "${arch}" in
arm64)
echo "aarch64"
;;
386)
echo "i686"
;;
amd64)
echo "x86_64"
;;
ppc64le)
echo "powerpc64le"
;;
arm)
case "${variant}" in
v6)
echo "arm"
;;
""|v7)
echo "armv7"
;;
*)
echo "Unknown Docker image variant, got \"${variant}\"." >&2
exit 1
;;
esac
;;
riscv64|s390x)
echo "${arch}"
;;
*)
echo "Unknown Docker image architecture, got \"${arch}\"." >&2
exit 1
;;
esac
eval "${oldstate}"
}
find_argument() {
# Extracts the value from an argument of the form VARIABLE=VALUE
local needle="$1"
local return_var="$2"
shift 2
local prefix="${needle}="
for var in "${@}"; do
case "$var" in
"$prefix"*)
eval "$return_var=${var#"${prefix}"}"
return 0 ;;
*) ;;
esac
done
echo "Missing argument ${needle}"
exit 1
}
symlinkify_if_same() {
local file1="$1"
local file2="$2"
# Only make a symlink if the files are identical, and the destination file isn't already a symlink
if [ ! -L "${file2}" ] && cmp "$file1" "$file2"; then
ln -sf "$file1" "$file2"
fi
}
symlinkify_and_strip_toolchain() {
local target="$1"
local gcc_ver="$2"
local target_bin="/usr/local/${target}/bin"
local local_bin="/usr/local/bin"
# The first set of tools appear as /usr/local/bin/- and /usr/local//bin/
# Special case: ld is itself usually hardlinked to ld.bfd
symlinkify_if_same "${local_bin}/ld" "${local_bin}/ld.bfd"
# Turn hard links or otherwise identical files into symlinks
for tool in ar as ld ld.bfd nm objcopy objdump ranlib readelf strip; do
local src="${local_bin}/${target}-${tool}"
local dest="${target_bin}/${tool}"
symlinkify_if_same "${src}" "${dest}"
strip "${src}"
done
# The second set of tools only appear as /usr/local/bin/-
# Special case: c++ and g++ are usually the same file
symlinkify_if_same "${local_bin}/${target}-c++" "${local_bin}/${target}-g++"
# Special case: gcc and gcc-
symlinkify_if_same "${local_bin}/${target}-gcc" "${local_bin}/${target}-gcc-${gcc_ver}"
for tool in addr2line c++ c++filt cpp elfedit g++ gcc gcc-${gcc_ver} gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool gfortran gprof size strings; do
strip "${local_bin}/${target}-${tool}"
done
}
================================================
FILE: docker/linux-image.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
max_kernel_version() {
# kernel versions have the following format:
# `5.10.0-10-$arch`, where the `$arch` may be optional.
local IFS=$'\n'
local -a versions
local major=0
local minor=0
local patch=0
local release=0
local index=0
local version
local x
local y
local z
local r
local is_larger
read -r -d '' -a versions <<<"$1"
for i in "${!versions[@]}"; do
version="${versions[$i]}"
x=$(echo "$version" | cut -d '.' -f 1)
y=$(echo "$version" | cut -d '.' -f 2)
z=$(echo "$version" | cut -d '.' -f 3 | cut -d '-' -f 1)
r=$(echo "$version" | cut -d '-' -f 2)
is_larger=
if [ "$x" -gt "$major" ]; then
is_larger=1
elif [ "$x" -eq "$major" ] && [ "$y" -gt "$minor" ]; then
is_larger=1
elif [ "$x" -eq "$major" ] && [ "$y" -eq "$minor" ] && [ "$z" -gt "$patch" ]; then
is_larger=1
elif [ "$x" -eq "$major" ] && [ "$y" -eq "$minor" ] && [ "$z" -eq "$patch" ] && [ "$r" -gt "$release" ]; then
is_larger=1
fi
if [ -n "$is_larger" ]; then
index="$i"
major="$x"
minor="$y"
patch="$z"
release="$r"
fi
done
echo "${versions[index]}"
}
main() {
# arch in the rust target
local arch="${1}" \
kversion=5.10.0-34
local debsource="deb http://http.debian.net/debian/ bullseye main"
debsource="${debsource}\ndeb http://security.debian.org/ bullseye-security main"
local dropbear="dropbear-bin"
local -a deps
local kernel=
local libgcc="libgcc-s1"
local ncurses=
# select debian arch and kernel version
case "${arch}" in
aarch64)
arch=arm64
kernel="${kversion}-arm64"
deps=(libcrypt1:"${arch}")
;;
armv7)
arch=armhf
kernel='5.*-armmp'
deps=(libcrypt1:"${arch}")
;;
i686)
arch=i386
kernel="${kversion}-686"
deps=(libcrypt1:"${arch}")
;;
mips)
# mips was discontinued in bullseye, so we have to use buster.
libgcc="libgcc1"
debsource="deb http://http.debian.net/debian/ buster main"
debsource="${debsource}\ndeb http://security.debian.org/ buster/updates main"
kernel='4.*-4kc-malta'
ncurses="=6.1*"
;;
mipsel)
kernel='5.*-4kc-malta'
deps=(libcrypt1:"${arch}")
;;
mips64el)
kernel='5.*-5kc-malta'
deps=(libcrypt1:"${arch}")
;;
powerpc)
# there is no buster powerpc port, so we use jessie
# use a more recent kernel from backports
kversion='4.9.0-0.bpo.6'
kernel="${kversion}-powerpc"
debsource="deb http://archive.debian.org/debian jessie main"
debsource="${debsource}\ndeb http://archive.debian.org/debian jessie-backports main"
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unstable main"
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
# archive.debian.org Release files are expired.
echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
echo "APT::Get::AllowUnauthenticated true;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
echo "Acquire::AllowInsecureRepositories True;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
dropbear="dropbear"
deps=(libcrypt1:"${arch}")
;;
powerpc64)
# there is no stable port
arch=ppc64
# https://packages.debian.org/en/sid/linux-image-powerpc64
kernel='6.*-powerpc64'
debsource="deb http://ftp.ports.debian.org/debian-ports unstable main"
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
# sid version of dropbear requires these dependencies
deps=(libcrypt1:"${arch}")
;;
powerpc64le)
arch=ppc64el
kernel='5.*-powerpc64le'
deps=(libcrypt1:"${arch}")
;;
riscv64)
kernel='6.*-riscv64'
debsource="deb http://deb.debian.org/debian unstable main"
deps=(libcrypt1:"${arch}")
;;
s390x)
arch=s390x
kernel='5.*-s390x'
deps=(libcrypt1:"${arch}")
;;
sparc64)
# there is no stable port
# https://packages.debian.org/en/sid/linux-image-sparc64
kernel='6.*-sparc64'
debsource="deb http://ftp.ports.debian.org/debian-ports unstable main"
debsource="${debsource}\ndeb http://ftp.ports.debian.org/debian-ports unreleased main"
# sid version of dropbear requires these dependencies
deps=(libcrypt1:"${arch}")
;;
x86_64)
arch=amd64
kernel="${kversion}-amd64"
deps=(libcrypt1:"${arch}")
;;
*)
echo "Invalid arch: ${arch}"
exit 1
;;
esac
install_packages ca-certificates \
curl \
cpio \
sharutils \
gnupg
# conflicting versions of some packages will be installed already for the host platform,
# we need to remove the system installs later. since apt relies
# on these packages, we need to download them and reinstall
# using dpkg later, since we cannot redownload via apt.
local dpkg_arch
dpkg_arch=$(dpkg --print-architecture)
local libgcc_packages=("${libgcc}:${arch}" "libstdc++6:${arch}")
if [[ "${arch}" == "${dpkg_arch}" ]]; then
local libgcc_root=/qemu/libgcc
mkdir -p "${libgcc_root}"
pushd "${libgcc_root}"
apt-get -d --no-install-recommends download "${libgcc_packages[@]}"
popd
fi
# Download packages
mv /etc/apt/sources.list /etc/apt/sources.list.bak
mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak
echo -e "${debsource}" >/etc/apt/sources.list
# Old ubuntu does not support --add-architecture, so we directly change multiarch file
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch ]; then
cp /etc/dpkg/dpkg.cfg.d/multiarch /etc/dpkg/dpkg.cfg.d/multiarch.bak
fi
dpkg --add-architecture "${arch}" || echo "foreign-architecture ${arch}" >/etc/dpkg/dpkg.cfg.d/multiarch
# Add Debian keys.
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{7.0,8,9,10,11,12}.asc' -O
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{8,9,10,11,12}-security.asc' -O
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/release-{7,8,9,10,11,12}.asc' -O
curl --retry 3 -sSfL 'https://www.ports.debian.org/archive_{2020,2021,2022,2023,2024,2025}.key' -O
for key in *.asc *.key; do
apt-key add "${key}"
rm "${key}"
done
# allow apt-get to retry downloads
echo 'APT::Acquire::Retries "3";' >/etc/apt/apt.conf.d/80-retries
apt-get update
mkdir -p "/qemu/${arch}"
chmod 777 /qemu "/qemu/${arch}"
# Need to limit the kernel version and select the best version
# if we have a wildcard. This is because some matches, such as
# `linux-image-4.*-4kc-malta` can match more than 1 package,
# which will prevent further steps from working.
if [[ "$kernel" == *'*'* ]]; then
# Need an exact match for start and end, to avoid debug kernels.
# Afterwards, need to do a complex sort for the best kernel version,
# since the sort is non-trivial and must extract subcomponents.
packages=$(apt-cache search ^linux-image-"$kernel$" --names-only)
names=$(echo "$packages" | cut -d ' ' -f 1)
kversions="${names//linux-image-/}"
kernel=$(max_kernel_version "$kversions")
fi
cd "/qemu/${arch}"
apt-get -d --no-install-recommends download \
${deps[@]+"${deps[@]}"} \
"busybox:${arch}" \
"${dropbear}:${arch}" \
"libtommath1:${arch}" \
"libtomcrypt1:${arch}" \
"libgmp10:${arch}" \
"libc6:${arch}" \
"linux-image-${kernel}:${arch}" \
ncurses-base"${ncurses}" \
"zlib1g:${arch}"
if [[ "${arch}" != "${dpkg_arch}" ]]; then
apt-get -d --no-install-recommends download "${libgcc_packages[@]}"
else
# host arch has conflicting versions of the packages installed
# this prevents us from downloading them, so we need to
# simply grab the last version from the debian sources.
# we're search for a paragraph with:
# Maintainer: Debian
# but not
# Original-Maintainer: Debian
#
# then, we extract the version record and download **only**
# packages matching that specific version.
local version_info
local version_record
local version
for package in "${libgcc_packages[@]}"; do
version_info=$(apt-cache show "${package}")
version_record=$(echo "${version_info}" | perl -n00e 'print if /^Maintainer: Debian/m')
version=$(echo "${version_record}" | grep 'Version: ' | cut -d ' ' -f 2)
apt-get -d --no-install-recommends download "${package}=${version}"
done
# now, if we don't remove the system installs, qemu-system won't
# be able to find these libgcc packages after building, since it
# will prefer the system packages, which it can't find later.
# removing these packages needs to occur after download via apt,
# since apt-get relies on libgcc_s1 and libstdc++6.
dpkg -r --force-depends "${libgcc_packages[@]}"
fi
cd /qemu
# Install packages
root="root-${arch}"
mkdir -p "${root}"/{bin,etc/dropbear,root,sys,dev,proc,sbin,tmp,usr/{bin,sbin},var/log}
for deb in "${arch}"/*deb; do
dpkg -x "${deb}" "${root}"/
done
cp "${root}/boot/vmlinu"* kernel
# initrd
mkdir -p "${root}/modules"
if ls -d "${root}/usr/lib/modules"/*/kernel; then
prefix='/usr'
else
prefix=''
fi
cp -v \
"${root}${prefix}/lib/modules"/*/kernel/drivers/net/net_failover.ko* \
"${root}${prefix}/lib/modules"/*/kernel/drivers/net/virtio_net.ko* \
"${root}${prefix}/lib/modules"/*/kernel/drivers/virtio/* \
"${root}${prefix}/lib/modules"/*/kernel/fs/netfs/netfs.ko* \
"${root}${prefix}/lib/modules"/*/kernel/fs/9p/9p.ko* \
"${root}${prefix}/lib/modules"/*/kernel/fs/fscache/fscache.ko* \
"${root}${prefix}/lib/modules"/*/kernel/net/9p/9pnet.ko* \
"${root}${prefix}/lib/modules"/*/kernel/net/9p/9pnet_virtio.ko* \
"${root}${prefix}/lib/modules"/*/kernel/net/core/failover.ko* \
"${root}/modules" || true # some file may not exist
rm -rf "${root:?}/boot"
rm -rf "${root:?}${prefix}/lib/modules"
cat <<'EOF' >"${root}/etc/hosts"
127.0.0.1 localhost qemu
EOF
cat <<'EOF' >"$root/etc/hostname"
qemu
EOF
cat <<'EOF' >"$root/etc/passwd"
root::0:0:root:/root:/bin/sh
EOF
cat <<'EOF' | uudecode -o "$root/etc/dropbear/dropbear_rsa_host_key"
begin 600 dropbear_rsa_host_key
M````!W-S:"UR+3[X=QMH,B*4$RYULV,V3X6]K:7@Q?80"#WXGGQZNFN6CZ7LTDX(F6J[\]F5<0`HEOF:Z
MX;^53`L'4I/A```!``$L:$Z*#6<^3@+O%.[-#/5H+.C'3\#QQZN[1;J>L`8I
MZ_&T'!"J'/Y+?R?55G:M^=]R*-&I3TOJYZA8@&H51ZOAF59'1_>>Z@?E4#)$
MQU)X/RWH51ZB5KSDWJS:D'7GD(!?NAY`C'7\)I:_4)J")QBV/P"RJQGHG'%B
M1BT2LE6676>`1K,0\NIMZTKQNB(IC+88<7#8%_-=P<&6<"9LH>60TSS?3?-C
MN`T36YB/3^<(Q;`N1NT>I9EZS`BAC^-?.:,R\7EL"<4>7E=]^1]B\K9])AQU
MBM\]M;4V(S(6KH-I.4[6>9E+@\UEM.J6:[2LUEEJDG:G:+:/EVF^Y75@(S$`
M``"!`.O+KW=&*CBCHL"11&SVO4/K]$R-]7MV7,3RR)Q[X'0;6.?4JHW!3VR6
M*FGBY--37ZD-+UV.8_+"$6PH9)(/E.\G19#G0K`LRM?JWS!58&;D0C1````
M@0"\[@NYWSTW(?Q@:_A*1Y3/AKYO5?S=0"<2>#V-AH6W-NCSDTSRP=2D79FS
M"D?[;.)V>8'#9&I3"MU@+:2\Z%$0-MG0+J'(0>T1_C6?*C=4U0I$DI<=@D]1
H_&DE8Y(OT%%EPG]!$H&5HX*),_D1A2\P=R.7G'`0L%YM-79Y"T">$0``
`
end
EOF
# dropbear complains when this file is missing
touch "${root}/var/log/lastlog"
if [[ -e "${root}/usr/bin/busybox" ]]; then
busybox='/usr/bin/busybox'
else
busybox='/bin/busybox'
fi
cat <"${root}/init"
#!${busybox} sh
set -e
${busybox} --install
mount -t devtmpfs devtmpfs /dev
mount -t proc none /proc
mount -t sysfs none /sys
mkdir /dev/pts
mount -t devpts none /dev/pts/
# some archs does not have virtio modules
# fscache is builtin on riscv64
insmod /modules/failover.ko || insmod /modules/failover.ko.xz || true
insmod /modules/net_failover.ko || insmod /modules/net_failover.ko.xz || true
insmod /modules/virtio.ko || insmod /modules/virtio.ko.xz || true
insmod /modules/virtio_ring.ko || insmod /modules/virtio_ring.ko.xz || true
insmod /modules/virtio_mmio.ko || insmod /modules/virtio_mmio.ko.xz || true
insmod /modules/virtio_pci_legacy_dev.ko || insmod /modules/virtio_pci_legacy_dev.ko.xz || true
insmod /modules/virtio_pci_modern_dev.ko || insmod /modules/virtio_pci_modern_dev.ko.xz || true
insmod /modules/virtio_pci.ko || insmod /modules/virtio_pci.ko.xz || true
insmod /modules/virtio_net.ko || insmod /modules/virtio_net.ko.xz || true
insmod /modules/netfs.ko || insmod /modules/netfs.ko.xz || true
insmod /modules/fscache.ko || insmod /modules/fscache.ko.xz || true
insmod /modules/9pnet.ko || insmod /modules/9pnet.ko.xz
insmod /modules/9pnet_virtio.ko || insmod /modules/9pnet_virtio.ko.xz || true
insmod /modules/9p.ko || insmod /modules/9p.ko.xz
ifconfig lo 127.0.0.1
ifconfig eth0 10.0.2.15
route add default gw 10.0.2.2 eth0
mkdir /target
mount -t 9p -o trans=virtio target /target -oversion=9p2000.u || true
exec dropbear -F -E -B
EOF
if [[ "${arch}" == "riscv64" ]]; then
# Symlink dynamic loader to /lib/ld-linux-riscv64-lp64d.so.1
mkdir -p "${root}/lib"
ln -s /usr/lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 "${root}/lib/ld-linux-riscv64-lp64d.so.1"
fi
chmod +x "${root}/init"
cd "${root}"
find . | cpio --create --format='newc' --quiet | gzip >../initrd.gz
cd -
if [[ "${arch}" == "${dpkg_arch}" ]]; then
# need to reinstall these packages, since basic utilities rely on them.
pushd "${libgcc_root}"
dpkg -i --force-depends "${libgcc_root}"/*.deb
popd
rm -rf "${libgcc_root}"
fi
# Clean up
rm -rf "/qemu/${root}" "/qemu/${arch}"
mv -f /etc/apt/sources.list.bak /etc/apt/sources.list
mv -f /etc/apt/sources.list.d.bak /etc/apt/sources.list.d
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch.bak ]; then
mv /etc/dpkg/dpkg.cfg.d/multiarch.bak /etc/dpkg/dpkg.cfg.d/multiarch
fi
if [ -f /etc/apt/apt.conf.d/10-nocheckvalid ]; then
rm /etc/apt/apt.conf.d/10-nocheckvalid
fi
# can fail if arch is used (image arch, such as amd64 and/or i386)
dpkg --remove-architecture "${arch}" || true
apt-get update
# need to reinstall the removed libgcc packages, which are required for apt
if [[ "${arch}" == "${dpkg_arch}" ]]; then
apt-get install --no-install-recommends --assume-yes "${packages[@]}"
fi
purge_packages
ls -lh /qemu
}
main "${@}"
================================================
FILE: docker/linux-runner
================================================
#!/usr/bin/env bash
set -e
# shellcheck disable=SC1091
. /base-runner.sh
LOG=/tmp/qemu.log
LOCK=/tmp/qemu.lock
if [ -n "${CROSS_DEBUG}" ]; then
set -x
fi
# arch in the rust target
arch="${1}"
shift
if [[ -z "${CROSS_RUNNER}" ]]; then
if is_native_binary "${arch}"; then
CROSS_RUNNER=native
else
CROSS_RUNNER=qemu-user
fi
fi
# Ensure that the correct prefix is set even if the user has cleared the env.
# `@DEFAULT_QEMU_LD_PREFIX@` is replaced during image build.
export QEMU_LD_PREFIX=${QEMU_LD_PREFIX:-@DEFAULT_QEMU_LD_PREFIX@}
qarch=$(qemu_arch "${arch}")
case "${CROSS_RUNNER}" in
native)
exec "${@}"
;;
qemu-user)
exec "qemu-${qarch}" "${@}"
;;
qemu-system)
true
;;
*)
echo "Invalid runner: \"${CROSS_RUNNER}\"";
echo "Valid runners are: native, qemu-user and qemu-system"
exit 1
;;
esac
n="$(nproc)"
memory=1G
driver9p="virtio-9p-pci"
drivernet="virtio-net-pci"
# select qemu parameters
case "${arch}" in
aarch64|aarch64_be)
# 8 is the max number of cpu supported by qemu-aarch64
n=$(( n > 8 ? 8 : n ))
opt="-machine virt -cpu cortex-a57"
;;
armv7hf)
opt="-machine virt"
driver9p="virtio-9p-device"
drivernet="virtio-net-device"
;;
i686)
opt="-append console=ttyS0"
;;
mips|mipsel)
# avoid kernel error
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
opt="-append nokaslr"
n=1
;;
mips64el)
# avoid kernel error
# https://blahcat.github.io/2017/07/14/building-a-debian-stretch-qemu-image-for-mipsel/
opt="-append nokaslr -cpu MIPS64R2-generic"
n=1
;;
powerpc)
opt="-append console=ttyPZ0"
n=1
;;
riscv64)
opt="-machine virt"
;;
powerpc64|powerpc64le)
opt="-append console=hvc0 --nodefaults -serial stdio"
;;
s390x)
n=1
driver9p="virtio-9p-ccw"
drivernet="virtio-net-ccw"
;;
sparc64)
n=1
driver9p+=",bus=pciB"
drivernet+=",bus=pciB"
;;
x86_64)
opt="-append console=ttyS0"
;;
esac
(
flock -n 200 || exit 0
echo Booting QEMU virtual machine with $n cpus...
QEMU_CMD="qemu-system-${qarch} \
-m ${memory} \
-smp ${n} \
-nographic \
-monitor none \
-netdev user,id=net0,hostfwd=tcp::10022-:22 \
-device ${drivernet},netdev=net0 \
-kernel /qemu/kernel \
-initrd /qemu/initrd.gz \
${opt} \
-fsdev local,id=fs0,path=/target,security_model=mapped \
-device ${driver9p},fsdev=fs0,mount_tag=target"
touch "${LOG}"
if [[ -n "${CROSS_DEBUG}" ]]; then
(${QEMU_CMD} 2>&1 | tee -a "${LOG}") &
else
${QEMU_CMD} >> "${LOG}" 2>&1 &
fi
qemu_pid=$!
# wait for dropbear
for _ in $(seq 240); do
if grep -q "Not backgrounding" "${LOG}"; then
READY=1
break
elif ! (ps -p "${qemu_pid}" >/dev/null 2>&1); then
# qemu command failed and exited early
exit 1
fi
sleep 0.5s
done
if [ -z "${READY}" ]; then
if [ -n "${CROSS_DEBUG}" ]; then
echo "Not ready but continuing because CROSS_DEBUG is set"
else
echo "Qemu is not ready after ${SECONDS} seconds..."
echo "Set the environment variable CROSS_DEBUG=1 to debug"
echo "Last 100 lines of qemu output:"
tail -n 100 "${LOG}"
exit 1
fi
fi
echo "Booted in ${SECONDS} seconds"
) 200>"${LOCK}"
if [[ -t 1 ]] && [[ -t 2 ]]; then
tty_flag='-t'
fi
exec dbclient ${tty_flag} -p 10022 -y -y root@localhost "${@}"
================================================
FILE: docker/mingw.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
# Ubuntu mingw packages for i686 uses sjlj exceptions, but rust target
# i686-pc-windows-gnu uses dwarf exceptions. So we build mingw packages
# that are compatible with rust.
# Enable source
sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list
apt-get update
# Install mingw (with sjlj exceptions) to get the dependencies right
# Later we replace these packages with the new ones
apt-get install --assume-yes --no-install-recommends g++-mingw-w64-i686
local dependencies=(build-essential)
while IFS='' read -r dep; do dependencies+=("${dep}"); done < \
<(apt-cache showsrc gcc-mingw-w64-i686 | grep Build | cut -d: -f2 | tr , '\n' | cut -d' ' -f2 | sort | uniq)
install_packages "${dependencies[@]}"
local td
td="$(mktemp -d)"
pushd "${td}"
apt-get source gcc-mingw-w64-i686
pushd gcc-mingw-w64-*
# We are using dwarf exceptions instead of sjlj
sed -i -e 's/libgcc_s_sjlj-1/libgcc_s_dw2-1/g' debian/gcc-mingw-w64-i686.install.in
# Only build i686 packages (disable x86_64)
patch -p0 <<'EOF'
--- debian/control.template.ori 2018-03-12 16:25:30.000000000 +0000
+++ debian/control.template 2018-03-12 16:25:30.000000000 +0000
@@ -1,7 +1,6 @@
Package: @@PACKAGE@@-mingw-w64
Architecture: all
Depends: @@PACKAGE@@-mingw-w64-i686,
- @@PACKAGE@@-mingw-w64-x86-64,
${misc:Depends}
Recommends: @@RECOMMENDS@@
Built-Using: gcc-@@VERSION@@ (= ${gcc:Version})
@@ -32,22 +31,3 @@
This package contains the @@LANGUAGE@@ compiler, supporting
cross-compiling to 32-bit MinGW-w64 targets.
Build-Profiles:
-
-Package: @@PACKAGE@@-mingw-w64-x86-64
-Architecture: any
-Depends: @@DEPENDS64@@,
- ${misc:Depends},
- ${shlibs:Depends}
-Suggests: gcc-@@VERSION@@-locales (>= ${local:Version})
-Breaks: @@BREAKS64@@
-Conflicts: @@CONFLICTS64@@
-Replaces: @@REPLACES64@@
-Built-Using: gcc-@@VERSION@@ (= ${gcc:Version})
-Description: GNU @@LANGUAGE@@ compiler for MinGW-w64 targeting Win64
- MinGW-w64 provides a development and runtime environment for 32- and
- 64-bit (x86 and x64) Windows applications using the Windows API and
- the GNU Compiler Collection (gcc).
- .
- This package contains the @@LANGUAGE@@ compiler, supporting
- cross-compiling to 64-bit MinGW-w64 targets.
-Build-Profiles:
EOF
# Disable build of fortran,objc,obj-c++ and use configure options
# --disable-sjlj-exceptions --with-dwarf2
patch -p0 <<'EOF'
--- debian/rules.ori 2018-03-12 16:25:30.000000000 +0000
+++ debian/rules 2018-03-12 16:25:30.000000000 +0000
@@ -58,7 +58,7 @@
INSTALL_TARGET := install-gcc
else
# Build the full GCC.
- languages := c,c++,fortran,objc,obj-c++,ada
+ languages := c,c++
BUILD_TARGET :=
INSTALL_TARGET := install install-lto-plugin
endif
@@ -85,7 +85,7 @@
sed -i 's/@@VERSION@@/$(target_version)/g' debian/control
touch $@
-targets := i686-w64-mingw32 x86_64-w64-mingw32
+targets := i686-w64-mingw32
threads := posix win32
# Hardening on the host, none on the target
@@ -220,6 +220,10 @@
# Enable libatomic
CONFFLAGS += \
--enable-libatomic
+# Enable dwarf exceptions
+CONFFLAGS += \
+ --disable-sjlj-exceptions \
+ --with-dwarf2
# Enable experimental::filesystem and std::filesystem
CONFFLAGS += \
--enable-libstdcxx-filesystem-ts=yes
EOF
# Need symlinks for specific autoconf versions, since it
# attempts to use autoconf2.69 and autom4te2.69.
ln -s /usr/bin/autoconf /usr/bin/autoconf2.69
ln -s /usr/bin/autom4te /usr/bin/autom4te2.69
# Build the modified mingw packages
MAKEFLAGS=--silent dpkg-buildpackage -nc -B --jobs=auto
# Replace installed mingw packages with the new ones
dpkg -i ../g*-mingw-w64-i686*.deb ../gcc-mingw-w64-base*.deb
purge_packages
popd
popd
rm -rf "${td}"
rm "${0}"
# Unlink our temporary aliases
unlink /usr/bin/autoconf2.69
unlink /usr/bin/autom4te2.69
}
main "${@}"
================================================
FILE: docker/musl-gcc.sh
================================================
#!/bin/bash
# this linker works around missing builtins in older rust versions.
# we also have custom linker scripts for our static libstdc++ for all versions
# which is found in `musl-symlink.sh`.
#
# for other targets, issues in older versions of compiler-builtins require
# manually linking to libgcc to compensate for missing builtins.
# target-specific details include:
#
# aarch64-unknown-linux-musl (fixed in 1.48)
# https://github.com/rust-lang/compiler-builtins/pull/377
#
# armv5te-unknown-linux-musleabi (fixed in 1.65)
# missing sync `sync_X_and_fetch`
# https://github.com/rust-lang/compiler-builtins/pull/484
#
# mips64-unknown-linux-muslabi64, mips64el-unknown-linux-muslabi64 (fixed in 1.65)
# missing soft-fp routine `__trunctfsf2`
# https://github.com/rust-lang/compiler-builtins/pull/483
set -euo pipefail
main() {
local minor
local patched_minor="${CROSS_BUILTINS_PATCHED_MINOR_VERSION:-0}"
minor=$(rustc_minor_version)
if [[ $# -eq 0 ]] || [[ "${minor}" -ge "${patched_minor}" ]]; then
exec "${CROSS_TOOLCHAIN_PREFIX}"gcc "$@"
else
exec "${CROSS_TOOLCHAIN_PREFIX}"gcc "$@" -lgcc -static-libgcc
fi
}
# FIXME: the rest of the contents of this file can be removed later on,
# especially after 0.3.0 has been released so we can ensure everyone is
# using a cross version at least as recent as images requiring the rust
# versions provided as environment variables. these functions are wrappers
# around these environment variables for backwards compatibility.
# https://github.com/cross-rs/cross/issues/1046
# NOTE: this will fail if rustc does not provide version
# info, which may happen with a custom toolchain.
rustc_version() {
rustc -Vv | grep '^release:' | cut -d ':' -f2
}
rustc_major_version() {
if [[ -z "${CROSS_RUSTC_MAJOR_VERSION:-}" ]]; then
CROSS_RUSTC_MAJOR_VERSION=$(rustc_version | cut -d '.' -f1)
export CROSS_RUSTC_MAJOR_VERSION
fi
echo "${CROSS_RUSTC_MAJOR_VERSION}"
}
rustc_minor_version() {
if [[ -z "${CROSS_RUSTC_MINOR_VERSION:-}" ]]; then
CROSS_RUSTC_MINOR_VERSION=$(rustc_version | cut -d '.' -f2)
export CROSS_RUSTC_MINOR_VERSION
fi
echo "${CROSS_RUSTC_MINOR_VERSION}"
}
rustc_patch_version() {
if [[ -z "${CROSS_RUSTC_PATCH_VERSION:-}" ]]; then
CROSS_RUSTC_PATCH_VERSION=$(rustc_version | cut -d '.' -f3)
export CROSS_RUSTC_PATCH_VERSION
fi
echo "${CROSS_RUSTC_PATCH_VERSION}"
}
main "$@"
================================================
FILE: docker/musl-symlink.sh
================================================
#!/usr/bin/env bash
# Create necessary symlinks for musl images to run
# dynamically-linked binaries.
# Just to be careful, we need this in a few locations,
# relative to the musl sysroot.
# /lib/ld-musl-armhf.so
# /lib/ld-musl-armhf.so.1
# /usr/lib/ld.so
# /usr/lib/ld.so.1
# /usr/lib/libc.so
# /usr/lib/libc.so.1
set -x
set -euo pipefail
main() {
local sysroot="${1}"
local arch="${2}"
local src
local dst
local dsts
# ignore any failures here
local ld_arch="${arch//_/-}"
mkdir -p "$sysroot/usr/lib"
src="$sysroot/lib/libc.so"
dsts=(
"/lib/ld-musl-${arch}.so"
"/lib/ld-musl-${arch}.so.1"
"$sysroot/lib/ld-musl-${arch}.so"
"$sysroot/lib/ld-musl-${arch}.so.1"
"$sysroot/usr/lib/ld.so"
"$sysroot/usr/lib/ld.so.1"
"$sysroot/usr/lib/libc.so"
"$sysroot/usr/lib/libc.so.1"
# this specifically is a workaround for ARM64, which
# for some reason links to `ld-linux-aarch64.so`, but
# it is a valid musl binary. trying to use `libc6-dev:arm64`
# shows it has an invalid ELF header.
"$sysroot/lib/ld-linux-${ld_arch}.so"
"$sysroot/lib/ld-linux-${ld_arch}.so.1"
)
for dst in "${dsts[@]}"; do
# force a link if the dst does not exist or is broken
if [[ -L "${dst}" ]] && [[ ! -a "${dst}" ]]; then
ln -sf "${src}" "${dst}"
elif [[ ! -f "${dst}" ]]; then
ln -s "${src}" "${dst}"
fi
done
# ensure we statically link libstdc++, so avoid segfaults with c++
# https://github.com/cross-rs/cross/issues/902
rm "${sysroot}"/lib/libstdc++.so* || true
# now, we create a linker script that adds all the required dependencies
# because we link to a static libstdc++ to avoid runtime issues and
# with the shared libstdc++, we can have missing symbols that are reference
# in libstdc++, such as those from libc like `setlocale` and `__cxa_atexit`,
# as well as those from libgcc, like `__extendsftf2`. all musl targets
# can require symbols from libc, however, only the following are known
# to require symbols from libgcc:
# - aarch64-unknown-linux-musl
# - mips64-unknown-linux-muslabi64
# - mips64el-unknown-linux-muslabi64
echo '/* cross-rs linker script
* this allows us to statically link libstdc++ to avoid segfaults
* https://github.com/cross-rs/cross/issues/902
*/
GROUP ( libstdc++.a AS_NEEDED( -lgcc -lc -lm ) )
' > "${sysroot}"/lib/libstdc++.so.6.0.27
ln -s libstdc++.so.6.0.27 "${sysroot}"/lib/libstdc++.so.6
ln -s libstdc++.so.6.0.27 "${sysroot}"/lib/libstdc++.so
echo "${sysroot}/lib" >> "/etc/ld-musl-${arch}.path"
rm -rf "${0}"
}
main "${@}"
================================================
FILE: docker/musl.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
hide_output() {
set +x
trap "
echo 'ERROR: An error was encountered with the build.'
cat /tmp/build.log
exit 1
" ERR
bash -c 'while true; do sleep 30; echo $(date) - building ...; done' &
PING_LOOP_PID=$!
"${@}" &> /tmp/build.log
trap - ERR
kill "${PING_LOOP_PID}"
set -x
}
main() {
local version=fe91582
install_packages ca-certificates curl build-essential
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://github.com/richfelker/musl-cross-make/archive/${version}.tar.gz" -O
tar --strip-components=1 -xzf "${version}.tar.gz"
# Don't depend on the mirrors of sabotage linux that musl-cross-make uses.
local linux_headers_site=https://ci-mirrors.rust-lang.org/rustc/sabotage-linux-tarballs
local linux_ver=headers-4.19.88
local gcc_ver=9.2.0
local target
find_argument TARGET target "${@}"
# alpine GCC is built with `--enable-default-pie`, so we want to
# ensure we use that. we want support for shared runtimes except for
# libstdc++, however, the only way to do that is to simply remove
# the shared libraries later. on alpine, binaries use static-pie
# linked, so our behavior has maximum portability, and is consistent
# with popular musl distros.
hide_output make install "-j$(nproc)" \
GCC_VER=${gcc_ver} \
MUSL_VER=1.2.3 \
BINUTILS_VER=2.33.1 \
DL_CMD='curl --retry 3 -sSfL -C - -o' \
LINUX_HEADERS_SITE="${linux_headers_site}" \
LINUX_VER="${linux_ver}" \
OUTPUT=/usr/local/ \
"GCC_CONFIG += --enable-default-pie --enable-languages=c,c++,fortran" \
"${@}"
purge_packages
popd
symlinkify_and_strip_toolchain "${target}" "${gcc_ver}"
for dir in /usr/local/libexec/gcc/"${target}"/*; do
pushd "${dir}" || exit 1
strip cc1 cc1plus collect2 f951 lto1 lto-wrapper liblto_plugin.so.0.0.0
popd || exit 1
done
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/native-linux-image.sh
================================================
#!/usr/bin/env bash
set -x
set -eo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch
arch=$(docker_to_linux_arch "${TARGETARCH}" "${TARGETVARIANT}")
/linux-image.sh "${arch}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/native-linux-runner
================================================
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1091
. /lib.sh
main() {
local arch
arch=$(docker_to_linux_arch "${CROSS_TARGETARCH:-@DEFAULT_CROSS_TARGETARCH@}" "${CROSS_TARGETVARIANT:-@DEFAULT_CROSS_TARGETVARIANT@}")
if [[ -z "${CROSS_RUNNER}" ]]; then
export CROSS_RUNNER=native
fi
exec /linux-runner "${arch}" "${@}"
}
main "${@}"
================================================
FILE: docker/native-qemu.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch
arch=$(docker_to_qemu_arch "${TARGETARCH}")
/qemu.sh "${arch}" softmmu
rm "${0}"
}
main "${@}"
================================================
FILE: docker/netbsd.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local binutils=2.36.1 \
gcc=9.4.0 \
target=x86_64-unknown-netbsd
install_packages bzip2 \
ca-certificates \
curl \
g++ \
make \
patch \
texinfo \
wget \
xz-utils
local td
td="$(mktemp -d)"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/netbsd"
download_binutils "${binutils}" "bz2"
tar -C "${td}/binutils" --strip-components=1 -xjf "binutils-${binutils}.tar.bz2"
download_gcc "${gcc}" "xz"
tar -C "${td}/gcc" --strip-components=1 -xJf "gcc-${gcc}.tar.xz"
pushd "${td}"
pushd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
local patches=(
https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/gcc9/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc
https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/gcc9/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/gcc8/patches/patch-libgfortran_io_io.h
)
local patch
for patch in "${patches[@]}"; do
local patch_file
patch_file="$(mktemp)"
curl --retry 3 -sSfL "${patch}" -o "${patch_file}"
patch -Np0 < "${patch_file}"
rm "${patch_file}"
done
popd
local mirrors=(
"ftp://ftp.netbsd.org"
"https://cdn.NetBSD.org"
)
download_mirrors "pub/NetBSD/NetBSD-9.3/amd64/binary/sets" "base.tar.xz" "${mirrors[@]}"
tar -C "${td}/netbsd" -xJf base.tar.xz ./usr/include ./usr/lib ./lib
download_mirrors "pub/NetBSD/NetBSD-9.3/amd64/binary/sets" "comp.tar.xz" "${mirrors[@]}"
tar -C "${td}/netbsd" -xJf comp.tar.xz ./usr/include ./usr/lib
pushd binutils-build
../binutils/configure \
--target="${target}"
make "-j$(nproc)"
make install
popd
local destdir="/usr/local/${target}"
cp -r "${td}/netbsd/usr/include" "${destdir}"/
ls -all "${td}/netbsd/usr/lib"
cp "${td}/netbsd/lib/libc.so.12.213" "${destdir}/lib"
cp "${td}/netbsd/lib/libm.so.0.12" "${destdir}/lib"
cp "${td}/netbsd/lib/libutil.so.7.24" "${destdir}/lib"
cp "${td}/netbsd/lib/libpthread.so.1.4" "${destdir}/lib"
cp "${td}/netbsd/usr/lib/librt.so.1.1" "${destdir}/lib"
cp "${td}/netbsd/usr/lib"/lib{c,m,pthread}{,_p}.a "${destdir}/lib"
cp "${td}/netbsd/usr/lib"/libexecinfo.so "${destdir}/lib"
cp "${td}/netbsd/usr/lib"/{crt0,crti,crtn,crtbeginS,crtendS,crtbegin,crtend,gcrt0}.o "${destdir}/lib"
ln -s libc.so.12.213 "${destdir}/lib/libc.so"
ln -s libc.so.12.213 "${destdir}/lib/libc.so.12"
ln -s libm.so.0.12 "${destdir}/lib/libm.so"
ln -s libm.so.0.12 "${destdir}/lib/libm.so.0"
ln -s libpthread.so.1.4 "${destdir}/lib/libpthread.so"
ln -s libpthread.so.1.4 "${destdir}/lib/libpthread.so.1"
ln -s librt.so.1.1 "${destdir}/lib/librt.so"
ln -s libutil.so.7.24 "${destdir}/lib/libutil.so"
ln -s libutil.so.7.24 "${destdir}/lib/libutil.so.7"
pushd gcc-build
# remove the environment variables after bumping the gcc version to 11.
target_configargs="ac_cv_func_newlocale=no ac_cv_func_freelocale=no ac_cv_func_uselocale=no" ../gcc/configure \
--disable-libada \
--disable-libcilkrt \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,fortran \
--target="${target}"
make "-j$(nproc)"
make install
popd
# clean up
popd
purge_packages
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/qemu-runner
================================================
#!/usr/bin/env bash
# A very lightweight version of linux-runner that
# doesn't support system emulation. Just useful
# to allow native or qemu-user mode emulation.
set -e
# shellcheck disable=SC1091
. /base-runner.sh
if [ -n "${CROSS_DEBUG}" ]; then
set -x
fi
# arch in the rust target
arch="${1}"
shift
if [[ -z "${CROSS_RUNNER}" ]]; then
if is_native_binary "${arch}"; then
CROSS_RUNNER=native
else
CROSS_RUNNER=qemu-user
fi
fi
# Ensure that the correct prefix is set even if the user has cleared the env.
# `@DEFAULT_QEMU_LD_PREFIX@` is replaced during image build.
export QEMU_LD_PREFIX=${QEMU_LD_PREFIX:-@DEFAULT_QEMU_LD_PREFIX@}
qarch=$(qemu_arch "${arch}")
case "${CROSS_RUNNER}" in
native)
exec "${@}"
;;
qemu-user)
exec "qemu-${qarch}" "${@}"
;;
*)
echo "Invalid runner: \"${CROSS_RUNNER}\"";
echo "Valid runners are: native and qemu-user"
exit 1
;;
esac
================================================
FILE: docker/qemu.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
build_static_libffi () {
local version=3.0.13
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://github.com/libffi/libffi/archive/refs/tags/v${version}.tar.gz" -O -L
tar --strip-components=1 -xzf "v${version}.tar.gz"
./configure --prefix="$td"/lib --disable-builddir --disable-shared --enable-static
make "-j$(nproc)"
install -m 644 ./.libs/libffi.a /usr/local/lib/
popd
rm -rf "${td}"
}
build_static_libmount () {
local version_spec=2.23.2
local version=2.23
if_ubuntu_ge 22.04 version_spec=2.37.2
if_ubuntu_ge 22.04 version=2.37
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://kernel.org/pub/linux/utils/util-linux/v${version}/util-linux-${version_spec}.tar.xz" -O -L
tar --strip-components=1 -xJf "util-linux-${version_spec}.tar.xz"
./configure --disable-shared --enable-static --without-ncurses
make "-j$(nproc)" mount blkid
install -m 644 ./.libs/*.a /usr/local/lib/
popd
rm -rf "${td}"
}
build_static_libattr() {
local version=2.4.46
local td
td="$(mktemp -d)"
pushd "${td}"
set_centos_ulimit
yum install -y gettext
curl --retry 3 -sSfL "https://download.savannah.nongnu.org/releases/attr/attr-${version}.src.tar.gz" -O
tar --strip-components=1 -xzf "attr-${version}.src.tar.gz"
cp /usr/share/automake*/config.* .
./configure
make "-j$(nproc)"
install -m 644 ./libattr/.libs/libattr.a /usr/local/lib/
yum remove -y gettext
popd
rm -rf "${td}"
}
build_static_libcap() {
local version=2.22
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-${version}.tar.xz" -O
tar --strip-components=1 -xJf "libcap-${version}.tar.xz"
make "-j$(nproc)"
install -m 644 libcap/libcap.a /usr/local/lib/
popd
rm -rf "${td}"
}
build_static_pixman() {
local version=0.34.0
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://www.cairographics.org/releases/pixman-${version}.tar.gz" -O
tar --strip-components=1 -xzf "pixman-${version}.tar.gz"
./configure
make "-j$(nproc)"
install -m 644 ./pixman/.libs/libpixman-1.a /usr/local/lib/
popd
rm -rf "${td}"
}
build_static_slirp() {
local version=4.1.0
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://gitlab.freedesktop.org/slirp/libslirp//-/archive/v${version}/libslirp-v${version}.tar.gz" -O
tar -xzf "libslirp-v${version}.tar.gz"
meson setup -Ddefault_library=static libslirp-v${version} build
ninja -C build
install -m 644 ./build/libslirp.a /usr/local/lib/
popd
rm -rf "${td}"
}
main() {
local version=5.1.0
if_centos version=4.2.1
local arch="${1}" \
softmmu="${2:-}"
install_packages \
autoconf \
automake \
bison \
bzip2 \
curl \
flex \
libtool \
make \
patch \
python3 \
if_centos install_packages \
gcc-c++ \
pkgconfig \
xz \
glib2-devel \
glib2-static \
glibc-static \
libattr-devel \
libcap-devel \
libfdt-devel \
pcre-static \
pixman-devel \
libselinux-devel \
libselinux-static \
libffi \
libuuid-devel \
libblkid-devel \
libmount-devel \
zlib-devel \
zlib-static
### See this thread in case there are other issues regarding Savannah from gnu
### https://lists.nongnu.org/archive/html/savannah-hackers-public/2025-04/msg00003.html
### This link should be a good reference for the config.git repository: https://cgit.git.savannah.gnu.org/cgit/config.git/
if_centos 'curl --retry 3 -sSfL "https://gitweb.git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" -o /usr/share/automake*/config.guess'
if_centos 'curl --retry 3 -sSfL "https://gitweb.git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD" -o /usr/share/automake*/config.sub'
# these are not packaged as static libraries in centos; build them manually
if_centos build_static_libffi
if_centos build_static_libmount
if_centos build_static_libattr
if_centos build_static_libcap
if_centos build_static_pixman
if_ubuntu install_packages \
g++ \
pkg-config \
xz-utils \
libattr1-dev \
libcap-ng-dev \
libffi-dev \
libglib2.0-dev \
libpixman-1-dev \
libselinux1-dev \
zlib1g-dev
# ubuntu no longer provides statically linked libmount
if_ubuntu_ge 22.04 build_static_libmount
# if we have python3.6+, we can install qemu 7.0.0, which needs ninja-build
# ubuntu 16.04 only provides python3.5, so remove when we have a newer qemu.
is_ge_python36=$(python3 -c "import sys; print(int(sys.version_info >= (3, 6)))")
if [[ "${is_ge_python36}" == "1" ]]; then
if_ubuntu version=7.0.0
if_ubuntu install_packages ninja-build
fi
# if we have python3.8+, we can install qemu 8.2.2, which needs ninja-build,
# meson, python3-pip and libslirp-dev.
# ubuntu 16.04 only provides python3.5, so remove when we have a newer qemu.
is_ge_python38=$(python3 -c "import sys; print(int(sys.version_info >= (3, 8)))")
if [[ "${is_ge_python38}" == "1" ]]; then
if_ubuntu version=8.2.2
if_ubuntu install_packages ninja-build meson python3-pip libslirp-dev
if_ubuntu build_static_slirp
fi
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://download.qemu.org/qemu-${version}.tar.xz" -O
tar --strip-components=1 -xJf "qemu-${version}.tar.xz"
local targets="${arch}-linux-user"
local virtfs=""
case "${softmmu}" in
softmmu)
if [ "${arch}" = "ppc64le" ]; then
targets="${targets},ppc64-softmmu"
else
targets="${targets},${arch}-softmmu"
fi
virtfs="--enable-virtfs"
;;
"")
true
;;
*)
echo "Invalid softmmu option: ${softmmu}"
exit 1
;;
esac
./configure \
--disable-kvm \
--disable-vnc \
--disable-guest-agent \
--enable-linux-user \
--static \
${virtfs} \
--target-list="${targets}"
make "-j$(nproc)"
make install
# HACK the binfmt_misc interpreter we'll use expects the QEMU binary to be
# in /usr/bin. Create an appropriate symlink
ln -s "/usr/local/bin/qemu-${arch}" "/usr/bin/qemu-${arch}-static"
purge_packages
popd
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/solaris.sh
================================================
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local arch="${1}"
local manufacturer="${2}"
local binutils=2.38 \
gcc=8.4.0 \
target="${arch}-${manufacturer}-solaris2.10"
install_packages bzip2 \
ca-certificates \
curl \
dirmngr \
g++ \
gpg-agent \
make \
patch \
software-properties-common \
texinfo \
wget \
xz-utils
local td
td="$(mktemp -d)"
pushd "${td}"
mkdir "${td}"/{binutils,gcc}{,-build} "${td}/solaris"
download_binutils "${binutils}" "xz"
tar -C "${td}/binutils" --strip-components=1 -xJf "binutils-${binutils}.tar.xz"
download_gcc "${gcc}" "xz"
tar -C "${td}/gcc" --strip-components=1 -xJf "gcc-${gcc}.tar.xz"
cd gcc
sed -i -e 's/ftp:/https:/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
local apt_arch=
local lib_arch=
case "${arch}" in
x86_64)
apt_arch=solaris-i386
lib_arch=amd64
;;
sparcv9)
apt_arch=solaris-sparc
lib_arch=sparcv9
;;
esac
apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2 main'
dpkg --add-architecture "${apt_arch}"
apt-get update
apt-get install -y --download-only \
"libc:${apt_arch}" \
"liblgrp:${apt_arch}" \
"libm-dev:${apt_arch}" \
"libpthread:${apt_arch}" \
"libresolv:${apt_arch}" \
"librt:${apt_arch}" \
"libsendfile:${apt_arch}" \
"libsocket:${apt_arch}" \
"system-crt:${apt_arch}" \
"system-header:${apt_arch}"
for deb in /var/cache/apt/archives/*"${apt_arch}.deb"; do
dpkg -x "${deb}" "${td}/solaris"
done
apt-get clean
# The -dev packages are not available from the apt repository we're using.
# However, those packages are just symlinks from *.so to *.so..
# This makes all those symlinks.
while IFS= read -r -d '' lib; do
link_name=${lib%.so.*}.so
[ -e "$link_name" ] || ln -sf "${lib##*/}" "$link_name"
done < <(find . -name '*.so.*' -print0)
cd binutils-build
../binutils/configure \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
# Remove Solaris 11 functions that are optionally used by libbacktrace.
# This is for Solaris 10 compatibility.
rm solaris/usr/include/link.h
patch -p0 << 'EOF'
--- solaris/usr/include/string.h
+++ solaris/usr/include/string10.h
@@ -93 +92,0 @@
-extern size_t strnlen(const char *, size_t);
EOF
local destdir="/usr/local/${target}"
mkdir "${destdir}/usr"
cp -r "${td}/solaris/usr/include" "${destdir}/usr"
mv "${td}/solaris/usr/lib/${lib_arch}"/* "${destdir}/lib"
mv "${td}/solaris/lib/${lib_arch}"/* "${destdir}/lib"
ln -s usr/include "${destdir}/sys-include"
ln -s usr/include "${destdir}/include"
# note: solaris2.10 is obsolete, so we can't upgrade to GCC 10 till then.
# for gcc 9.4.0, need `--enable-obsolete`
cd gcc-build
../gcc/configure \
--disable-libada \
--disable-libcilkrts \
--disable-libgomp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls \
--enable-languages=c,c++,fortran \
--with-gnu-as \
--with-gnu-ld \
--target="${target}"
make "-j$(nproc)"
make install
cd ..
# clean up
popd
purge_packages
rm -rf "${td}"
rm "${0}"
}
main "${@}"
================================================
FILE: docker/tidyup.sh
================================================
#!/usr/bin/env bash
rm -rf /var/lib/apt/lists
rm -rf /usr/local/doc
================================================
FILE: docker/toolchain.cmake
================================================
# default toolchain file for targets, see #1110
# required so CMAKE_CROSSCOMPILING_EMULATOR is set,
# as well for embedded systems and other targets.
#
# all embedded systems without an OS should set the system name to generic
# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
set(CMAKE_SYSTEM_NAME "$ENV{CROSS_CMAKE_SYSTEM_NAME}")
set(CMAKE_SYSTEM_PROCESSOR "$ENV{CROSS_CMAKE_SYSTEM_PROCESSOR}")
if(DEFINED ENV{CROSS_TARGET_RUNNER})
set(runner "$ENV{CROSS_TARGET_RUNNER}")
separate_arguments(runner)
set(CMAKE_CROSSCOMPILING_EMULATOR ${runner})
endif()
# not all of these are standard, however, they're common enough
# that it's good practice to define them.
set(prefix "$ENV{CROSS_TOOLCHAIN_PREFIX}")
set(suffix "$ENV{CROSS_TOOLCHAIN_SUFFIX}")
set(CMAKE_C_COMPILER "${prefix}gcc${suffix}")
set(CMAKE_ASM_COMPILER "${prefix}gcc${suffix}")
set(CMAKE_CXX_COMPILER "${prefix}g++${suffix}")
set(CMAKE_AR "${prefix}ar")
set(CMAKE_LINKER "${prefix}ld")
set(CMAKE_NM "${prefix}nm")
set(CMAKE_OBJCOPY "${prefix}objcopy")
set(CMAKE_OBJDUMP "${prefix}objdump")
set(CMAKE_RANLIB "${prefix}ranlib")
set(CMAKE_STRIP "${prefix}strip")
# these are cached so any build system that compiled outside of the rust
# build system, such as a third-party cmake build and install of a shared
# library, will still work. however, cmake-rs can override these values
if(DEFINED ENV{CROSS_CMAKE_OBJECT_FLAGS})
set(CMAKE_C_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "C Compiler options")
set(CMAKE_CXX_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "C++ Compiler options")
set(CMAKE_ASM_FLAGS "$ENV{CROSS_CMAKE_OBJECT_FLAGS}" CACHE STRING "ASM Compiler options")
endif()
# if cross-compiling, we need to disable where the root path
# is found and also provide our own sysroot
if(DEFINED ENV{CROSS_SYSROOT})
set(CMAKE_FIND_ROOT_PATH "$ENV{CROSS_SYSROOT}" "${CMAKE_PREFIX_PATH}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()
set(crt "$ENV{CROSS_CMAKE_CRT}")
if(crt STREQUAL "newlib")
# cmake normally tries to test the C and C++ compilers by building and
# running a binary, but this fails for bare-metal targets, since
# they are missing start files and potentially other symbols.
# choosing to make a static library causes cmake to skip the check.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
endif()
================================================
FILE: docker/validate-android-args.sh
================================================
#!/usr/bin/env bash
# Ensure the NDK, SDK, and Android versions match to exit
# before a build or even worse, a runner later fails.
set -x
set -euo pipefail
main() {
local arch="${1}"
validate_ndk "${arch}"
validate_sdk
validate_system
validate_ndk_sdk "${arch}"
validate_sdk_system
}
validate_ndk() {
local arch="${1}"
local ndk_version=
ndk_version=$(echo "${ANDROID_NDK}" | tr -dc '0-9')
case "${arch}" in
mips|mips64)
if [[ "${ndk_version}" -ge 17 ]]; then
echo "Android NDKs r17+ removed support for MIPS architectures." 1>&2
exit 1
fi
;;
*)
;;
esac
}
validate_sdk() {
local invalid_sdk_versions=(6 7 10 11 20 25)
# shellcheck disable=SC2076
if [[ "${invalid_sdk_versions[*]}" =~ "${ANDROID_SDK}" ]]; then
echo "The Android SDK version ${ANDROID_SDK} is not provided by Android and therefore not supported." 1>&2
exit 1
fi
}
validate_system() {
local major_version
major_version=$(echo "${ANDROID_VERSION}" | cut -d '.' -f 1)
if [[ "${major_version}" -lt 5 ]]; then
echo "Invalid Android version ${ANDROID_VERSION}, must be Android 5+." 1>&2
exit 1
fi
}
validate_ndk_sdk() {
local arch="${1}"
local ndk_version=
ndk_version=$(echo "${ANDROID_NDK}" | tr -dc '0-9')
# no minimum version for most 32-bit architectures
case "${arch}" in
arm|x86)
;;
mips)
check_min_sdk_arch "${arch}" 9
;;
arm64|mips64|x86_64)
check_min_sdk_arch "${arch}" 21
;;
*)
echo "Unsupported architecture, got ${arch}." 1>&2
exit 1
;;
esac
case "${ndk_version}" in
9)
check_sdk_range 3 19
;;
10)
check_sdk_range 3 21
;;
11)
check_sdk_range 3 24
;;
12|13|14)
check_sdk_range 9 24
;;
15)
check_sdk_range 14 26
;;
16)
check_sdk_range 14 27
;;
17)
check_sdk_range 14 28
;;
18)
check_sdk_range 16 28
;;
19)
check_sdk_range 16 28
;;
20)
check_sdk_range 16 29
;;
21|22)
check_sdk_range 21 30
;;
23)
check_sdk_range 21 31
;;
24)
check_sdk_range 21 32
;;
25)
check_sdk_range 21 33
;;
*)
echo "Currently unsupported NDK version of ${ndk_version}." 1>&2
echo "If you would like support, please file an issue." 1>&2
exit 1
;;
esac
}
check_min_sdk_arch() {
local arch="${1}"
local minimum="${2}"
if [[ "${ANDROID_SDK}" -lt "${minimum}" ]]; then
echo "Invalid SDK version ${ANDROID_SDK} for architecture ${arch}" 1>&2
echo "The minimum supported SDK version is ${minimum}." 1>&2
exit 1
fi
}
check_sdk_range() {
local lower="${1}"
local upper="${2}"
if [[ "${ANDROID_SDK}" -lt "${lower}" ]] || [[ "${ANDROID_SDK}" -gt "${upper}" ]]; then
echo "Invalid SDK version ${ANDROID_SDK} for NDK version ${ANDROID_NDK}" 1>&2
echo "Valid SDK versions are ${lower}-${upper}." 1>&2
exit 1
fi
}
validate_sdk_system() {
local major_version
local minor_version
major_version=$(echo "${ANDROID_VERSION}" | cut -d '.' -f 1)
minor_version=$(echo "${ANDROID_VERSION}" | cut -d '.' -f 2)
local system_version="${major_version}.${minor_version}"
case "${system_version}" in
5.0)
check_sdk_system_equal 21
;;
5.1)
check_sdk_system_equal 22
;;
6.0)
check_sdk_system_equal 23
;;
7.0)
check_sdk_system_equal 24
;;
7.1)
check_sdk_system_equal 25
;;
8.0)
check_sdk_system_equal 26
;;
8.1)
check_sdk_system_equal 27
;;
9.0)
check_sdk_system_equal 28
;;
10.0)
check_sdk_system_equal 29
;;
11.0)
check_sdk_system_equal 30
;;
12.0)
check_sdk_system_equal 31
;;
12.1)
# NOTE: also knows as 12L
check_sdk_system_equal 32
;;
13.0)
check_sdk_system_equal 33
;;
*)
echo "Currently unsupported Android system version of ${system_version}." 1>&2
echo "If you would like support, please file an issue." 1>&2
exit 1
;;
esac
}
check_sdk_system_equal() {
local expected=("$@")
local valid=0
for version in "${expected[@]}"; do
if [[ "${ANDROID_SDK}" == "${version}" ]]; then
valid=1
fi
done
if [[ "${valid}" -ne 1 ]]; then
# shellcheck disable=SC2145
echo "Invalid SDK version, got ${ANDROID_SDK} and expected ${expected[@]}." 1>&2
exit 1
fi
}
main "${@}"
================================================
FILE: docker/windows-entry.sh
================================================
#!/usr/bin/env bash
set -e
export HOME=/tmp/home
mkdir -p "${HOME}"
# Initialize the wine prefix (virtual windows installation)
export WINEPREFIX=/tmp/wine
mkdir -p "${WINEPREFIX}"
# FIXME: Make the wine prefix initialization faster
# TODO: https://github.com/cross-rs/cross/issues/1372 wine fails on arm64 qemu
wineboot &> /dev/null || true
# Put libstdc++ and some other mingw dlls in WINEPATH
# This must work for x86_64 and i686
P1="$(dirname "$(find /usr -name libwinpthread-1.dll)")"
WINEPATH="$(ls -d /usr/lib/gcc/*-w64-mingw32/*posix);${P1}"
export WINEPATH
exec "$@"
================================================
FILE: docker/wine.sh
================================================
#!/bin/bash
set -x
set -euo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local version="9.0.0.0~focal-1"
install_packages wget
dpkg --add-architecture i386
# add repository for latest wine version and install from source
# hardcode version, since we might want to avoid a version later.
wget -nc https://dl.winehq.org/wine-builds/winehq.key
# workaround for wine server synchronization, see #1035
# we need to ensure the keys are now stored in `/etc/apt/keyrings`,
# which were previously stored in `/usr/share/keyrings`, and ensure
# our sources list searches for the right location.
mkdir -p /etc/apt/keyrings
mv winehq.key /etc/apt/keyrings/winehq-archive.key
wget -nc https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
mv winehq-focal.sources /etc/apt/sources.list.d/
sed -i s@/usr/share/keyrings/@/etc/apt/keyrings/@ /etc/apt/sources.list.d/winehq-focal.sources || true
# winehq requires all the dependencies to be manually specified
# if we're not using the latest version of a given major version.
apt-get update
apt install --no-install-recommends --assume-yes \
"wine-stable=${version}" \
"wine-stable-amd64=${version}" \
"wine-stable-i386=${version}" \
"winehq-stable=${version}"
purge_packages
}
main "${@}"
================================================
FILE: docker/zig.sh
================================================
#!/usr/bin/env bash
set -x
set -eo pipefail
# shellcheck disable=SC1091
. lib.sh
main() {
local platform="${1}"
install_packages ca-certificates curl xz-utils
install_zig "${platform}"
install_zigbuild "${platform}"
purge_packages
rm "${0}"
}
install_zig() {
local platform="${1}"
local version="0.11.0"
local dst="/opt/zig"
local arch=
local os=
local triple=
case "${platform}" in
'linux/386')
arch="i386"
os="linux"
;;
'linux/amd64')
arch="x86_64"
os="linux"
;;
'linux/arm64')
arch="aarch64"
os="linux"
;;
'linux/riscv64')
arch="riscv64"
os="linux"
;;
'linux/ppc64le')
triple="powerpc64le-linux-gnu"
;;
'linux/s390x')
triple="s390x-linux-gnu"
;;
'darwin/amd64')
arch="x86_64"
os="macos"
;;
'darwin/arm64')
arch="aarch64"
os="macos"
;;
# NOTE: explicitly don't support linux/arm/v6
*)
echo "Unsupported target platform '${platform}'" 1>&2
exit 1
;;
esac
if [[ -n "${arch}" ]]; then
install_zig_tarball "${arch}" "${os}" "${version}" "${dst}"
else
install_zig_source "${triple}" "${version}" "${dst}"
fi
}
install_zig_tarball() {
local arch="${1}"
local os="${2}"
local version="${3}"
local dst="${4}"
local filename="zig-${os}-${arch}-${version}.tar.xz"
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://ziglang.org/download/${version}/${filename}" -O
mkdir -p "${dst}"
tar --strip-components=1 -xJf "${filename}" --directory "${dst}"
popd
rm -rf "${td}"
}
install_zig_source() {
local triple="${1}"
local version="${2}"
local dst="${3}"
local filename="zig-bootstrap-${version}.tar.xz"
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "https://ziglang.org/download/${version}/${filename}" -O
mkdir zig
tar --strip-components=1 -xJf "${filename}" --directory zig
pushd zig
install_packages python3 make g++
./build -j5 "${triple}" native
mv "out/zig-${triple}-native" /opt/zig
popd
popd
rm -rf "${td}"
}
install_zigbuild() {
local platform="${1}"
local version="0.17.5"
local dst="/usr/local"
local triple=
# we don't know if `linux/arm/v7` is hard-float,
# and we don't know the the zigbuild `apple-darwin`
# target doesn't manually specify the architecture.
case "${platform}" in
'linux/386')
triple="i686-unknown-linux-musl"
;;
'linux/amd64')
triple="x86_64-unknown-linux-musl"
;;
'linux/arm64')
triple="aarch64-unknown-linux-musl"
;;
*)
;;
esac
if [[ -n "${triple}" ]]; then
install_zigbuild_tarball "${triple}" "${version}" "${dst}"
else
install_zigbuild_source "${version}" "${dst}"
fi
}
install_zigbuild_tarball() {
local triple="${1}"
local version="${2}"
local dst="${3}"
local repo="https://github.com/messense/cargo-zigbuild"
local filename="cargo-zigbuild-v${version}.${triple}.tar.gz"
local td
td="$(mktemp -d)"
pushd "${td}"
curl --retry 3 -sSfL "${repo}/releases/download/v${version}/${filename}" -O
mkdir -p "${dst}/bin"
tar -xzf "${filename}" --directory "${dst}/bin"
popd
rm -rf "${td}"
}
install_zigbuild_source() {
local version="${1}"
local dst="${2}"
local td
td="$(mktemp -d)"
pushd "${td}"
export RUSTUP_HOME="${td}/rustup"
export CARGO_HOME="${td}/cargo"
curl --retry 3 -sSfL https://sh.rustup.rs -o rustup-init.sh
sh rustup-init.sh -y --no-modify-path --profile minimal
PATH="${CARGO_HOME}/bin:${PATH}" \
cargo install cargo-zigbuild \
--version "${version}" \
--root "${dst}" \
--locked
popd
rm -rf "${td}"
}
main "${@}"
================================================
FILE: docs/cargo_configuration.md
================================================
- [Configuring `cross`](#configuring-cross)
- [Configuring Cargo through environment variables](#configuring-cargo-through-environment-variables)
# Configuring `cross`
Please refer to the following docs:
- [config file](./config_file.md)
- [env variables](./environment_variables.md)
# Configuring Cargo through environment variables
When cross-compiling, `cargo` does not use environment variables such as
`RUSTFLAGS`, and must be provided using `CARGO_TARGET_${TARGET}_${OPTION}`.
Please note that some of these may be provided by the image themselves, such as
runners, and should be overwritten with caution. A list of important flags
includes:
- `CARGO_TARGET_${TARGET}_LINKER`: specify a custom linker passed to rustc.
- `CARGO_TARGET_${TARGET}_RUNNER`: specify the wrapper to run executables.
- `CARGO_TARGET_${TARGET}_RUSTFLAGS`: add additional flags passed to rustc.
Any of the following [flags][cargo-flags] can be provided, and are converted to
uppercase. For example, changing `foo-bar` would be provided as
`CARGO_TARGET_${TARGET}_FOO_BAR`.
For example, to run binaries on `i686-unknown-linux-gnu` with Qemu, first
create a custom image containing Qemu, and run with the following command:
```
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER=qemu-i386 cross run ...
```
[cargo-flags]: https://doc.rust-lang.org/cargo/reference/config.html#target
================================================
FILE: docs/config_file.md
================================================
- [`build`](#build)
- [`build.env`](#buildenv)
- [`build.dockerfile`](#builddockerfile)
- [`build.zig`](#buildzig)
- [`target.TARGET`](#targettarget)
- [`target.TARGET.pre-build`](#targettargetpre-build)
- [`target.TARGET.image`](#targettargetimage)
- [`target.TARGET.env`](#targettargetenv)
- [`target.TARGET.dockerfile`](#targettargetdockerfile)
- [`target.TARGET.zig`](#targettargetzig)
> **Note**: Additional configuration is available through
> [environment variables](./environment_variables.md)
You can place a `Cross.toml` file in the root of your Cargo project or use a
`CROSS_CONFIG` environment variable to tweak cross's behavior. You can also use
`package.metadata.cross.KEY` in `Cargo.toml`, and the priority of settings is
environment variables override `Cross.toml` options, which override
`Cargo.toml` options. Annotated examples of both
[`Cross.toml`][example-cross-toml] and [`Cargo.toml`][example-cargo-toml] are
provided.
For example, the `[build]` table in `Cross.toml` is identical to setting
`[package.metadata.cross.build]` in `Cargo.toml`.
The `cross` configuration in the `Cross.toml` file can contain the following
elements:
# `build`
The `build` key allows you to set global variables, e.g.:
> *NOTE*: `$CROSS_DEB_ARCH` is automatically provided by cross,
> [see here][custom_images_automatic_arch].
```toml
[build]
build-std = false # do not build the std library
zig = false # do not use zig cc for the builds
default-target = "x86_64-unknown-linux-gnu" # use this target if none is explicitly provided
pre-build = [ # additional commands to run prior to building the package
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get --assume-yes install libssl-dev:$CROSS_DEB_ARCH"
]
```
# `build.env`
With the `build.env` key you can globally set volumes that should be mounted in
the Docker container or environment variables that should be passed through.
For example:
```toml
[build.env]
volumes = ["VOL1_ARG", "VOL2_ARG=/path/to/volume"]
passthrough = ["VAR1_ARG", "VAR2_ARG=VALUE"]
```
Note how in the environment variable passthrough, we can provide a definition
for the variable as well. `VAR1_ARG` will be the value of the environment
variable on the host, while `VAR2_ARG` will be `VALUE`. Likewise, the path to
the volume for `VOL1_ARG` will be the value of the environment variable on the
host, while `VOL2_ARG` will be `/path/to/volume`.
# `build.dockerfile`
> If the image you want to use is already available from a container registry,
> check out the `target.TARGET.image` option below.
The `build.dockerfile` key lets you provide a custom Docker image for all
targets, except those specified `target.TARGET.dockerfile`. The value can be
provided as either a table or a string. If `build.dockerfile` is set to a
string, it's equivalent to setting `build.dockerfile.file` to that value. For
example, using only a string:
```toml
[build]
dockerfile = "./Dockerfile"
```
Or using a table:
```toml
[build.dockerfile]
file = "./Dockerfile" # the dockerfile to use relative to the `Cargo.toml`
context = "." # the context folder to build the script in. defaults to `.`
build-args = { ARG1 = "foo" } # https://docs.docker.com/engine/reference/builder/#arg
```
`cross` will build and use the image that was built instead of the default
image. It's recommended to base your custom image on the default Docker image
that `cross` uses: `ghcr.io/cross-rs/{{TARGET}}:{{VERSION}}` (where
`{{VERSION}}` is `cross`'s version). This way you won't have to figure out how
to install a cross-C toolchain in your custom image.
> *NOTE*: `$CROSS_DEB_ARCH` is automatically provided by cross, [see
> here][custom_images_automatic_arch].
``` Dockerfile
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:latest
RUN dpkg --add-architecture $CROSS_DEB_ARCH && \
apt-get update && \
apt-get install --assume-yes libfoo:$CROSS_DEB_ARCH
```
`cross` will provide the argument `CROSS_BASE_IMAGE` which points to the
default image `cross` would use for the target. Instead of the above, you can
also then do the following:
```Dockerfile
ARG CROSS_BASE_IMAGE
FROM $CROSS_BASE_IMAGE
RUN ...
```
# `build.zig`
The `build.zig` key lets you use `zig cc` as a cross-compiler, enabling
cross-compilation to numerous architectures and glibc versions using a single
Docker image. Note that `zig cc` doesn't support all targets: only a subset of
our Linux GNU targets, so it might be better to set these values in
`target.TARGET.zig` instead. The value can be provided as either a table, a bool,
or a string. If `build.zig` is set to a string, it's equivalent to setting
`build.zig.version` to that value and `build.zig.enable` to true:
```toml
[build]
zig = "2.17"
```
If `build.zig` is set to a bool, it's equivalent to setting `build.zig.enable`
to that value:
```toml
[build]
zig = true
```
Or using a table:
```toml
[build.zig]
enable = true # enable or disable the use of zig cc
version = "2.17" # the glibc version to use
image = "myimage" # a custom image containing zig to use
```
# `target.TARGET`
The `target` key allows you to specify parameters for specific compilation
targets:
```toml
[target.aarch64-unknown-linux-gnu]
build-std = ["core", "alloc"] # always build the `core` and `alloc` crates from the std library
image = "test-image" # use a different image for the target
runner = "qemu-user" # wrapper to run the binary (must be `qemu-system`, `qemu-user`, or `native`).
```
# `target.TARGET.pre-build`
The `pre-build` field can reference a file to copy and run. This file is
relative to the container context, which would be the workspace root, or the
current directory if `--manifest-path` is used. For more involved scripts,
consider using `target.TARGET.dockerfile` instead to directly control the
execution.
This script will be invoked as `RUN ./pre-build-script $CROSS_TARGET` where
`$CROSS_TARGET` is the target triple.
```toml
[target.aarch64-unknown-linux-gnu]
pre-build = "./scripts/my-script.sh"
```
```bash
$ cat ./scripts/my-script.sh
#!/usr/bin/env bash
apt-get install libssl-dev -y
```
`pre-build` can also be a list of commands to directly run inside the image:
> *NOTE*: `$CROSS_DEB_ARCH` is automatically provided by cross, [see
> here][custom_images_automatic_arch].
```toml
[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update",
"apt-get install --assume-yes libfoo:$CROSS_DEB_ARCH"
]
```
# `target.TARGET.image`
```toml
[target.aarch64-unknown-linux-gnu]
image = "my/image:latest"
```
In the example above, `cross` will use a image named `my/image:latest` instead of
the default one. Normal Docker behavior applies, so:
- Docker will first look for a local image named `my/image:latest`
- If it doesn't find a local image, then it will look in Docker Hub.
- If only `image:latest` is specified, then Docker won't look in Docker Hub.
- If the tag is omitted, then Docker will use the `latest` tag.
If you specify a tag but no image name, `cross` will use the default image with
the tag you provided:
```toml
[target.aarch64-unknown-linux-gnu]
# Translates to `ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge`
image = ":edge"
[target.x86_64-unknown-linux-musl]
# Translates to `ghcr.io/cross-rs/x86_64-unknown-linux-musl@sha256:77db671d8356a64ae72a3e1415e63f547f26d374fbe3c4762c1cd36c7eac7b99`
image = "@sha256:77db671d8356a64ae72a3e1415e63f547f26d374fbe3c4762c1cd36c7eac7b99"
```
You can also specify a subtarget with no tag nor image name:
```toml
[target.x86_64-unknown-linux-gnu]
# Translates to `ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.3.0-centos`
image = "-centos"
```
The `image` key can also take the toolchains/platforms supported by the image:
```toml
[target.aarch64-unknown-linux-gnu]
image.name = "alpine:edge"
image.toolchain = ["x86_64-unknown-linux-musl", "linux/arm64=aarch64-unknown-linux-musl"] # Defaults to `x86_64-unknown-linux-gnu`
```
# `target.TARGET.env`
The `env` key allows you to specify environment variables that should be used
for a specific compilation target. This is similar to `build.env`, but allows
you to be more specific per target:
```toml
[target.x86_64-unknown-linux-gnu.env]
volumes = ["VOL1_ARG", "VOL2_ARG=/path/to/volume"]
passthrough = ["VAR1_ARG", "VAR2_ARG=VALUE"]
```
# `target.TARGET.dockerfile`
The `dockerfile` key lets you provide a custom Docker image for the
given target. The value can be provided as either a table or a string. If
`target.TARGET.dockerfile` is set to a string, it's equivalent to setting
`target.(...).dockerfile.file` to that value. For example, using only a string:
```toml
[target.aarch64-unknown-linux-gnu]
dockerfile = "./Dockerfile"
```
Or using a table:
```toml
[target.aarch64-unknown-linux-gnu.dockerfile]
file = "./Dockerfile" # the dockerfile to use relative to the `Cargo.toml`
context = "." # the context folder to build the script in. defaults to `.`
build-args = { ARG1 = "foo" } # https://docs.docker.com/engine/reference/builder/#arg
```
# `target.TARGET.zig`
The `target.TARGET.zig` key lets you use `zig cc` as a cross-compiler, enabling
cross-compilation to numerous architectures and glibc versions using a single
Docker image. The value can be provided as either a table, a bool, or a string.
If `target.TARGET.zig` is set to a string, it's equivalent to setting
`target.TARGET.zig.version` to that value and `target.TARGET.zig.enable` to
true:
```toml
[target.aarch64-unknown-linux-gnu]
zig = "2.17"
```
If `target.TARGET.zig` is set to a bool, it's equivalent to setting
`target.TARGET.zig.enable` to that value:
```toml
[target.aarch64-unknown-linux-gnu]
zig = true
```
Or using a table:
```toml
[target.aarch64-unknown-linux-gnu.zig]
enable = true # enable or disable the use of zig cc
version = "2.17" # the glibc version to use
image = "myimage" # a custom image containing zig to use
```
[example-cross-toml]: https://github.com/cross-rs/wiki_assets/blob/main/Configuration/Cross.toml
[example-cargo-toml]: https://github.com/cross-rs/wiki_assets/blob/main/Configuration/Cargo.toml
[custom_images_automatic_arch]: ./custom_images.md#automatic-target-architecture-on-debian
================================================
FILE: docs/custom_images.md
================================================
- [Automatic Target Architecture on Debian](#automatic-target-architecture-on-debian)
- [Custom Images](#custom-images)
- [Adding Dependencies to Existing Images](#adding-dependencies-to-existing-images)
- [Custom Dockerfile](#custom-dockerfile)
- [Custom Image](#custom-image)
# Automatic Target Architecture on Debian
Custom images generated from config `dockerfile` or `pre-build` keys will
export `CROSS_DEB_ARCH`, which allows you to install packages from
Ubuntu/Debian repositories without having to specify the exact architecture.
You can find an
[example of this here](#adding-dependencies-to-existing-images).
# Custom Images
`cross` provides default Docker images for the targets listed [in the
README](../README.md#supported-targets). However, it can't cover every single
use case out there.
## Adding Dependencies to Existing Images
If you simply need to install a dependency availaible in ubuntus package
manager, see [`target.TARGET.pre-build`][config-target-pre-build]:
```toml
[target.x86_64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH"
]
```
For FreeBSD targets, a few helper scripts are available for use in
[`target.TARGET.pre-build`][config-target-pre-build]:
```toml
[target.x86_64-unknown-freebsd]
pre-build = ["""
export FREEBSD_MIRROR=$(/freebsd-fetch-best-mirror.sh) &&
/freebsd-setup-packagesite.sh &&
/freebsd-install-package.sh xen-tools
"""]
```
## Custom Dockerfile
For other targets, or when the default image is not enough, you can use the
[`target.{{TARGET}}.dockerfile`][config_target_dockerfile] field
in `Cross.toml` to use a custom Docker image for a specific target:
> *NOTE*: Refer to the [`build.dockerfile`][config_build_dockerfile] section of
> the configuration for tips when writing your own `Dockerfile`.
``` toml
[target.aarch64-unknown-linux-gnu]
dockerfile = "Dockerfile"
```
`cross` will build and use the image that was built instead of the default
image.
## Custom Image
If there is a pre-built image for your specific target, you can use the
[`target.{{TARGET}}.image`][config_target_image] field in `Cross.toml` to use
that instead:
``` toml
[target.aarch64-unknown-linux-gnu]
image = "my/image:tag"
```
In thie case, `cross` will use a image named `my/image:tag` instead of the
default one. Normal Docker behavior applies, so:
- Docker will first look for a local image named `my/image:tag`
- If it doesn't find a local image, then it will look in Docker Hub.
- If only `image:tag` is specified, then Docker won't look in Docker Hub.
- If only `tag` is omitted, then Docker will use the `latest` tag.
[config-target-pre-build]: ./config_file.md#targettargetpre-build
[config_target_dockerfile]: ./config_file.md#targettargetdockerfile
[config_target_image]: ./config_file.md#targettargetimage
[config_build_dockerfile]: ./config_file.md#builddockerfile
================================================
FILE: docs/environment_variables.md
================================================
- [Configuring cross with environment variables](#configuring-cross-with-environment-variables)
- [Environment-Variable passthrough](#environment-variable-passthrough)
# Configuring cross with environment variables
Cross can be further customized by setting certain environment variables.
In-depth documentation with examples can be found [here][env-examples].
- `CROSS_CONTAINER_ENGINE`: The container engine to run cross in. Defaults to
`docker` then `podman`, whichever is found first (example: `docker`, see the
[FAQ][faq-container-engines]).
- `NIX_STORE`: The directory for the [Nix store][nix-store] (example:
`/nix/store`).
- `CROSS_CONTAINER_UID`: Set the user identifier for the cross command
(example: `1000`).
- `CROSS_CONTAINER_GID`: Set the group identifier for the cross command
(example: `1000`).
- `CROSS_CONTAINER_IN_CONTAINER`: Inform `cross` that it is running inside a
container (example: `true`, see the FAQ).
- `CROSS_CONTAINER_OPTS`: Additional arguments to provide to the container
engine during `$engine run` (example: `--env MYVAR=1` where `engine=docker`).
- `CROSS_CONFIG`: Specify the path to the `cross` config file (see [Config
File][cross-config-file]).
- `CROSS_BUILD_OPTS`: Space separated flags to add when building a custom
image, i.e. `--network=host`
- `CROSS_DEBUG`: Print debugging information for `cross`.
- `CROSS_COMPATIBILITY_VERSION`: Use older `cross` behavior (example: `0.2.1`).
- `CROSS_CUSTOM_TOOLCHAIN`: Specify that `rustup` is using a custom toolchain,
and therefore should not try to add targets/install components. Useful with
[`cargo-bisect-rustc`][cargo-bisect-rustc].
- `CROSS_REMOTE`: Inform `cross` it is using a remote container engine, and use
data volumes rather than local bind mounts. See [Remote][docs-remote] for
more information using remote container engines.
- `QEMU_STRACE`: Get a backtrace of system calls from “foreign” (non x86_64)
binaries when using `cross` run.
- `CARGO_BUILD_TARGET`: Sets the default target, similar to specifying
`--target`.
- `CROSS_BUILD_DOCKERFILE`: Specify to provide a custom Docker image for all
targets.
- `CROSS_ROOTLESS_CONTAINER_ENGINE`: Specify whether to container engine runs
as root or is rootless. If set to `auto` or not provided, it assumes `docker`
runs as root and all other container engines are rootless.
- `CROSS_CONTAINER_USER_NAMESPACE`: Custom the [container user
namespace][container-user-namespace]. If set to `none`, user namespaces will
be disabled. If not provided or set to `auto`, it will use the default
namespace.
- `CROSS_CUSTOM_TOOLCHAIN_COMPAT`: A descriptive name for a custom toolchain so
`cross` can convert it to a fully-qualified toolchain name.
- `CROSS_CONTAINER_ENGINE_NO_BUILDKIT`: The container engine does not have
`buildx` command (or BuildKit support) when building custom images.
- `CROSS_NO_WARNINGS`: Set to `1` to panic on warnings from `cross`, before
building the executables.
Use `0` to disable this behaviour.
The no warnings behaviour is implicitly enabled in CI pipelines.
All config file options can also be specified using environment variables. For
example, setting `CROSS_TARGET_AARCH64_UNKNOWN_LINUX_GNU_DOCKERFILE=foo` is
identical to setting `target.aarch64-unknown-linux-gnu.dockerfile = foo`.
# Environment-Variable passthrough
By default, `cross` does not pass most environment variables into the build
environment from the calling shell. This is chosen as a safe default as most
use cases will not want the calling environment leaking into the inner
execution environment. There are, however, some notable exceptions: most
environment variables `cross` or `cargo` reads are passed through automatically
to the build environment. The major exceptions are variables that are set by
`cross` or conflict with our build environment, including:
- `CARGO_HOME`
- `CARGO_TARGET_DIR`
- `CARGO_BUILD_TARGET_DIR`
- `CARGO_BUILD_RUSTC`
- `CARGO_BUILD_RUSTC_WRAPPER`
- `CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER`
- `CARGO_BUILD_RUSTDOC`
- `CROSS_RUNNER`
- `CROSS_RUSTC_MAJOR_VERSION`
- `CROSS_RUSTC_MINOR_VERSION`
- `CROSS_RUSTC_PATCH_VERSION`
Otherwise, any environment variables that start with CARGO_ or CROSS_, and a
few others, will be available in the build environment. For example, RUSTFLAGS
and CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS will both be automatically
available in the build environment.
In the instances that you do want to pass through additional environment
variables, this can be done via `build.env.passthrough` in your `Cross.toml`:
```toml
[build.env]
passthrough = [
"RUST_BACKTRACE",
"RUST_LOG",
"TRAVIS",
]
```
To pass variables through for one target but not others, you can use
this syntax instead:
```toml
[target.aarch64-unknown-linux-gnu.env]
passthrough = [
"RUST_DEBUG",
]
```
[env-examples]: https://github.com/cross-rs/wiki_assets/blob/main/Configuration/crossrc.bash_aliases
[faq-container-engines]: https://github.com/cross-rs/cross/wiki/FAQ#explicitly-choose-the-container-engine
[nix-store]: https://nixos.org/manual/nix/stable/introduction.html
[cross-config-file]: ./config_file.md
[cargo-bisect-rustc]: https://github.com/rust-lang/cargo-bisect-rustc
[docs-remote]: ./remote.md
[container-user-namespace]: https://docs.docker.com/engine/security/userns-remap/
================================================
FILE: docs/getting-started.md
================================================
- [Installing Cross](#installing-cross)
- [Installing Rust via Rustup](#installing-rust-via-rustup)
- [Installing Cross](#installing-cross)
- [Installing A Container Engine](#installing-a-container-engine)
- [Cross-Compiling Your First Package](#cross-compiling-your-first-package)
New to cross? Cross-compilation? Container engines? Here's how to get up-and-running.
# Installing Cross
## Installing Rust via Rustup
`cross` requires a `rustup` installation of Rust. To do so, the recommended
instructions are documented [here](https://www.rust-lang.org/tools/install),
but might differ on some platforms. For UNIX-like systems, run the following
command in a terminal and follow the instructions to install Rust and add Rust
to the path:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
On Windows, download
[rustup-init.exe](https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe)
or following the [other installation
methods](https://forge.rust-lang.org/infra/other-installation-methods.html),
say, to install from a package manager.
On some platforms, such as NixOS, you might need to use a package manager since
the default `rustup` install will fail. On NixOS, you should run the following,
which will install `rustup` and the latest `stable` release of Rust.
```bash
nix-env -i rustup
rustup toolchain install stable
```
Note that you might need additional tools on some platforms to get `rustc` and
`cargo` working. On UNIX-like systems, this generally means an install of GCC
or Clang. For example, on NixOS you will likely need to install GCC via
`nix-env -i gcc` and then go into a GCC and Rust shell (`nix-shell -p gcc
rustup`). On Alpine, you'll need to run `apk add libgcc gcc musl-dev`. Exact
instructions will differ by OS and Linux distro, feel free to ask on the
[discussion](https://github.com/cross-rs/cross/discussions) or our [Matrix
room](https://matrix.to/#/#cross-rs:matrix.org) if you have any questions.
## Installing Cross
Once `cargo` is installed via `rustup`, and the necessary additional tools are
present, you can now install `cross` via `cargo`:
```bash
cargo install cross
# Optionally, if you have cargo-binstall, you can install via pre-built binary
cargo binstall cross
```
Once `cross` is installed, you need a container engine and you can start
cross-compiling.
# Installing A Container Engine
On Windows and macOS, we generally recommend you use Docker unless you know
what you're doing. [Docker
Desktop](https://www.docker.com/products/docker-desktop/) install instructions
can be found [here](https://www.docker.com/products/docker-desktop/). On Linux,
you can either install via [Docker
Engine](https://docs.docker.com/engine/install/ubuntu/), [Docker
Desktop](https://docs.docker.com/desktop/install/linux-install/) or
[Podman](https://podman.io/getting-started/installation). We generally
recommend Podman, since it runs rootless by default. If you choose to use
Docker, make sure you add users to the [docker
group](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)
so it can be run without `sudo` (note that this has security implications) or
use [rootless](https://docs.docker.com/engine/security/rootless/)†
Docker.
If you use Docker Desktop for Windows, ensure you're using the WSL2. Follow the
[WSL2 installation
instructions](https://docs.microsoft.com/en-us/windows/wsl/install) to enable
the [WSL2 backend in docker](https://docs.docker.com/desktop/windows/wsl/).
Once your container engine is installed, you can check that it is running via:
```bash
# or use podman, if installed
$ docker ps -a
```
†Using rootless docker also requires setting the environment
variable `CROSS_ROOTLESS_CONTAINER_ENGINE=1`.
# Cross-Compiling Your First Package
Once both `cross` and the container engine are installed, you can build your
first package: this is all that's required.
```bash
$ cargo init --bin hello
$ cd hello
$ cross run --target aarch64-unknown-linux-gnu
Compiling hello v0.1.0 (/project)
Finished dev [unoptimized + debuginfo] target(s) in 0.64s
Running `/linux-runner aarch64 /target/aarch64-unknown-linux-gnu/debug/hello`
Hello, world!
```
This will automatically install the Rust target required and the Docker image
containing the toolchain to cross-compile your target.
If you get an error similar to `error: toolchain
'stable-x86_64-unknown-linux-gnu' does not support components`, try
reinstalling that toolchain with rustup.
```sh
$ rustup toolchain uninstall stable-x86_64-unknown-linux-gnu
$ rustup toolchain install stable-x86_64-unknown-linux-gnu --force-non-host
```
================================================
FILE: docs/recipes.md
================================================
- [OpenSSL](#openssl)
- [Vendored](#vendored)
- [Pre-build](#pre-build)
- [Custom dockerfile](#custom-dockerfile)
- [sccache](#sccache)
- [Redoxer](#redoxer)
- [vcpkg, Meson, and Conan](#vcpkg-meson-and-conan)
- [Using Clang and Software Collections on CentOS7](#using-clang-and-software-collections-on-centos7)
This contains recipes for common logic use cases.
# OpenSSL
You can either use the vendored or system packages for the
[openssl](https://crates.io/crates/openssl) crate. See
[openssl-certs](https://github.com/cross-rs/wiki_assets/tree/main/Recipes/openssl-certs)
for a working project.
## Vendored
Use the vendored feature of the openssl crate by adding the following to your
dependencies in `Cargo.toml`:
```toml,cargo
openssl = { version = "0.10", features = ["vendored"] }
```
## Pre-build
To install OpenSSL in an image with `apt-get` available add the following to
your [Cross
configuration](./config_file.md):
```toml
[target.x86_64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH"
]
```
## Custom dockerfile
A sample Dockerfile for `aarch64` with OpenSSL support is:
```Dockerfile
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge
RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install --assume-yes libssl-dev:arm64
```
Build this image and use it, as is described extensively in [Custom
Images](./custom_images.md).
# sccache
sccache support can be done either by `sccache` from source or using a pre-built binary. See [sccache](https://github.com/cross-rs/wiki_assets/tree/main/Recipes/sccache) for a working project using pre-build hooks.
1. Create a script to [install](#sccache-install-script) sccache in the image, either from a [pre-built binary](#sccache-prebuilt-binary) or [from source](#sccache-from-source).
2. Extend a [Dockerfile](#sccache-dockerfile) to install sccache in the image.
3. Passthrough the appropriate environment variables in [Cross.toml](#sccache-cross-toml) when using sccache.