forked from tttapa/toolchains
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
126 lines (100 loc) · 4.41 KB
/
Copy pathDockerfile
File metadata and controls
126 lines (100 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Python config ----------------------------------------------------------------
FROM python:3 AS config
ARG HOST_TRIPLE
ARG GCC_VERSION
COPY *.py .
RUN mkdir /config-${HOST_TRIPLE}
RUN python3 gen-cmake-toolchain.py ${HOST_TRIPLE} /config-${HOST_TRIPLE}/${HOST_TRIPLE}.toolchain.cmake
RUN python3 gen-conan-profile.py ${HOST_TRIPLE} ${GCC_VERSION} /config-${HOST_TRIPLE}/${HOST_TRIPLE}.profile.conan
# Crosstool-NG -----------------------------------------------------------------
FROM --platform=$BUILDPLATFORM debian:bullseye AS ct-ng
# Install dependencies to build crosstool-ng and the toolchain
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
autoconf automake libtool-bin make texinfo help2man \
sudo file gawk patch \
python3 \
g++ bison flex gperf \
libncurses5-dev \
perl libthread-queue-perl \
ca-certificates wget git \
bzip2 xz-utils unzip rsync && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Add a user called `develop` and add them to the sudo group
RUN useradd -m develop && echo "develop:develop" | chpasswd && \
usermod -aG sudo develop
USER develop
WORKDIR /home/develop
# Install autoconf
RUN wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz -O- | tar xz && \
cd autoconf-2.72 && \
./configure --prefix=/home/develop/.local && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf autoconf-2.72
ENV PATH=/home/develop/.local/bin:${PATH}
# Build crosstool-ng
RUN git clone -b master --single-branch \
https://github.com/crosstool-ng/crosstool-ng.git && \
cd crosstool-ng && \
git fetch origin refs/pull/2502/head:pr/2502 && \
git checkout 43780e61fc95677d2fa7d042f32f889da064c6a3 && \
git show --summary && \
./bootstrap && \
mkdir build && cd build && \
../configure --prefix=/home/develop/.local && \
make -j$(($(nproc) * 2)) && \
make install && \
cd /home/develop && rm -rf crosstool-ng
# Patches
# https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=280707&p=1700861#p1700861
# See https://packages.debian.org/sid/binutils for an up-to-date download URL
RUN wget https://ftp.debian.org/debian/pool/main/b/binutils/binutils_2.46-3.debian.tar.xz -O- | \
tar xJ debian/patches/129_multiarch_libpath.patch && \
mkdir -p patches/binutils/2.46.0 && \
mv debian/patches/129_multiarch_libpath.patch patches/binutils/2.46.0 && \
rm -rf debian
# Toolchain --------------------------------------------------------------------
FROM --platform=$BUILDPLATFORM ct-ng AS gcc-build
ARG HOST_TRIPLE
ARG GCC_VERSION
ARG PKG_VERSION
# Build the toolchain
COPY --chown=develop:develop ${HOST_TRIPLE}.defconfig .
COPY --chown=develop:develop ${HOST_TRIPLE}.env .
RUN [ -n "${GCC_VERSION}" ] && { echo "CT_GCC_V_${GCC_VERSION}=y" >> ${HOST_TRIPLE}.defconfig; }
RUN [ -n "${PKG_VERSION}" ] && { echo "CT_TOOLCHAIN_PKGVERSION=\"tttapa/toolchains@${PKG_VERSION}\"" >> ${HOST_TRIPLE}.defconfig; }
RUN cp ${HOST_TRIPLE}.defconfig defconfig && ct-ng defconfig
RUN . ./${HOST_TRIPLE}.env && \
ct-ng build || { cat build.log && false; } && rm -rf .build
RUN chmod +w /home/develop/x-tools/${HOST_TRIPLE}
COPY --chown=develop:develop --from=config /config-${HOST_TRIPLE}/* /home/develop/x-tools
RUN chmod -w /home/develop/x-tools/${HOST_TRIPLE}
# Build container (base) -------------------------------------------------------
FROM debian:trixie AS gcc-dev-base
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update -y && \
apt-get install --no-install-recommends -y \
ninja-build cmake make bison flex \
tar xz-utils gzip zip unzip bzip2 zstd \
ca-certificates wget git sudo file && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Add a user called `develop` and add them to the sudo group
RUN useradd -m develop && echo "develop:develop" | chpasswd && \
usermod -aG sudo develop
USER develop
WORKDIR /home/develop
# Build container --------------------------------------------------------------
FROM gcc-dev-base AS gcc-dev
ARG HOST_TRIPLE
ENV TOOLCHAIN_PATH=/home/develop/opt/x-tools/${HOST_TRIPLE}
ENV PATH=${TOOLCHAIN_PATH}/bin:${PATH}
# Copy the toolchain
COPY --chown=develop:develop --from=gcc-build /home/develop/x-tools /home/develop/opt/x-tools
RUN ${HOST_TRIPLE}-g++ --version