binutils.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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-2016.09-eng011
  12. else
  13. BINUTILS_VERSION = 2.25.1
  14. endif
  15. endif # BINUTILS_VERSION
  16. ifeq ($(BR2_arc),y)
  17. BINUTILS_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(BINUTILS_VERSION))
  18. BINUTILS_SOURCE = binutils-$(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.bz2
  23. BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS))
  24. BINUTILS_INSTALL_STAGING = YES
  25. BINUTILS_DEPENDENCIES = $(if $(BR2_NEEDS_GETTEXT_IF_LOCALE),gettext)
  26. BINUTILS_LICENSE = GPLv3+, libiberty LGPLv2.1+
  27. BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
  28. ifeq ($(BINUTILS_FROM_GIT),y)
  29. BINUTILS_DEPENDENCIES += host-flex host-bison host-texinfo
  30. HOST_BINUTILS_DEPENDENCIES += host-flex host-bison host-texinfo
  31. endif
  32. # The .info files in the >= 2.26 tarball have an incorrect timestamp,
  33. # so binutils tries to re-generate them. In order to avoid the
  34. # dependency on host-texinfo, we simply update the timestamps.
  35. ifeq ($(BR2_BINUTILS_VERSION_2_26_X)$(BR2_BINUTILS_VERSION_2_27_X),y)
  36. define BINUTILS_FIXUP_INFO_TIMESTAMPS
  37. find $(@D) -name '*.info' -exec touch {} \;
  38. endef
  39. BINUTILS_POST_PATCH_HOOKS += BINUTILS_FIXUP_INFO_TIMESTAMPS
  40. HOST_BINUTILS_POST_PATCH_HOOKS += BINUTILS_FIXUP_INFO_TIMESTAMPS
  41. endif
  42. # When binutils sources are fetched from the binutils-gdb repository,
  43. # they also contain the gdb sources, but gdb shouldn't be built, so we
  44. # disable it.
  45. BINUTILS_DISABLE_GDB_CONF_OPTS = \
  46. --disable-sim \
  47. --disable-gdb
  48. # We need to specify host & target to avoid breaking ARM EABI
  49. BINUTILS_CONF_OPTS = \
  50. --disable-multilib \
  51. --disable-werror \
  52. --host=$(GNU_TARGET_NAME) \
  53. --target=$(GNU_TARGET_NAME) \
  54. --enable-install-libiberty \
  55. --enable-build-warnings=no \
  56. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  57. $(BINUTILS_EXTRA_CONFIG_OPTIONS)
  58. ifeq ($(BR2_STATIC_LIBS),y)
  59. BINUTILS_CONF_OPTS += --disable-plugins
  60. endif
  61. # Don't build documentation. It takes up extra space / build time,
  62. # and sometimes needs specific makeinfo versions to work
  63. BINUTILS_CONF_ENV += ac_cv_prog_MAKEINFO=missing
  64. HOST_BINUTILS_CONF_ENV += ac_cv_prog_MAKEINFO=missing
  65. # gcc bug with Os/O2/O3, PR77311
  66. # error: unable to find a register to spill in class 'CCREGS'
  67. ifeq ($(BR2_bfin),y)
  68. BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O1"
  69. endif
  70. # Workaround a build issue with -Os for ARM Cortex-M cpus.
  71. # (Binutils 2.25.1 and 2.26.1)
  72. # https://sourceware.org/bugzilla/show_bug.cgi?id=20552
  73. ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
  74. BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
  75. endif
  76. # Install binutils after busybox to prefer full-blown utilities
  77. ifeq ($(BR2_PACKAGE_BUSYBOX),y)
  78. BINUTILS_DEPENDENCIES += busybox
  79. endif
  80. ifeq ($(BR2_PACKAGE_ZLIB),y)
  81. BINUTILS_DEPENDENCIES += zlib
  82. endif
  83. # "host" binutils should actually be "cross"
  84. # We just keep the convention of "host utility" for now
  85. HOST_BINUTILS_CONF_OPTS = \
  86. --disable-multilib \
  87. --disable-werror \
  88. --target=$(GNU_TARGET_NAME) \
  89. --disable-shared \
  90. --enable-static \
  91. --with-sysroot=$(STAGING_DIR) \
  92. --enable-poison-system-directories \
  93. $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
  94. $(BINUTILS_EXTRA_CONFIG_OPTIONS)
  95. # binutils run configure script of subdirs at make time, so ensure
  96. # our TARGET_CONFIGURE_ARGS are taken into consideration for those
  97. define BINUTILS_BUILD_CMDS
  98. $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_ARGS) $(MAKE) -C $(@D)
  99. endef
  100. # We just want libbfd, libiberty and libopcodes,
  101. # not the full-blown binutils in staging
  102. define BINUTILS_INSTALL_STAGING_CMDS
  103. $(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install
  104. $(MAKE) -C $(@D)/opcodes DESTDIR=$(STAGING_DIR) install
  105. $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
  106. endef
  107. # If we don't want full binutils on target
  108. ifneq ($(BR2_PACKAGE_BINUTILS_TARGET),y)
  109. define BINUTILS_INSTALL_TARGET_CMDS
  110. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(TARGET_DIR) install
  111. $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
  112. endef
  113. endif
  114. XTENSA_CORE_NAME = $(call qstrip, $(BR2_XTENSA_CORE_NAME))
  115. ifneq ($(XTENSA_CORE_NAME),)
  116. define BINUTILS_XTENSA_PRE_PATCH
  117. tar xf $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(XTENSA_CORE_NAME).tar \
  118. -C $(@D) --strip-components=1 binutils
  119. endef
  120. BINUTILS_PRE_PATCH_HOOKS += BINUTILS_XTENSA_PRE_PATCH
  121. HOST_BINUTILS_PRE_PATCH_HOOKS += BINUTILS_XTENSA_PRE_PATCH
  122. endif
  123. ifeq ($(BR2_BINUTILS_ENABLE_LTO),y)
  124. HOST_BINUTILS_CONF_OPTS += --enable-plugins --enable-lto
  125. endif
  126. $(eval $(autotools-package))
  127. $(eval $(host-autotools-package))