diff --git a/.gitignore b/.gitignore index d35c36f..e9868bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /target -toolchain/ *.swp diff --git a/cross/.gitignore b/cross/.gitignore new file mode 100644 index 0000000..9633208 --- /dev/null +++ b/cross/.gitignore @@ -0,0 +1 @@ +toolchain/ \ No newline at end of file diff --git a/cross/README.md b/cross/README.md new file mode 100644 index 0000000..0ebf6ff --- /dev/null +++ b/cross/README.md @@ -0,0 +1,3 @@ +# Cross compilation + +This directory contains utilities to build a toolchain to be used to cross-compile packages. diff --git a/cross/build.sh b/cross/build.sh new file mode 100755 index 0000000..c480009 --- /dev/null +++ b/cross/build.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +# If the target is not specified, set to default +if [ -z $TARGET ]; then + export TARGET=i686-unknown-linux-musl +fi + +# Prepare +mkdir -p toolchain/repo +PATH="$(pwd)/../target/release:$PATH" +export SYSROOT="$(pwd)/toolchain/" +export LOCAL_REPO="$(pwd)/toolchain/repo/" + +# binutils +blimp-builder desc/binutils toolchain/repo/ +yes | blimp install binutils + +# musl +source ./env.sh +HOST="$TARGET" blimp-builder desc/musl toolchain/repo/ +unset CC LD CFLAGS LDFLAGS RUSTFLAGS +yes | blimp install musl + +# TODO clang \ No newline at end of file diff --git a/cross/desc/binutils/build-hook b/cross/desc/binutils/build-hook new file mode 100755 index 0000000..7665f09 --- /dev/null +++ b/cross/desc/binutils/build-hook @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e +cd * + +mkdir build +cd build + +# Compile +../configure \ + --prefix=/usr \ + --build="$BUILD" \ + --host="$HOST" \ + --target="$TARGET" \ + --disable-werror \ + --enable-64-bit-bfd +make -j${JOBS} + +# Install +make DESTDIR=$SYSROOT install -j1 diff --git a/cross/desc/binutils/package.json b/cross/desc/binutils/package.json new file mode 100644 index 0000000..abc269f --- /dev/null +++ b/cross/desc/binutils/package.json @@ -0,0 +1,17 @@ +{ + "sources": [ + { + "location": "/", + "url": "https://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.gz" + } + ], + "package": { + "name": "binutils", + "version": "2.42", + + "description": "The GNU Binutils are a collection of binary tools.", + + "build_deps": [], + "run_deps": [] + } +} diff --git a/cross/desc/musl/build-hook b/cross/desc/musl/build-hook new file mode 100755 index 0000000..dde2517 --- /dev/null +++ b/cross/desc/musl/build-hook @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e +cd * + +# Compile +./configure \ + --build="$BUILD" \ + --host="$HOST" \ + --target="$TARGET" \ + --prefix="/usr" \ + --enable-optimize \ + --enable-shared +make -j${JOBS} + +# Install +make DESTDIR=$SYSROOT install diff --git a/cross/desc/musl/package.json b/cross/desc/musl/package.json new file mode 100644 index 0000000..e8ab8bf --- /dev/null +++ b/cross/desc/musl/package.json @@ -0,0 +1,17 @@ +{ + "sources": [ + { + "location": "/", + "url": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + } + ], + "package": { + "name": "musl", + "version": "1.2.5", + + "description": "musl is an implementation of the C standard library built on top of the Linux system call API, including interfaces defined in the base language standard, POSIX, and widely agreed-upon extensions.", + + "build_deps": [], + "run_deps": [] + } +} diff --git a/scripts/cross_compile_env.sh b/cross/env.sh old mode 100644 new mode 100755 similarity index 56% rename from scripts/cross_compile_env.sh rename to cross/env.sh index e827d94..ba1ae0c --- a/scripts/cross_compile_env.sh +++ b/cross/env.sh @@ -1,10 +1,9 @@ -# This file contains an environment to cross-compile packages to the i686 architecture -# The script requires the TOOLCHAIN variable to be set to the toolchain's path +# Usage: `source env.sh` +# `TARGET` is the target triplet for the compiler -# If the target is not specified, set to default -if [ -z $TARGET ]; then - export TARGET=i686-unknown-linux-musl -fi +TOOLCHAIN="$(pwd)/toolchain" + +export PATH="$TOOLCHAIN/usr/bin:$TOOLCHAIN/toolchain/bin:$PATH" export CC="clang" export LD="ld.lld" diff --git a/scripts/build_toolchain.sh b/scripts/build_toolchain.sh deleted file mode 100755 index fe3832b..0000000 --- a/scripts/build_toolchain.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -set -e - -# Prepare -mkdir -p toolchain/{repo,usr/bin} -PATH="$(pwd)/toolchain/usr/bin/:$PATH" -export SYSROOT="$(pwd)/toolchain/" -export LOCAL_REPO="$(pwd)/toolchain/repo/" -# If the target is not specified, set to default -if [ -z $TARGET ]; then - export TARGET=i686-unknown-linux-musl -fi - -# binutils -target/release/blimp-builder "$1/binutils" toolchain/repo/ -target/release/blimp install binutils - -# musl -TOOLCHAIN="toolchain" source scripts/cross_compile_env.sh -HOST="$TARGET" target/release/blimp-builder "$1/musl" toolchain/repo/ -unset CC LD CFLAGS LDFLAGS RUSTFLAGS -target/release/blimp install musl - -# TODO clang \ No newline at end of file