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