-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
150 lines (141 loc) · 3.71 KB
/
Dockerfile
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
ARG TARGET=x86_64-hermit
ARG PREFIX=/opt/hermit
FROM --platform=$BUILDPLATFORM rust:bookworm AS kernel
ADD --link https://github.com/hermit-os/kernel.git /kernel
WORKDIR /kernel
RUN cargo xtask build \
--artifact-dir . \
--arch x86_64 \
--release \
--no-default-features \
--features pci,smp,acpi,newlib,tcp,dhcpv4
FROM buildpack-deps:bookworm AS binutils
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
flex \
texinfo \
; \
rm -rf /var/lib/apt/lists/*;
ADD --link https://github.com/hermit-os/binutils.git /binutils
WORKDIR /binutils
ENV CFLAGS="-w" \
CXXFLAGS="-w"
ARG TARGET
ARG PREFIX
RUN set -eux; \
./configure \
--target=$TARGET \
--prefix=$PREFIX \
--with-sysroot \
--disable-werror \
--disable-multilib \
--disable-shared \
--disable-nls \
--disable-gdb \
--disable-libdecnumber \
--disable-readline \
--disable-sim \
--enable-tls \
--enable-lto \
--enable-plugin; \
make -O -j$(nproc); \
make install; \
make clean
FROM buildpack-deps:bookworm AS gcc
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
flex \
libgmp-dev \
libisl-dev \
libmpc-dev \
libmpfr-dev \
texinfo \
; \
rm -rf /var/lib/apt/lists/*;
ARG TARGET
ARG PREFIX
COPY --link --from=binutils $PREFIX $PREFIX
ENV CFLAGS="-w" \
CXXFLAGS="-w" \
CFLAGS_FOR_TARGET="-fPIE -pie" \
GOFLAGS_FOR_TARGET="-fPIE -pie" \
FCFLAGS_FOR_TARGET="-fPIE -pie" \
FFLAGS_FOR_TARGET="-fPIE -pie" \
CXXFLAGS_FOR_TARGET="-fPIE -pie"
ADD --link https://github.com/hermit-os/gcc.git /gcc
WORKDIR /gcc/builddir-bootstrap
RUN set -eux; \
../configure \
--target=$TARGET \
--prefix=$PREFIX \
--without-headers \
--disable-multilib \
--with-isl \
--enable-languages=c,c++,lto \
--disable-nls \
--disable-shared \
--disable-libssp \
--disable-libgomp \
--enable-threads=posix \
--enable-tls \
--enable-lto \
--disable-symvers; \
make -O -j$(nproc) all-gcc; \
make install-gcc; \
make clean
ENV PATH=$PREFIX/bin:$PATH
COPY --link --from=kernel /kernel/libhermit.a /kernel/libhermit.a
ENV LDFLAGS_FOR_TARGET="-L/kernel -lhermit"
ADD --link https://github.com/hermit-os/newlib.git /newlib
WORKDIR /newlib
RUN set -eux; \
./configure \
--target=$TARGET \
--prefix=$PREFIX \
--disable-shared \
--disable-multilib \
--enable-lto \
--enable-newlib-io-c99-formats \
--enable-newlib-multithread; \
make -O -j$(nproc); \
make install; \
make clean
ADD --link https://github.com/hermit-os/pthread-embedded.git /pthread-embedded
WORKDIR /pthread-embedded
RUN set -eux; \
./configure \
--target=$TARGET \
--prefix=$PREFIX; \
make -O -j$(nproc); \
make install; \
make clean
WORKDIR /gcc/builddir
RUN set -eux; \
../configure \
--target=$TARGET \
--prefix=$PREFIX \
--with-newlib \
--with-isl \
--disable-multilib \
--without-libatomic \
--enable-languages=c,c++,fortran,lto \
--disable-nls \
--disable-shared \
--enable-libssp \
--enable-threads=posix \
--enable-libgomp \
--enable-tls \
--enable-lto \
--disable-symver; \
make -O -j$(nproc); \
make install; \
make clean
FROM rust:bookworm AS toolchain
ARG PREFIX
COPY --from=gcc $PREFIX $PREFIX
ENV PATH=$PREFIX/bin:$PATH \
LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH