binutils.mk 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ################################################################################
  2. #
  3. # binutils
  4. #
  5. ################################################################################
  6. # Version is set when using buildroot toolchain.
  7. # If not, we do like other packages
  8. BINUTILS_VERSION = $(call qstrip,$(BR2_BINUTILS_VERSION))
  9. ifeq ($(BINUTILS_VERSION),)
  10. ifeq ($(BR2_arc),y)
  11. BINUTILS_VERSION = arc-2024.12-release
  12. else
  13. BINUTILS_VERSION = 2.44
  14. endif
  15. endif # BINUTILS_VERSION
  16. ifeq ($(BINUTILS_VERSION),arc-2024.12-release)
  17. BINUTILS_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(BINUTILS_VERSION))
  18. BINUTILS_SOURCE = binutils-gdb-$(BINUTILS_VERSION).tar.gz
  19. BINUTILS_FROM_GIT = y
  20. endif
  21. BINUTILS_SITE ?= $(BR2_GNU_MIRROR)/binutils
  22. BINUTILS_SOURCE ?= binutils-$(BINUTILS_VERSION).tar.xz
  23. BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS))
  24. BINUTILS_INSTALL_STAGING = YES
  25. BINUTILS_DEPENDENCIES = zlib $(TARGET_NLS_DEPENDENCIES)
  26. BINUTILS_MAKE_OPTS = LIBS=$(TARGET_NLS_LIBS)
  27. BINUTILS_LICENSE = GPL-3.0+, libiberty LGPL-2.1+
  28. BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
  29. BINUTILS_CPE_ID_VENDOR = gnu
  30. # 0003-objdump-memleak.patch
  31. BINUTILS_IGNORE_CVES += CVE-2025-3198
  32. ifeq ($(BINUTILS_FROM_GIT),y)
  33. BINUTILS_DEPENDENCIES += host-flex host-bison
  34. HOST_BINUTILS_DEPENDENCIES += host-flex host-bison
  35. endif
  36. # When binutils sources are fetched from the binutils-gdb repository,
  37. # they also contain the gdb sources, but gdb shouldn't be built, so we
  38. # disable it.
  39. BINUTILS_DISABLE_GDB_CONF_OPTS = \
  40. --disable-sim \
  41. --disable-gdb
  42. # We need to specify host & target to avoid breaking ARM EABI
  43. #
  44. # --with-system-readline to never build readline, as binutils doesn't
  45. # need it (only gdb does). For binutils release tarballs, readline
  46. # is not shipped, but when we get it from git, it is present and
  47. # gets built which can cause build issues, so force skipping
  48. # it. Note: the configure script will not check for readline as it
  49. # doesn't need it.
  50. BINUTILS_CONF_OPTS = \
  51. --disable-multilib \
  52. --disable-werror \
  53. --host=$(GNU_TARGET_NAME) \
  54. --target=$(GNU_TARGET_NAME) \
  55. --enable-install-libiberty \
  56. --enable-build-warnings=no \
  57. --with-system-zlib \
  58. --disable-gprofng \
  59. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  60. $(BINUTILS_EXTRA_CONFIG_OPTIONS) \
  61. --without-zstd \
  62. --with-system-readline
  63. ifeq ($(BR2_STATIC_LIBS),y)
  64. BINUTILS_CONF_OPTS += --disable-plugins
  65. endif
  66. # Don't build documentation. It takes up extra space / build time,
  67. # and sometimes needs specific makeinfo versions to work
  68. BINUTILS_CONF_ENV += MAKEINFO=true
  69. BINUTILS_MAKE_OPTS += MAKEINFO=true
  70. BINUTILS_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) MAKEINFO=true install
  71. HOST_BINUTILS_CONF_ENV += MAKEINFO=true
  72. HOST_BINUTILS_MAKE_OPTS += MAKEINFO=true
  73. HOST_BINUTILS_INSTALL_OPTS += MAKEINFO=true install
  74. # Workaround a build issue with -Os for ARM Cortex-M cpus.
  75. # (Binutils 2.25.1 and 2.26.1)
  76. # https://sourceware.org/bugzilla/show_bug.cgi?id=20552
  77. ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
  78. BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
  79. endif
  80. # "host" binutils should actually be "cross"
  81. # We just keep the convention of "host utility" for now
  82. #
  83. # --with-system-readline to never build readline, as binutils doesn't
  84. # need it (only gdb does). For binutils release tarballs, readline
  85. # is not shipped, but when we get it from git, it is present and
  86. # gets built which can cause build issues, so force skipping
  87. # it. Note: the configure script will not check for readline as it
  88. # doesn't need it.
  89. HOST_BINUTILS_CONF_OPTS = \
  90. --disable-multilib \
  91. --disable-werror \
  92. --target=$(GNU_TARGET_NAME) \
  93. --disable-shared \
  94. --enable-static \
  95. --with-sysroot=$(STAGING_DIR) \
  96. --enable-poison-system-directories \
  97. --without-debuginfod \
  98. --enable-plugins \
  99. --enable-lto \
  100. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  101. $(BINUTILS_EXTRA_CONFIG_OPTIONS) \
  102. --without-zstd \
  103. --with-system-readline
  104. ifeq ($(BR2_BINUTILS_GPROFNG),y)
  105. HOST_BINUTILS_DEPENDENCIES += host-bison
  106. HOST_BINUTILS_CONF_OPTS += --enable-gprofng
  107. else
  108. HOST_BINUTILS_CONF_OPTS += --disable-gprofng
  109. endif
  110. # binutils run configure script of subdirs at make time, so ensure
  111. # our TARGET_CONFIGURE_ARGS are taken into consideration for those
  112. BINUTILS_MAKE_ENV = $(TARGET_CONFIGURE_ARGS)
  113. # We just want libbfd, libiberty and libopcodes,
  114. # not the full-blown binutils in staging
  115. define BINUTILS_INSTALL_STAGING_CMDS
  116. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install
  117. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(STAGING_DIR) install
  118. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
  119. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libsframe DESTDIR=$(STAGING_DIR) install
  120. endef
  121. # If we don't want full binutils on target
  122. ifneq ($(BR2_PACKAGE_BINUTILS_TARGET),y)
  123. # libiberty is static-only, so it is only installed to staging, above.
  124. define BINUTILS_INSTALL_TARGET_CMDS
  125. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(TARGET_DIR) install
  126. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(TARGET_DIR) install
  127. endef
  128. endif
  129. ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
  130. define BINUTILS_XTENSA_OVERLAY_EXTRACT
  131. $(call arch-xtensa-overlay-extract,$(@D),binutils)
  132. endef
  133. BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
  134. BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
  135. HOST_BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
  136. HOST_BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
  137. endif
  138. # Hardlinks between binaries in different directories cause a problem
  139. # with rpath fixup, so we de-hardlink those binaries, and replace them
  140. # with copies instead.
  141. BINUTILS_TOOLS = ar as ld ld.bfd nm objcopy objdump ranlib readelf strip
  142. define HOST_BINUTILS_FIXUP_HARDLINKS
  143. $(foreach tool,$(BINUTILS_TOOLS),\
  144. rm -f $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) && \
  145. cp -a $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-$(tool) \
  146. $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool)
  147. )
  148. endef
  149. HOST_BINUTILS_POST_INSTALL_HOOKS += HOST_BINUTILS_FIXUP_HARDLINKS
  150. $(eval $(autotools-package))
  151. $(eval $(host-autotools-package))