Skip to content

Commit

Permalink
Switch to crosstool-ng
Browse files Browse the repository at this point in the history
Fixes #2.
  • Loading branch information
ali1234 committed Oct 13, 2019
1 parent b57db8d commit ffa4609
Show file tree
Hide file tree
Showing 11 changed files with 1,335 additions and 227 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.idea
/.config
/.config.old
/build
/result
/build.log
/crosstool-ng*
/*.tar.xz
/*.tar.xz.asc
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/_build
/.idea
/.config
/.config.old
/build
/result
/build.log
/crosstool-ng*
/*.tar.xz
/*.tar.xz.asc
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:eoan

ARG CTVER=1.24.0
ARG UID=1000
ARG GID=1000
ARG USER=toolchain
ARG GROUP=toolchain

RUN apt-get update
RUN apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
python3-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
patch libstdc++6 rsync wget git

RUN wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-$CTVER.tar.xz && \
tar xf crosstool-ng-$CTVER.tar.xz && \
cd crosstool-ng-$CTVER && \
./configure && \
make && make install

RUN groupadd -g $GID $GROUP
RUN useradd -ms /bin/bash -u $UID -g $GID $USER

USER $USER
RUN mkdir -p /home/$USER/rpi-toolchain
WORKDIR /home/$USER/rpi-toolchain
COPY --chown=toolchain:toolchain . .
RUN make

57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
TARGET:=arm-linux-gnueabihf
VERSION:=$(shell git describe --always --dirty)
NAME:=raspbian-$(VERSION)
TOOLCHAIN:=toolchain-$(NAME)-x86_64-$(TARGET)
SRC:=src-$(NAME)
URL:=https://github.com/ali1234/rpi-toolchain/issues/new?body=Version:%20$(VERSION)

export DEB_TARGET_MULTIARCH=$(TARGET)

all: $(TOOLCHAIN).tar.xz.asc $(SRC).tar.xz.asc

%.tar.xz.asc: %.tar.xz
sha256sum $< > $@

.config: ct-ng-config
sed -E -e 's|^(CT_TOOLCHAIN_PKGVERSION)=.*|\1=\"$(NAME)\"|' \
-e 's|^(CT_TOOLCHAIN_BUGURL)=.*|\1=\"$(NAME)\"|' ct-ng-config > .config

result/success: .config
ct-ng build && touch result/success

$(TOOLCHAIN).tar.xz: result/success
rm -rf --one-file-system result/$(TOOLCHAIN)
mkdir result/$(TOOLCHAIN)
rsync -av result/$(TARGET)/* result/$(TOOLCHAIN)
ct-ng --version > result/$(TOOLCHAIN)/ct-ng-version
cp .config result/$(TOOLCHAIN)/ct-ng-config
tar Jcf $(TOOLCHAIN).tar.xz --directory result $(TOOLCHAIN)

$(SRC).tar.xz: result/success
ct-ng --version > src/ct-ng-version
cp .config src/ct-ng-config
tar Jcf $(SRC).tar.xz src

saveconfig:
sed -E -e 's|^(CT_TOOLCHAIN_PKGVERSION)=.*|\1=\"\"|' \
-e 's|^(CT_TOOLCHAIN_BUGURL)=.*|\1=\"\"|' .config > ct-ng-config

menuconfig: .config
ct-ng menuconfig

clean:
rm -rf build result build.log .config .config.old
rm -rf $(TOOLCHAIN).tar.xz $(TOOLCHAIN).tar.xz.asc $(SRC).tar.xz $(SRC).tar.xz.asc

reallyclean: clean
rm -rf *.tar.xz *.tar.xz.asc

indocker:
docker build -t rpi-toolchain .
docker create -ti --name rpi-toolchain-tmp rpi-toolchain
docker cp rpi-toolchain-tmp:/home/toolchain/rpi-toolchain/$(TOOLCHAIN).tar.xz .
docker cp rpi-toolchain-tmp:/home/toolchain/rpi-toolchain/$(TOOLCHAIN).tar.xz.asc .
docker cp rpi-toolchain-tmp:/home/toolchain/rpi-toolchain/$(SRC).tar.xz .
docker cp rpi-toolchain-tmp:/home/toolchain/rpi-toolchain/$(SRC).tar.xz.asc .
docker cp rpi-toolchain-tmp:/home/toolchain/rpi-toolchain/build.log .
docker rm -f rpi-toolchain-tmp
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@

A gcc cross toolchain for all Raspberry Pi models with multiarch support.

Linaro toolchains are built using a tool called ABE. This is similar to
crosstool-ng. After building it produces a manifest which can be used to
reproduce the build.
This toolchain is built with crosstool-ng. It includes the Debian specific
patch for multiarch support in binutils.

This toolchain is built by taking the Linaro release manifest and modifying
the compiler configuration to produce armv6 compatible binaries which can
run on all models of Raspberry Pi.
To build it, clone the repository and run `make` or `make indocker` to
run the build inside Docker. Check the Dockerfile to see the dependencies
for a local build. To build from the release source, untar them inside
the `src` directory.

The changes required for this are very small. In the manifest, only the
variables `gcc_stage1_flags` and `gcc_stage2_flags` are modified.

The flags:

--with-fpu=vfpv3-d16 --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a

are replaced by:

--with-fpu=vfp --with-arch=armv6
1 change: 0 additions & 1 deletion abe
Submodule abe deleted from bb166f
12 changes: 0 additions & 12 deletions build.sh

This file was deleted.

Loading

0 comments on commit ffa4609

Please sign in to comment.