05-binutils 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Build script for binutils.
  2. #
  3. # Copyright (c) 2014-2022 Matias Fonzo, <selk@dragora.org>.
  4. #
  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
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  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.
  16. version=2.38
  17. cd -- "$TMPDIR"
  18. rm -rf binutils-${version}
  19. unpack "${worktree}/sources/binutils-${version}.tar.lz"
  20. # Build instructions
  21. cd binutils-${version}
  22. # Apply patches from Fedora (Nick Clifton)
  23. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-export-demangle.h.patch"
  24. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-no-config-h-check.patch"
  25. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-filename-in-error-messages.patch"
  26. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-revert-PLT-elision.patch"
  27. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-readelf-other-sym-info.patch"
  28. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-2.27-aarch64-ifunc.patch"
  29. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-link-with-static-libstdc++.patch"
  30. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-special-sections-in-groups.patch"
  31. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-mismatched-section-flags.patch"
  32. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-CVE-2019-1010204.patch"
  33. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-warn-unsupported.patch"
  34. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-use-long-long.patch"
  35. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-i386-gnu-property-notes.patch"
  36. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-autoconf-version.patch"
  37. patch -Np1 -i "${worktree}/patches/binutils/2.38/gcc12-libtool-no-rpath.patch"
  38. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-section-type.patch"
  39. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gas-loc-view.patch"
  40. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-use-debuginfod.patch"
  41. patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"
  42. # Build in a separate directory
  43. rm -rf ../binutils-build
  44. mkdir ../binutils-build
  45. cd ../binutils-build
  46. # Import and export toolchain variables
  47. . "${worktree}/stages/env.d/cross-staticenv"
  48. ../binutils-${version}/configure \
  49. AR="$AR" AS="$AS" LD="$LD" RANLIB="$RANLIB" READELF="$READELF" STRIP="$STRIP" \
  50. CC="$BTCC" CXX="$BTCXX" \
  51. CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
  52. --prefix=/tools \
  53. --libdir=/tools/lib${libSuffix} \
  54. --build=$host \
  55. --host=$target \
  56. --target=$target \
  57. --enable-deterministic-archives \
  58. --enable-separate-code \
  59. --enable-relro \
  60. --enable-threads=auto \
  61. --enable-default-hash-style=gnu \
  62. --enable-64-bit-bfd \
  63. --enable-install-libiberty \
  64. --disable-compressed-debug-sections \
  65. --disable-generate-build-notes \
  66. --disable-nls \
  67. --disable-werror \
  68. --disable-ppl-version-check \
  69. --disable-cloog-version-check \
  70. --with-lib-path=/tools/lib \
  71. --with-pic \
  72. $multilib_options
  73. make -j${jobs} V=1 MAKEINFO="true"
  74. make -j${jobs} V=1 MAKEINFO="true" install
  75. # Make a new ld(1) containing another search path,
  76. # this is handled by "20-toolchain" (called from musl's recipe)
  77. make -C ld clean
  78. make -C ld LIB_PATH=/usr/lib${libSuffix}:/lib
  79. cp -f ld/ld-new /tools/bin
  80. # Unset some imported variables from file
  81. unset AR AS LD RANLIB READELF STRIP
  82. cd -- "$TMPDIR"
  83. cleanup()
  84. {
  85. rm -rf binutils-${version} binutils-build
  86. }