CrossForge is a native compilation tool that uses Docker containers to compile C projects for multiple architectures. It performs native compilation within Docker containers of different architectures, providing a unified interface for building across platforms.
- Native compilation for 9 different architectures using Docker containers
- Static linking support with
--staticflag - Automatic dependency management via Docker containers
- Universal binary processing - works with any C/C++ project
- Docker-based isolation - clean build environments
- amd64 - Intel x86 64-bit
- i386 - Intel x86 32-bit
- arm32v5 - ARM 32-bit (ARMv5)
- arm32v7 - ARM 32-bit (ARMv7)
- arm64v8 - ARM 64-bit (ARMv8)
- mips64le - MIPS 64-bit (little-endian)
- ppc64le - PowerPC 64-bit (little-endian)
- riscv64 - RISC-V 64-bit
- s390x - IBM System/390 64-bit
- Docker installed and running
- GCC compiler (for building xforge itself)
- Make (optional, for using the Makefile)
makegcc -Wall -Wextra -std=c99 -O2 -o crossforge xforge.csudo ./install.shThis installs to /opt/archbox/ with a symlink in /usr/local/bin/.
Simply place the crossforge binary in your project root directory or add it to your PATH.
./crossforge -a <architecture> [--static] <command>Natively compile a project for ARM using ARM container:
./crossforge -a arm32v7 make -C project/Natively compile for RISC-V 64-bit using RISC-V container:
./crossforge -a riscv64 make -C myproject/Create fully static binaries that run anywhere:
./crossforge -a s390x --static make -C project/Natively compile with static linking and custom make targets:
./crossforge -a arm64v8 --static make -C project/ clean allCompile a single static binary:
./crossforge -a amd64 --static gcc -o test test.cFirst build the Docker images for your target architectures:
# Build all architectures
./build-docker-images.sh
# Build specific architecture
./build-docker-images.sh -a s390x
# Clean existing images before building
./build-docker-images.sh --cleanup- Architecture Detection: CrossForge maps the specified architecture to the appropriate Docker image and platform.
- Docker Management: It automatically pulls the required Docker image if not already available.
- Container Execution: Runs the specified command in a Docker container with the current directory mounted as
/workspace. - Native Compilation: The Docker container contains the native compilation toolchain for that architecture.
- Normal Build: First builds the project normally in the target architecture container.
- Binary Detection: Automatically finds all executable ELF binaries in the project directory.
- Static Conversion: Uses
staticxto convert each binary to a fully static version (adds-staticsuffix). - Dependency Bundling: All library dependencies are bundled into the binary.
CrossForge uses custom Debian-based Docker images with staticx pre-installed:
crossforge-amd64:latestfor x86_64crossforge-s390x:latestfor s390xcrossforge-riscv64:latestfor RISC-Vcrossforge-arm32v7:latestfor ARM 32-bitcrossforge-arm64v8:latestfor ARM 64-bit- And more... (one per supported architecture)
Each image includes:
- Complete native compilation toolchain for that architecture
- Development libraries and headers
- Staticx for creating static binaries
- Patchelf for ELF manipulation
- Smaller size - libraries are shared
- Requires target system libraries - glibc, libcurl, etc.
- Faster build times - no static conversion step
- Self-contained - no external dependencies
- Larger size - all libraries bundled
- Portable - runs on any system of target architecture
- Slower build - additional staticx conversion step
The tool runs commands in Docker containers with the current working directory mounted as /workspace. All environment variables from the host system are available in the container.
- If an unsupported architecture is specified, the tool lists all supported architectures.
- If Docker is not available or fails to pull an image, appropriate error messages are displayed.
- Command execution failures are reported with exit codes.
- Staticx failures show clear error messages with troubleshooting hints.
Ensure Docker is installed and running:
docker --version
docker infoIf you get permission errors, you may need to run Docker commands with sudo or add your user to the docker group:
sudo usermod -aG docker $USERCheck the list of supported architectures:
./crossforgeEnsure your project's Makefile and source code are compatible with native compilation in different architectures. Some projects may require additional configuration or patches for certain architectures.
Check that:
- Docker images have staticx installed
- Built binaries are ELF executables
- Sufficient disk space for static binaries
# 1. Build Docker images
./build-docker-images.sh -a s390x
# 2. Natively compile with static linking
./crossforge -a s390x --static make -C myproject/
# 3. Deploy static binary
scp myproject/binary-static user@target-system:/usr/local/bin/# Build for multiple architectures
for arch in amd64 arm64v8 s390x; do
./crossforge -a $arch --static make -C project/
done
# Results: project/binary-static (per arch)Remove built files:
make cleanClean Docker images:
./build-docker-images.sh --cleanupUninstall from system:
make uninstallThis project is provided as-is for educational and development purposes.