binutils.mk 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-2023.09-release
  12. else
  13. BINUTILS_VERSION = 2.40
  14. endif
  15. endif # BINUTILS_VERSION
  16. ifeq ($(BINUTILS_VERSION),arc-2023.09-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. ifeq ($(BINUTILS_FROM_GIT),y)
  31. BINUTILS_DEPENDENCIES += host-flex host-bison
  32. HOST_BINUTILS_DEPENDENCIES += host-flex host-bison
  33. endif
  34. # When binutils sources are fetched from the binutils-gdb repository,
  35. # they also contain the gdb sources, but gdb shouldn't be built, so we
  36. # disable it.
  37. BINUTILS_DISABLE_GDB_CONF_OPTS = \
  38. --disable-sim \
  39. --disable-gdb
  40. # We need to specify host & target to avoid breaking ARM EABI
  41. BINUTILS_CONF_OPTS = \
  42. --disable-multilib \
  43. --disable-werror \
  44. --host=$(GNU_TARGET_NAME) \
  45. --target=$(GNU_TARGET_NAME) \
  46. --enable-install-libiberty \
  47. --enable-build-warnings=no \
  48. --with-system-zlib \
  49. --disable-gprofng \
  50. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  51. $(BINUTILS_EXTRA_CONFIG_OPTIONS) \
  52. --without-zstd
  53. ifeq ($(BR2_STATIC_LIBS),y)
  54. BINUTILS_CONF_OPTS += --disable-plugins
  55. endif
  56. # Don't build documentation. It takes up extra space / build time,
  57. # and sometimes needs specific makeinfo versions to work
  58. BINUTILS_CONF_ENV += MAKEINFO=true
  59. BINUTILS_MAKE_OPTS += MAKEINFO=true
  60. BINUTILS_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) MAKEINFO=true install
  61. HOST_BINUTILS_CONF_ENV += MAKEINFO=true
  62. HOST_BINUTILS_MAKE_OPTS += MAKEINFO=true
  63. HOST_BINUTILS_INSTALL_OPTS += MAKEINFO=true install
  64. # Workaround a build issue with -Os for ARM Cortex-M cpus.
  65. # (Binutils 2.25.1 and 2.26.1)
  66. # https://sourceware.org/bugzilla/show_bug.cgi?id=20552
  67. ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
  68. BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
  69. endif
  70. # "host" binutils should actually be "cross"
  71. # We just keep the convention of "host utility" for now
  72. HOST_BINUTILS_CONF_OPTS = \
  73. --disable-multilib \
  74. --disable-werror \
  75. --target=$(GNU_TARGET_NAME) \
  76. --disable-shared \
  77. --enable-static \
  78. --with-sysroot=$(STAGING_DIR) \
  79. --enable-poison-system-directories \
  80. --without-debuginfod \
  81. --enable-plugins \
  82. --enable-lto \
  83. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  84. $(BINUTILS_EXTRA_CONFIG_OPTIONS) \
  85. --without-zstd
  86. ifeq ($(BR2_BINUTILS_GPROFNG),y)
  87. HOST_BINUTILS_DEPENDENCIES += host-bison
  88. HOST_BINUTILS_CONF_OPTS += --enable-gprofng
  89. else
  90. HOST_BINUTILS_CONF_OPTS += --disable-gprofng
  91. endif
  92. # binutils run configure script of subdirs at make time, so ensure
  93. # our TARGET_CONFIGURE_ARGS are taken into consideration for those
  94. BINUTILS_MAKE_ENV = $(TARGET_CONFIGURE_ARGS)
  95. ifeq ($(BR2_PACKAGE_BINUTILS_HAS_NO_LIBSFRAME),)
  96. define BINUTILS_INSTALL_STAGING_LIBSFRAME
  97. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libsframe DESTDIR=$(STAGING_DIR) install
  98. endef
  99. endif
  100. # We just want libbfd, libiberty and libopcodes,
  101. # not the full-blown binutils in staging
  102. define BINUTILS_INSTALL_STAGING_CMDS
  103. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install
  104. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(STAGING_DIR) install
  105. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
  106. $(BINUTILS_INSTALL_STAGING_LIBSFRAME)
  107. endef
  108. # If we don't want full binutils on target
  109. ifneq ($(BR2_PACKAGE_BINUTILS_TARGET),y)
  110. # libiberty is static-only, so it is only installed to staging, above.
  111. define BINUTILS_INSTALL_TARGET_CMDS
  112. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(TARGET_DIR) install
  113. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(TARGET_DIR) install
  114. endef
  115. endif
  116. ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
  117. define BINUTILS_XTENSA_OVERLAY_EXTRACT
  118. $(call arch-xtensa-overlay-extract,$(@D),binutils)
  119. endef
  120. BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
  121. BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
  122. HOST_BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT
  123. HOST_BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
  124. endif
  125. # Hardlinks between binaries in different directories cause a problem
  126. # with rpath fixup, so we de-hardlink those binaries, and replace them
  127. # with copies instead.
  128. BINUTILS_TOOLS = ar as ld ld.bfd nm objcopy objdump ranlib readelf strip
  129. define HOST_BINUTILS_FIXUP_HARDLINKS
  130. $(foreach tool,$(BINUTILS_TOOLS),\
  131. rm -f $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) && \
  132. cp -a $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-$(tool) \
  133. $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool)
  134. )
  135. endef
  136. HOST_BINUTILS_POST_INSTALL_HOOKS += HOST_BINUTILS_FIXUP_HARDLINKS
  137. $(eval $(autotools-package))
  138. $(eval $(host-autotools-package))