Open7
DockerでGCCのソースコードをビルドする
GCCのバージョンはスクラップの作成日時点(2024/02/23)での最新のバージョンの13.2.0を採用する。
Dockerfile
FROM ubuntu:24.04
ENV TZ=Asia/Tokyo
ENV VERSION=13.2.0
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone && \
sed -i 's@archive.ubuntu.com@ftp.jaist.ac.jp/pub/Linux@g' /etc/apt/sources.list && \
echo "bind 'set bell-style none'" >> .bashrc && \
apt-get update && \
apt-get install --no-install-recommends -y build-essential wget libmpc-dev gcc-multilib flex bison cloc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
wget -q --no-check-certificate https://github.com/gcc-mirror/gcc/archive/refs/tags/releases/gcc-${VERSION}.tar.gz && \
tar xf gcc-${VERSION}.tar.gz
WORKDIR /gcc-releases-gcc-${VERSION}
RUN ./configure && make -j$(nproc)
$ docker --version
Docker version 24.0.5, build ced0996
$ uname -a
Linux MyComputer 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
コンテナのビルド
$ docker build -t gcc .
[+] Building 3875.0s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 1.8s
=> => transferring dockerfile: 734B 0.2s
=> [internal] load .dockerignore 1.0s
=> => transferring context: 2B 0.1s
=> [internal] load metadata for docker.io/library/ubuntu:24.04 0.0s
=> CACHED [1/4] FROM docker.io/library/ubuntu:24.04 0.0s
=> [2/4] RUN ln -snf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && echo Asia/Tok 487.2s
=> [3/4] WORKDIR /gcc-releases-gcc-13.2.0 1.6s
=> [4/4] RUN ./configure && make -j$(nproc) 3288.8s
=> exporting to image 93.6s
=> => exporting layers 93.4s
=> => writing image sha256:7206a0090e6993533a2a2bed3f376bd999f2fd4e832f874197c026d0aa 0.1s
=> => naming to docker.io/library/gcc 0.2s
What's Next?
View summary of image vulnerabilities and recommendations → docker scout quickview
$ docker run -it --rm --name gcc_container gcc bash
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# gcc --version
gcc (Ubuntu 13.2.0-13ubuntu1) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# which gcc
/usr/bin/gcc
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# ls
ABOUT-NLS contrib libstdc++-v3
COPYING depcomp libtool-ldflags
COPYING.LIB fixincludes libtool.m4
COPYING.RUNTIME gcc libvtv
COPYING3 gnattools ltgcc.m4
COPYING3.LIB gotools ltmain.sh
ChangeLog host-x86_64-pc-linux-gnu lto-plugin
ChangeLog.jit include ltoptions.m4
ChangeLog.tree-ssa install-sh ltsugar.m4
INSTALL intl ltversion.m4
MAINTAINERS libada lt~obsolete.m4
Makefile libatomic maintainer-scripts
Makefile.def libbacktrace missing
Makefile.in libcc1 mkdep
Makefile.tpl libcody mkinstalldirs
README libcpp move-if-change
ar-lib libdecnumber multilib.am
build-x86_64-pc-linux-gnu libffi prev-x86_64-pc-linux-gnu
c++tools libgcc serdep.tmp
compare libgfortran stage1-x86_64-pc-linux-gnu
compile libgm2 stage_current
config libgo stage_final
config-ml.in libgomp stage_last
config.guess libiberty symlink-tree
config.log libitm test-driver
config.rpath libobjc x86_64-pc-linux-gnu
config.status libphobos ylwrap
config.sub libquadmath zlib
configure libsanitizer
configure.ac libssp
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# ls host-x86_64-pc-linux-gnu/
c++tools libcpp prev-libbacktrace stage1-fixincludes stage1-libiberty
fixincludes libdecnumber prev-libcody stage1-gcc stage1-lto-plugin
gcc libiberty prev-libcpp stage1-intl stage1-zlib
intl lto-plugin prev-libdecnumber stage1-libbacktrace zlib
libbacktrace prev-fixincludes prev-libiberty stage1-libcody
libcc1 prev-gcc prev-lto-plugin stage1-libcpp
libcody prev-intl prev-zlib stage1-libdecnumber
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# host-x86_64-pc-linux-gnu/gcc/xgcc --version
xgcc (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0#
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# make install
...
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/gcc-releases-gcc-13.2.0/x86_64-pc-linux-gnu/libatomic'
make[3]: Leaving directory '/gcc-releases-gcc-13.2.0/x86_64-pc-linux-gnu/libatomic'
make[2]: Leaving directory '/gcc-releases-gcc-13.2.0/x86_64-pc-linux-gnu/libatomic'
make[1]: Leaving directory '/gcc-releases-gcc-13.2.0'
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# ls /usr/local/bin/
c++ gcc-ar gcov-dump x86_64-pc-linux-gnu-c++ x86_64-pc-linux-gnu-gcc-ar
cpp gcc-nm gcov-tool x86_64-pc-linux-gnu-g++ x86_64-pc-linux-gnu-gcc-nm
g++ gcc-ranlib gfortran x86_64-pc-linux-gnu-gcc x86_64-pc-linux-gnu-gcc-ranlib
gcc gcov lto-dump x86_64-pc-linux-gnu-gcc-13.2.0 x86_64-pc-linux-gnu-gfortran
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0#
ソースコードの行数は約1105万行
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# make distclean
...
root@fa6aed982a5e:/gcc-releases-gcc-13.2.0# cloc .
123713 text files.
117245 unique files.
6876 files ignored.
6 errors:
Line count, exceeded timeout: ./libgo/go/golang.org/x/net/idna/tables10.0.0.go
Line count, exceeded timeout: ./libgo/go/golang.org/x/net/idna/tables11.0.0.go
Line count, exceeded timeout: ./libgo/go/golang.org/x/net/idna/tables12.0.0.go
Line count, exceeded timeout: ./libgo/go/golang.org/x/net/idna/tables13.0.0.go
Line count, exceeded timeout: ./libgo/go/golang.org/x/net/idna/tables9.0.0.go
Line count, exceeded timeout: ./libgo/go/net/http/requestwrite_test.go
github.com/AlDanial/cloc v 1.98 T=151.86 s (772.1 files/s, 107749.3 lines/s)
---------------------------------------------------------------------------------------
Language files blank comment code
---------------------------------------------------------------------------------------
C++ 31143 610405 701098 2959324
C 50773 410175 635758 2033424
PO File 44 332336 443572 916826
Ada 6610 290082 396614 831278
Go 5347 102068 191016 769730
C/C++ Header 4359 169919 211421 767247
D 4789 117532 162097 669363
Text 997 12691 0 462197
Markdown 459 52607 0 458635
Bourne Shell 180 78864 65474 428914
Fortran 90 7403 39714 70392 213607
Windows Module Definition 597 22431 424 88155
m4 221 8901 2849 79304
Assembly 621 13403 33395 64778
XML 94 6327 551 61255
Expect 515 9534 18267 37341
reStructuredText 69 17704 13411 29976
HTML 114 521 29 28091
SVG 48 0 126 20414
Objective-C 543 5050 3352 17391
make 149 2810 1849 16312
Logos 196 2673 993 15671
Fortran 77 559 1661 6245 14075
Python 58 2770 3645 11429
Rust 743 2330 1009 10573
Objective-C++ 276 2623 1844 8924
TeX 4 915 3609 7912
Pascal 30 1784 11562 5879
awk 23 647 773 4787
MSBuild script 7 1 0 4675
Fortran 95 122 1219 3437 3368
Perl 24 670 1010 3235
CSV 9 0 0 3191
Bourne Again Shell 18 433 707 1990
C# 9 230 506 879
Visual Studio Solution 6 5 5 645
JSON 11 0 0 493
yacc 1 56 40 338
CMake 3 59 44 310
PHP 2 71 0 309
OCaml 1 44 29 285
Standard ML 1 34 28 215
vim script 4 50 71 193
SQL 1 61 0 182
lex 1 34 30 157
Linker Script 1 28 32 132
Haskell 38 17 0 122
NAnt script 2 17 0 100
Windows Resource File 4 6 3 98
MATLAB 3 13 0 46
SWIG 7 8 10 35
SAS 1 14 22 32
Brainfuck 1 3 4 10
Lisp 1 4 12 7
DOS Batch 2 0 0 4
CSS 1 0 0 1
---------------------------------------------------------------------------------------
SUM: 117245 2321554 2987365 11053864
---------------------------------------------------------------------------------------