binutils.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. SUMMARY = "GNU binary utilities"
  2. DESCRIPTION = "The GNU Binutils are a collection of binary tools. \
  3. The main ones are ld (GNU Linker), and as (GNU Assembler). This \
  4. package also includes addition tools such as addr2line (Converts \
  5. addresses into filenames and line numbers), ar (utility for creating, \
  6. modifying and extracting archives), nm (list symbols in object \
  7. files), objcopy (copy and translate object files), objdump (Display \
  8. object information), and other tools and related libraries."
  9. HOMEPAGE = "http://www.gnu.org/software/binutils/"
  10. BUGTRACKER = "http://sourceware.org/bugzilla/"
  11. SECTION = "devel"
  12. LICENSE = "GPL-3.0-only"
  13. DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native"
  14. inherit autotools gettext multilib_header pkgconfig texinfo
  15. FILES:${PN} = " \
  16. ${bindir}/${TARGET_PREFIX}* \
  17. ${libdir}/lib*.so.* \
  18. ${libdir}/bfd-plugins/lib*.so \
  19. ${libdir}/lib*-${PV}*.so \
  20. ${prefix}/${TARGET_SYS}/bin/* \
  21. ${bindir}/embedspu"
  22. RPROVIDES:${PN} += "${PN}-symlinks"
  23. FILES:${PN}-dev = " \
  24. ${includedir} \
  25. ${libdir}/*.la \
  26. ${libdir}/libbfd.so \
  27. ${libdir}/libctf.so \
  28. ${libdir}/libctf-nobfd.so \
  29. ${libdir}/libopcodes.so"
  30. FILES:${PN}-staticdev += "${libdir}/gprofng/*.a"
  31. # Rather than duplicating multiple entries for these, make one
  32. # list and reuse it.
  33. GPROFNGS = " \
  34. gp-archive \
  35. gp-collect-app \
  36. gp-display-html \
  37. gp-display-src \
  38. gp-display-text \
  39. gprofng \
  40. "
  41. # it disables gprofng for clang and musl in the bb file
  42. GPROFNGS:toolchain-clang = ""
  43. GPROFNGS:libc-musl = ""
  44. GPROFNG_ALTS ?= ""
  45. GPROFNG_ALTS:x86 = "${GPROFNGS}"
  46. GPROFNG_ALTS:x86-64 = "${GPROFNGS}"
  47. GPROFNG_ALTS:aarch64 = "${GPROFNGS}"
  48. LDGOLD_ALTS ?= "ld.gold dwp"
  49. LDGOLD_ALTS:riscv64 = ""
  50. LDGOLD_ALTS:riscv32 = ""
  51. LDGOLD_ALTS:loongarch64 = ""
  52. LDGOLD_ALTS:libc-glibc:mipsarch = ""
  53. USE_ALTERNATIVES_FOR = " \
  54. addr2line \
  55. ar \
  56. as \
  57. c++filt \
  58. elfedit \
  59. gprof \
  60. ${GPROFNG_ALTS} \
  61. ld \
  62. ld.bfd \
  63. ${LDGOLD_ALTS} \
  64. nm \
  65. objcopy \
  66. objdump \
  67. ranlib \
  68. readelf \
  69. size \
  70. strings \
  71. strip \
  72. "
  73. python do_package:prepend() {
  74. make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
  75. prefix = d.getVar("TARGET_PREFIX")
  76. bindir = d.getVar("bindir")
  77. for alt in make_alts.split():
  78. d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
  79. d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
  80. }
  81. B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
  82. EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
  83. --disable-werror \
  84. --enable-deterministic-archives \
  85. --enable-plugins \
  86. --enable-new-dtags \
  87. --disable-gdb \
  88. --disable-gdbserver \
  89. --disable-libdecnumber \
  90. --disable-readline \
  91. --disable-sim \
  92. ${LDGOLD} \
  93. ${EXTRA_TARGETS} \
  94. ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
  95. EXTRA_TARGETS = ""
  96. EXTRA_TARGETS:x86-64 = " --enable-targets=x86_64-pe,x86_64-pep "
  97. EXTRA_TARGETS:class-native = ""
  98. LDGOLD:class-native = ""
  99. LDGOLD:class-crosssdk = ""
  100. LDGOLD:libc-glibc:mipsarch = ""
  101. LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
  102. # This is necessary due to a bug in the binutils Makefiles
  103. # EXTRA_OEMAKE = "configure-build-libiberty all"
  104. export AR = "${HOST_PREFIX}ar"
  105. export AS = "${HOST_PREFIX}as"
  106. export LD = "${HOST_PREFIX}ld"
  107. export NM = "${HOST_PREFIX}nm"
  108. export RANLIB = "${HOST_PREFIX}ranlib"
  109. export OBJCOPY = "${HOST_PREFIX}objcopy"
  110. export OBJDUMP = "${HOST_PREFIX}objdump"
  111. export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
  112. export AS_FOR_TARGET = "${TARGET_PREFIX}as"
  113. export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
  114. export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
  115. export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
  116. export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
  117. export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
  118. # autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
  119. # to unset LD_LIBRARY_PATH.
  120. export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
  121. MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
  122. do_configure[vardeps] += "MULTIARCH"
  123. do_configure () {
  124. (cd ${S} && gnu-configize)
  125. oe_runconf
  126. #
  127. # must prime config.cache to ensure the build of libiberty
  128. #
  129. mkdir -p ${B}/build-${BUILD_SYS}
  130. for i in ${CONFIG_SITE}; do
  131. cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
  132. done
  133. }
  134. do_install () {
  135. autotools_do_install
  136. # We don't really need these, so we'll remove them...
  137. rm -rf ${D}${libdir}/ldscripts
  138. bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
  139. # Fix the /usr/${TARGET_SYS}/bin/* links
  140. for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
  141. rm -f $l
  142. ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
  143. done
  144. # Install the libiberty header
  145. install -d ${D}${includedir}
  146. install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
  147. install -m 644 ${S}/include/libiberty.h ${D}${includedir}
  148. # insall pic version of libiberty if available
  149. if [ -e ${B}/libiberty/pic/libiberty.a ]; then
  150. install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a
  151. fi
  152. cd ${D}${bindir}
  153. # Symlinks for ease of running these on the native target
  154. for p in ${TARGET_PREFIX}* ; do
  155. ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
  156. done
  157. for alt in ${USE_ALTERNATIVES_FOR}; do
  158. rm -f ${D}${bindir}/$alt
  159. done
  160. oe_multilib_header bfd.h
  161. }
  162. inherit update-alternatives
  163. ALTERNATIVE_PRIORITY = "100"
  164. ALTERNATIVE:${PN}:class-target = "${USE_ALTERNATIVES_FOR}"
  165. python () {
  166. if bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', True, False, d) and bb.utils.contains_any('TARGET_ARCH', 'riscv32 riscv64 loongarch64', True, False, d):
  167. bb.fatal("Gold linker does not _yet_ support RISC-V and LoongArch architecture please remove ld-is-gold from DISTRO_FEATURES")
  168. }