binutils.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. # Rather than duplicating multiple entries for these, make one
  31. # list and reuse it.
  32. GPROFNGS = " \
  33. gp-archive \
  34. gp-collect-app \
  35. gp-display-html \
  36. gp-display-src \
  37. gp-display-text \
  38. gprofng \
  39. "
  40. # it disables gprofng for clang and musl in the bb file
  41. GPROFNGS:toolchain-clang = ""
  42. GPROFNGS:libc-musl = ""
  43. GPROFNG_ALTS ?= ""
  44. GPROFNG_ALTS:x86 = "${GPROFNGS}"
  45. GPROFNG_ALTS:x86-64 = "${GPROFNGS}"
  46. GPROFNG_ALTS:aarch64 = "${GPROFNGS}"
  47. LDGOLD_ALTS ?= "ld.gold dwp"
  48. LDGOLD_ALTS:riscv64 = ""
  49. LDGOLD_ALTS:riscv32 = ""
  50. LDGOLD_ALTS:libc-glibc:mipsarch = ""
  51. USE_ALTERNATIVES_FOR = " \
  52. addr2line \
  53. ar \
  54. as \
  55. c++filt \
  56. elfedit \
  57. gprof \
  58. ${GPROFNG_ALTS} \
  59. ld \
  60. ld.bfd \
  61. ${LDGOLD_ALTS} \
  62. nm \
  63. objcopy \
  64. objdump \
  65. ranlib \
  66. readelf \
  67. size \
  68. strings \
  69. strip \
  70. "
  71. python do_package:prepend() {
  72. make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
  73. prefix = d.getVar("TARGET_PREFIX")
  74. bindir = d.getVar("bindir")
  75. for alt in make_alts.split():
  76. d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
  77. d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
  78. }
  79. B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
  80. EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
  81. --disable-werror \
  82. --enable-deterministic-archives \
  83. --enable-plugins \
  84. --disable-gdb \
  85. --disable-gdbserver \
  86. --disable-libdecnumber \
  87. --disable-readline \
  88. --disable-sim \
  89. ${LDGOLD} \
  90. ${EXTRA_TARGETS} \
  91. ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
  92. EXTRA_TARGETS = ""
  93. EXTRA_TARGETS:x86-64 = " --enable-targets=x86_64-pe,x86_64-pep "
  94. EXTRA_TARGETS:class-native = ""
  95. LDGOLD:class-native = ""
  96. LDGOLD:class-crosssdk = ""
  97. LDGOLD:libc-glibc:mipsarch = ""
  98. LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
  99. # This is necessary due to a bug in the binutils Makefiles
  100. # EXTRA_OEMAKE = "configure-build-libiberty all"
  101. export AR = "${HOST_PREFIX}ar"
  102. export AS = "${HOST_PREFIX}as"
  103. export LD = "${HOST_PREFIX}ld"
  104. export NM = "${HOST_PREFIX}nm"
  105. export RANLIB = "${HOST_PREFIX}ranlib"
  106. export OBJCOPY = "${HOST_PREFIX}objcopy"
  107. export OBJDUMP = "${HOST_PREFIX}objdump"
  108. export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
  109. export AS_FOR_TARGET = "${TARGET_PREFIX}as"
  110. export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
  111. export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
  112. export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
  113. export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
  114. export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
  115. # autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
  116. # to unset LD_LIBRARY_PATH.
  117. export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
  118. MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
  119. do_configure[vardeps] += "MULTIARCH"
  120. do_configure () {
  121. (cd ${S} && gnu-configize)
  122. oe_runconf
  123. #
  124. # must prime config.cache to ensure the build of libiberty
  125. #
  126. mkdir -p ${B}/build-${BUILD_SYS}
  127. for i in ${CONFIG_SITE}; do
  128. cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
  129. done
  130. }
  131. do_install () {
  132. autotools_do_install
  133. # We don't really need these, so we'll remove them...
  134. rm -rf ${D}${libdir}/ldscripts
  135. bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
  136. # Fix the /usr/${TARGET_SYS}/bin/* links
  137. for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
  138. rm -f $l
  139. ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
  140. done
  141. # Install the libiberty header
  142. install -d ${D}${includedir}
  143. install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
  144. install -m 644 ${S}/include/libiberty.h ${D}${includedir}
  145. # insall pic version of libiberty if available
  146. if [ -e ${B}/libiberty/pic/libiberty.a ]; then
  147. install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a
  148. fi
  149. cd ${D}${bindir}
  150. # Symlinks for ease of running these on the native target
  151. for p in ${TARGET_PREFIX}* ; do
  152. ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
  153. done
  154. for alt in ${USE_ALTERNATIVES_FOR}; do
  155. rm -f ${D}${bindir}/$alt
  156. done
  157. oe_multilib_header bfd.h
  158. }
  159. inherit update-alternatives
  160. ALTERNATIVE_PRIORITY = "100"
  161. ALTERNATIVE:${PN}:class-target = "${USE_ALTERNATIVES_FOR}"
  162. python () {
  163. if bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', True, False, d) and bb.utils.contains_any('TARGET_ARCH', 'riscv32 riscv64', True, False, d):
  164. bb.fatal("Gold linker does not _yet_ support RISC-V architecture please remove ld-is-gold from DISTRO_FEATURES")
  165. }