binutils.mk 5.0 KB

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