Debian Codegraph @

build/unix/build-gcc/build-gcc.sh

raw
1 #!/bin/bash
2
3 set -e
4 set -x
5
6 make_flags="-j$(nproc)"
7
8 apply_patch() {
9 if [ $# -ge 2 ]; then
10 pushd $root_dir/$1
11 shift
12 else
13 pushd $root_dir/gcc-source
14 fi
15 patch -p1 < $1
16 popd
17 }
18
19 build_binutils() {
20 # if binutils_configure_flags is not set at all, give it the default value
21 if [ -z "${binutils_configure_flags+xxx}" ];
22 then
23 # gold is disabled because we don't use it on automation, and also we ran into
24 # some issues with it using this script in build-clang.py.
25 #
26 # --enable-targets builds extra target support in ld.
27 # Enabling aarch64 support brings in arm support, so we don't need to specify that too.
28 #
29 # It is important to have the binutils --target and the gcc --target match,
30 # so binutils will install binaries in a place that gcc will look for them.
31 binutils_configure_flags="--enable-targets=aarch64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu --disable-gold --enable-plugins --disable-nls --with-sysroot=/"
32 fi
33
34 mkdir $root_dir/binutils-objdir
35 pushd $root_dir/binutils-objdir
36 ../binutils-source/configure --prefix=${prefix-/tools/gcc}/ $binutils_configure_flags
37 make $make_flags
38 make install $make_flags DESTDIR=$root_dir
39 export PATH=$root_dir/${prefix-/tools/gcc}/bin:$PATH
40 popd
41 }
42
43 build_gcc() {
44 # Be explicit about --build and --target so header and library install
45 # directories are consistent.
46 local target="${1:-x86_64-unknown-linux-gnu}"
47
48 mkdir $root_dir/gcc-objdir
49 pushd $root_dir/gcc-objdir
50
51 if [ -d $MOZ_FETCHES_DIR/sysroot ]; then
52 EXTRA_CONFIGURE_FLAGS="--with-build-sysroot=$MOZ_FETCHES_DIR/sysroot"
53 export CFLAGS_FOR_BUILD="--sysroot=$MOZ_FETCHES_DIR/sysroot"
54 fi
55 ../gcc-source/configure --prefix=${prefix-/tools/gcc} --build=x86_64-unknown-linux-gnu --target="${target}" --enable-languages=c,c++ --disable-nls --disable-gnu-unique-object --enable-__cxa_atexit --with-arch-32=pentiumpro --with-sysroot=/ $EXTRA_CONFIGURE_FLAGS
56 make $make_flags
57 make $make_flags install-strip DESTDIR=$root_dir
58
59 cd $root_dir/tools
60 ln -s gcc gcc/bin/cc
61
62 tar caf $root_dir/gcc.tar.zst gcc/
63 popd
64 }