summaryrefslogtreecommitdiff
path: root/.github/dockerfiles/Dockerfile.cross-compile
blob: 75045f2c76bae15d00b09a46397d5091042e5e4e (plain)
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
##
## This docker file will build Erlang on 32-bit to 64-bit x86
##
ARG BASE=docker.pkg.github.com/erlang/otp/i386-debian-base
FROM $BASE as build

ARG MAKEFLAGS=-j4
ENV MAKEFLAGS=$MAKEFLAGS \
        ERLC_USE_SERVER=yes \
        ERL_TOP=/buildroot/bootstrap/otp

WORKDIR /buildroot/bootstrap

ARG ARCHIVE=./otp.tar.gz
COPY $ARCHIVE /buildroot/otp.tar.gz
RUN tar xzf ../otp.tar.gz

## Build the bootstrap system
RUN cd $ERL_TOP && CFLAGS="-Wall -O2 -g" ./configure && make && make install

ENV HOST=$HOST_TRIP \
        CC=$HOST_TRIP-gcc \
        CPPFLAGS="--sysroot=/buildroot/sysroot" \
        CFLAGS="--sysroot=/buildroot/sysroot -O2 -g -Werror" \
        CPP=$HOST_TRIP-cpp \
        CXX=$HOST_TRIP-g++ \
        LD=$CC \
        LD_FLAGS="--sysroot=/buildroot/sysroot" \
        DED_CFLAGS="$CFLAGS" \
        DED_LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic" \
        RANLIB=$HOST_TRIP-ranlib \
        AR=$HOST_TRIP-ar \
        erl_xcomp_sysroot=/buildroot/sysroot \
        ERL_TOP=/buildroot/otp

RUN cd /buildroot && tar xzf otp.tar.gz

WORKDIR /buildroot/otp

## Build the cross system
# We cannot use config.guess for --build since its value clashes with the
# canonical value of host...
RUN ./configure --prefix=/otp/ --host=$HOST --build=x86-pc-linux-gnu && \
    OTP_SMALL_BUILD=true V=1 make && \
    make install

## Build the cross tests
ENV CFLAGS="--sysroot=/buildroot/sysroot -O2 -g"
RUN ./otp_build tests
RUN cd release/tests/test_server && \
        erl -sname test@docker -noshell \
        -eval "ts:install([{cross,\"yes\"},{crossflags,[{\"host\",\"$HOST\"}]},{crossroot,\"/$ERL_TOP\"}])." \
        -s ts compile_testcases -s init stop

FROM debian as install

# Install the released application
COPY --from=build /otp /otp
COPY --from=build /buildroot/otp/release/tests /tests

ENV PATH=/otp/bin:$PATH