Skip to content

Commit 4f02679

Browse files
RX14Brian J. Cardiff
authored andcommitted
Update linux LLVM to 8, and don't build crystal twice (#44)
1 parent 7d45d71 commit 4f02679

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

linux/Dockerfile

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@ ARG alpine_image
22
ARG debian_image
33
FROM ${debian_image} AS debian
44

5-
RUN apt-get update \
6-
&& apt-get install -y build-essential libevent-core-2.0-5 libevent-dev libevent-extra-2.0-5 libevent-openssl-2.0-5 libevent-pthreads-2.0-5 libpcre3-dev automake libtool pkg-config git software-properties-common apt-transport-https curl \
7-
&& (pkg-config || true)
8-
9-
RUN add-apt-repository "deb http://apt.llvm.org/jessie/ llvm-toolchain-jessie-4.0 main" \
10-
&& curl -sSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
5+
RUN echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list \
116
&& apt-get update \
12-
&& apt-get install -y llvm-4.0-dev
13-
14-
ARG previous_crystal_release
15-
ADD ${previous_crystal_release} /tmp/crystal.tar.gz
16-
ENV PATH=${PATH}:/tmp/crystal/bin
17-
RUN mkdir -p /tmp/crystal \
18-
&& tar xz -f /tmp/crystal.tar.gz -C /tmp/crystal --strip-component=1 \
19-
&& crystal --version
7+
&& apt-get install -y -t buster-backports build-essential libevent-dev libpcre3-dev automake libtool pkg-config git curl llvm-8 \
8+
&& (pkg-config || true)
209

2110
ARG release
2211
ENV CFLAGS="-fPIC -pipe ${release:+-O2}"
@@ -44,19 +33,18 @@ RUN git clone https://github.com/crystal-lang/crystal \
4433
&& cd crystal \
4534
&& git checkout ${crystal_sha1} \
4635
\
47-
&& make deps \
48-
\
49-
&& bin/crystal build src/compiler/crystal.cr -D without_openssl -D without_zlib \
50-
--cross-compile --target ${musl_target} -o /crystal-musl
36+
&& make deps
5137

5238
FROM ${alpine_image}
5339

40+
RUN sed -i 's|--list -- "$@"|--list "$@"|' /usr/bin/ldd
41+
5442
# Install dependencies
5543
RUN apk add --no-cache \
5644
# Statically-compiled llvm
57-
llvm4-dev llvm4-static \
58-
# Static zlib, libyaml, pcre, and libevent
59-
zlib-dev yaml-dev pcre-dev libevent-dev \
45+
llvm8-dev llvm8-static \
46+
# Static zlib, libyaml, libxml2, pcre, and libevent
47+
zlib-dev yaml-dev libxml2-dev pcre-dev libevent-static \
6048
# Build tools
6149
git gcc g++ make automake libtool autoconf bash coreutils
6250

@@ -77,23 +65,23 @@ RUN git clone https://github.com/ivmai/bdwgc \
7765
&& make -j$(nproc) CFLAGS=-DNO_GETCONTEXT
7866

7967
ENV LIBRARY_PATH=/bdwgc/.libs/
80-
ENV PATH=/usr/lib/llvm4/bin:$PATH
8168
RUN llvm-config --version
8269

70+
ARG previous_crystal_release
71+
ADD ${previous_crystal_release} /tmp/crystal.tar.gz
72+
ENV PATH=${PATH}:/tmp/crystal/lib/crystal/bin/
73+
RUN mkdir -p /tmp/crystal \
74+
&& tar xz -f /tmp/crystal.tar.gz -C /tmp/crystal --strip-component=1 \
75+
&& crystal --version
76+
8377
# Build crystal
84-
COPY --from=debian /crystal-musl.o /
8578
ARG crystal_version
8679
ARG crystal_sha1
8780
ARG gnu_target
8881
RUN git clone https://github.com/crystal-lang/crystal \
8982
&& cd crystal \
9083
&& git checkout ${crystal_sha1} \
9184
\
92-
&& make deps \
93-
&& mkdir -p .build/crystal-musl \
94-
&& cc '/crystal-musl.o' -o '.build/crystal-musl/crystal' -rdynamic src/llvm/ext/llvm_ext.o `llvm-config --libs --system-libs --ldflags` -lstdc++ -lpcre -lm -lgc -lpthread src/ext/libcrystal.a -levent -lrt \
95-
&& export PATH=.build/crystal-musl/:$PATH \
96-
\
9785
&& make crystal stats=true static=true ${release:+release=true} \
9886
CRYSTAL_CONFIG_TARGET=${gnu_target} \
9987
&& ([ "$(ldd .build/crystal | wc -l)" -eq "1" ] || { echo './build/crystal is not statically linked'; ldd .build/crystal; exit 1; })

linux/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ BUILD_ARGS_COMMON = $(DOCKER_BUILD_ARGS) \
4747

4848
BUILD_ARGS64 = $(BUILD_ARGS_COMMON) \
4949
--build-arg previous_crystal_release=$(PREVIOUS_CRYSTAL_RELEASE_LINUX64_TARGZ) \
50-
--build-arg debian_image=debian:8 \
51-
--build-arg alpine_image=alpine:3.8 \
50+
--build-arg debian_image=debian:10 \
51+
--build-arg alpine_image=alpine:3.10 \
5252
--build-arg musl_target=x86_64-linux-musl \
5353
--build-arg gnu_target=x86_64-unknown-linux-gnu
5454

5555
BUILD_ARGS32 = $(BUILD_ARGS_COMMON) \
5656
--build-arg previous_crystal_release=$(PREVIOUS_CRYSTAL_RELEASE_LINUX32_TARGZ) \
57-
--build-arg debian_image=i386/debian:8 \
58-
--build-arg alpine_image=i386/alpine:3.8 \
57+
--build-arg debian_image=i386/debian:10 \
58+
--build-arg alpine_image=i386/alpine:3.10 \
5959
--build-arg musl_target=i686-linux-musl \
6060
--build-arg gnu_target=i686-unknown-linux-gnu
6161

0 commit comments

Comments
 (0)