Last active
June 13, 2018 04:43
-
-
Save jackpot51/6680ad973986e84d69c79854249f2b7e to your computer and use it in GitHub Desktop.
How to use the new Redox cross compile support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clone Rust with Redox cross compilation support | |
git clone https://github.com/redox-os/rust -b redox_cross --recursive | |
# Make a build directory | |
cd rust | |
mkdir build | |
cd build | |
# Create a config.toml | |
cat > config.toml <<EOF | |
[build] | |
target = ["x86_64-unknown-redox"] | |
[rust] | |
codegen-units = 0 | |
use-jemalloc = false | |
EOF | |
# Build Rust | |
../x.py build -j$(nproc) --stage 1 | |
# Stage Rust | |
../x.py dist -j$(nproc) --keep-stage 1 | |
# Install Rust | |
build/tmp/dist/rustc-1.15.0-dev-x86_64-unknown-linux-gnu/install.sh --prefix=`pwd`/prefix --verbose | |
build/tmp/dist/rust-std-1.15.0-dev-x86_64-unknown-linux-gnu/install.sh --prefix=`pwd`/prefix --verbose | |
build/tmp/dist/rust-std-1.15.0-dev-x86_64-unknown-redox/install.sh --prefix=`pwd`/prefix --verbose | |
# Build and install openlibm | |
git clone https://github.com/redox-os/openlibm.git -b master | |
CFLAGS=-fno-stack-protector make -C openlibm libopenlibm.a | |
cp openlibm/libopenlibm.a prefix/lib/rustlib/x86_64-unknown-redox/lib | |
# Build and install syscall crate | |
git clone https://github.com/redox-os/syscall.git -b master | |
prefix/bin/rustc syscall/src/lib.rs --target=x86_64-unknown-redox --crate-type rlib --crate-name syscall --out-dir prefix/lib/rustlib/x86_64-unknown-redox/lib | |
# Build and install ralloc crate | |
git clone https://github.com/redox-os/ralloc.git -b redox_cross | |
prefix/bin/rustc ralloc/src/lib.rs --target=x86_64-unknown-redox --crate-type rlib --crate-name ralloc --cfg 'feature="allocator"' --out-dir prefix/lib/rustlib/x86_64-unknown-redox/lib | |
# Create and build a test application | |
cat > test.rs <<EOF | |
fn main() { | |
println!("Hello from Redox"); | |
} | |
EOF | |
prefix/bin/rustc --target=x86_64-unknown-redox test.rs | |
# Install on Redox | |
REDOX_PATH=../../redox | |
cp test "$REDOX_PATH/filesystem/bin" | |
cd "$REDOX_PATH" | |
make qemu | |
# Test in Redox - expected output "Hello from Redox" | |
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment