1 # Build script for binutils.
3 # Copyright (c) 2014-2022 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 rm -rf binutils-${version}
21 unpack "${worktree}/sources/binutils-${version}.tar.lz"
24 cd binutils-${version}
26 # Apply patches from Fedora (Nick Clifton)
28 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-2.25-version.patch"
29 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-export-demangle.h.patch"
30 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-2.22.52.0.4-no-config-h-check.patch"
31 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-2.29-filename-in-error-messages.patch"
32 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-2.29-revert-PLT-elision.patch"
33 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-readelf-other-sym-info.patch"
34 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-2.27-aarch64-ifunc.patch"
35 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-do-not-link-with-static-libstdc++.patch"
36 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-attach-to-group.patch"
37 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-special-sections-in-groups.patch"
38 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-fix-testsuite-failures.patch"
39 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gold-mismatched-section-flags.patch"
40 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-CVE-2019-1010204.patch"
41 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gold-warn-unsupported.patch"
42 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-s390-build.patch"
43 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-config.patch"
44 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-warnings.patch"
45 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gcc-10-fixes.patch"
46 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-add-sym-cache-to-elf-link-hash.patch"
47 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-elf-add-objects.patch"
48 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-aarch64-condbranch-relocs.patch"
49 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-ppc-annobin-disassembly.patch"
50 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-strip-merge.patch"
51 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-plugin-as-needed.patch"
52 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-recursive-debuglink-following.patch"
53 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-SHF_LINK_ORDER.patch"
54 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-duplicate-sections.patch"
55 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-use-long-long.patch"
56 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gold-gnu-properties.patch"
57 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-testsuite-failures.patch"
58 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-CVE-2021-20197.patch"
59 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-ld-DWARF-5-sections.patch"
60 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-s390-arch14-insns.patch"
61 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-ppc64le-note-merge.patch"
62 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-readelf-no-warn-gaps.patch"
63 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-unexpected-form-20.patch"
64 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-CVE-2021-20284.patch"
65 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-extend-s390-arch14-support.patch"
66 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-CVE-2021-3487.patch"
67 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-CVE-2020-35448.patch"
68 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-dwarf-5-dir0.patch"
69 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gas-Use-the-directory-name-in-.file-0.patch"
70 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils.unicode.patch"
71 patch -Np1 -i "${worktree}/patches/binutils/2.35/binutils-gas-multibyte-warnings.patch"
73 patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"
75 # Build in a separate directory
76 rm -rf ../binutils-build
77 mkdir ../binutils-build
80 # Import and export toolchain variables
81 . "${worktree}/stages/env.d/cross-staticenv"
83 ../binutils-${version}/configure \
84 AR="$AR" AS="$AS" LD="$LD" RANLIB="$RANLIB" READELF="$READELF" STRIP="$STRIP" \
85 CC="$BTCC" CXX="$BTCXX" \
86 CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
88 --libdir=/tools/lib${libSuffix} \
92 --enable-deterministic-archives \
94 --enable-threads=auto \
95 --enable-default-hash-style=gnu \
97 --enable-install-libiberty \
98 --disable-compressed-debug-sections \
101 --disable-ppl-version-check \
102 --disable-cloog-version-check \
103 --with-lib-path=/tools/lib \
107 make -j${jobs} MAKEINFO="true"
108 make -j${jobs} MAKEINFO="true" install
110 # Make a new ld(1) containing another search path,
111 # this is handled by "20-toolchain" (called from musl's recipe)
113 make -C ld LIB_PATH=/usr/lib${libSuffix}:/lib
114 cp -f ld/ld-new /tools/bin
116 # Unset some imported variables from file
117 unset AR AS LD RANLIB READELF STRIP
123 rm -rf binutils-${version} binutils-build