Alpine-GCC13

Alpine-GCC13

 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
ARG ALPINE_VERSION=latest

FROM alpine:${ALPINE_VERSION} as alpine

ARG GCC_VERSION
ENV GCC_VERSION=${GCC_VERSION}


FROM alpine as builder

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories  \
    && apk update  \
    && apk add --no-cache \
            build-base \
            dejagnu \
            isl-dev \
            make \
            mpc1-dev \
            mpfr-dev \
            texinfo \
            zlib-dev
RUN wget -q https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz && \
    tar -xzf gcc-${GCC_VERSION}.tar.gz && \
    rm -f gcc-${GCC_VERSION}.tar.gz

WORKDIR /gcc-${GCC_VERSION}

RUN ./configure \
        --prefix=/usr/local \
        --build=$(uname -m)-alpine-linux-musl \
        --host=$(uname -m)-alpine-linux-musl \
        --target=$(uname -m)-alpine-linux-musl \
        --with-pkgversion="Alpine ${GCC_VERSION}" \
        --enable-checking=release \
        --disable-fixed-point \
        --disable-libmpx \
        --disable-libmudflap \
        --disable-libsanitizer \
        --disable-libssp \
        --disable-libstdcxx-pch \
        --disable-multilib \
        --disable-nls \
        --disable-symvers \
        --disable-werror \
        --enable-__cxa_atexit \
        --enable-default-pie \
        --enable-languages=c,c++ \
        --enable-shared \
        --enable-threads \
        --enable-tls \
        --with-linker-hash-style=gnu \
        --with-system-zlib
RUN make -j $(nproc)
RUN make -j $(nproc) install-strip

RUN ln -s /usr/bin/gcc /usr/local/bin/cc

RUN gcc -v


FROM alpine

RUN apk add --no-cache \
            autoconf \
            automake \
            binutils \
            cmake \
            file \
            git \
            gmp \
            isl \
            libc-dev \
            libtool \
            make \
            mpc1 \
            mpfr4 \
            musl-dev \
            pkgconf \
            zlib-dev

COPY --from=builder /usr/local/ /usr/

WORKDIR /src
1
docker build --build-arg GCC_VERSION=13.1.0 -t alpine-gcc .
updatedupdated2025-09-302025-09-30