-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile
151 lines (104 loc) · 4.44 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
151
FROM ubuntu:18.04 AS generator
RUN apt-get update
RUN apt-get install apt-utils sudo -y
# Create user
RUN useradd --create-home --shell=/bin/bash user
RUN chown -R user /home/user/
# Add the user to sudoers
RUN chmod -R o-w /etc/sudoers.d/
RUN usermod -aG sudo user
# Give the user a password
RUN echo user:user | chpasswd
RUN apt-get install build-essential wget -y
WORKDIR /data
USER user
COPY bootstrap-prefix.sh /data/
RUN PREFIX_DISABLE_RAP=yes STOP_BOOTSTRAP_AFTER=stage1 LATEST_TREE_YES=1 TESTING_PV=latest bash bootstrap-prefix.sh /tmp/gentoo noninteractive
RUN truncate -s 0 /tmp/gentoo/var/db/repos/gentoo/profiles/package.mask
RUN PREFIX_DISABLE_RAP=yes STOP_BOOTSTRAP_AFTER=stage2 LATEST_TREE_YES=1 TESTING_PV=latest bash bootstrap-prefix.sh /tmp/gentoo noninteractive
RUN PREFIX_DISABLE_RAP=yes STOP_BOOTSTRAP_AFTER=stage3 LATEST_TREE_YES=1 TESTING_PV=latest bash bootstrap-prefix.sh /tmp/gentoo noninteractive
RUN PREFIX_DISABLE_RAP=yes LATEST_TREE_YES=1 TESTING_PV=latest bash bootstrap-prefix.sh /tmp/gentoo noninteractive
USER root
ENV DEBIAN_FRONTEND=noninteractive ARCH=x86_64
RUN apt-get install \
cmake \
pkg-config \
tzdata \
python3-pip \
python-dev \
musl-tools \
binutils-dev \
libiberty-dev \
build-essential \
fakeroot \
dpkg-dev \
git \
flex \
autoconf \
google-perftools \
libssl-dev \
gettext \
file \
quilt \
gawk \
debhelper \
rdfind \
symlinks \
netbase \
gperf \
bison \
systemtap-sdt-dev \
libaudit-dev \
libcap-dev \
libselinux-dev \
zlib1g-dev \
libtinfo-dev \
libffi-dev \
po-debconf \
yasm \
rsync \
libltdl7 \
vim \
--yes --no-install-recommends
RUN if [ "${ARCH}" = "x86_64" ] ; then apt-get install g++-7-multilib --yes --no-install-recommends; fi
COPY execute-prefix.sh /data/
# libcxx has a regression which failed to build without -lpthread because newer glibc provides everything in libc.so
RUN sed -i "s=libc_nonshared.a=libc_nonshared.a /lib/${ARCH}-linux-gnu/libpthread.so.0 /usr/lib/${ARCH}-linux-gnu/libpthread_nonshared.a=" /usr/lib/${ARCH}-linux-gnu/libc.so
RUN bash execute-prefix.sh emerge nasm libcxx lldb sys-libs/libunwind llvm-core/clang lld gdb
FROM generator AS glibc
WORKDIR /opt
RUN wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/glibc/2.27-3ubuntu1.6/glibc_2.27-3ubuntu1.6.dsc
RUN wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/glibc/2.27-3ubuntu1.6/glibc_2.27.orig.tar.xz
RUN wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/glibc/2.27-3ubuntu1.6/glibc_2.27-3ubuntu1.6.debian.tar.xz
RUN dpkg-source -x glibc_2.27-3ubuntu1.6.dsc
WORKDIR /opt/glibc-2.27
RUN sed -i "s/if (__glibc_unlikely (__access (preload_file, R_OK) == 0))/if (false)/" elf/rtld.c
RUN DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -b
FROM generator
COPY --from=glibc /opt/libc6_2.27-3ubuntu1.6_*.deb /opt/
RUN dpkg -i /opt/libc6_2.27-3ubuntu1.6_*.deb
RUN wget https://github.com/Kitware/CMake/releases/download/v3.29.0/cmake-3.29.0-linux-${ARCH}.tar.gz -O /opt/cmake-3.29.0-linux-${ARCH}.tar.gz
RUN wget https://github.com/NixOS/patchelf/releases/download/0.14.3/patchelf-0.14.3-${ARCH}.tar.gz -O /opt/patchelf-0.14.3-${ARCH}.tar.gz
RUN if [ "${ARCH}" = "x86_64" ]; then wget https://github.com/apple/foundationdb/releases/download/7.1.59/foundationdb-clients_7.1.59-1_amd64.deb -O /opt/foundationdb-clients_7.1.59-1_amd64.deb && dpkg -i /opt/foundationdb-clients_7.1.59-1_amd64.deb; fi
RUN pip3 install setuptools
RUN wget https://ftp.gnu.org/gnu/bison/bison-3.5.1.tar.gz -O /opt/bison-3.5.1.tar.gz && \
cd /opt && \
tar zxf bison-3.5.1.tar.gz && \
cd bison-3.5.1 && \
env M4=m4 ./configure --prefix /usr --enable-relocatable && \
make && \
make install && \
cd .. && \
rm -rf bison-3.5.1 bison-3.5.1.tar.gz
ENV GCC_VERSION=14 LLVM_VERSION=19
RUN wget https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-$(/tmp/gentoo/usr/lib/llvm/${LLVM_VERSION}/bin/clang --version | head -n 1 | awk '{print $3}')/libcxx/utils/gdb/libcxx/printers.py -O /opt/printers.py
COPY generate_toolchain.sh setup_toolchain.sh disable_ld_preload.c /
RUN mkdir /wrappers
COPY tfg.py flamegraph bison ldb_gperf gcc g++ clang clang++ clangd curl /wrappers/
ADD tfg /wrappers/tfg
RUN mkdir /tests
COPY a.c /tests/
COPY FindThrift.cmake /
ADD glibc-compatibility /glibc-compatibility
WORKDIR /data
ENTRYPOINT [ "/generate_toolchain.sh" ]