Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 12 | LICENSE = "GPL-3.0-only" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
| 14 | DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native" |
| 15 | |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 16 | inherit autotools gettext multilib_header pkgconfig texinfo |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 18 | FILES:${PN} = " \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | ${bindir}/${TARGET_PREFIX}* \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 20 | ${libdir}/lib*.so.* \ |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 21 | ${libdir}/bfd-plugins/lib*.so \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 22 | ${libdir}/lib*-${PV}*.so \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | ${prefix}/${TARGET_SYS}/bin/* \ |
| 24 | ${bindir}/embedspu" |
| 25 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 26 | RPROVIDES:${PN} += "${PN}-symlinks" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 28 | FILES:${PN}-dev = " \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | ${includedir} \ |
| 30 | ${libdir}/*.la \ |
| 31 | ${libdir}/libbfd.so \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 32 | ${libdir}/libctf.so \ |
| 33 | ${libdir}/libctf-nobfd.so \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | ${libdir}/libopcodes.so" |
| 35 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 36 | FILES:${PN}-staticdev += "${libdir}/gprofng/*.a" |
| 37 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | # Rather than duplicating multiple entries for these, make one |
| 39 | # list and reuse it. |
| 40 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 41 | GPROFNGS = " \ |
| 42 | gp-archive \ |
| 43 | gp-collect-app \ |
| 44 | gp-display-html \ |
| 45 | gp-display-src \ |
| 46 | gp-display-text \ |
| 47 | gprofng \ |
| 48 | " |
| 49 | |
| 50 | # it disables gprofng for clang and musl in the bb file |
| 51 | GPROFNGS:toolchain-clang = "" |
| 52 | GPROFNGS:libc-musl = "" |
| 53 | |
| 54 | GPROFNG_ALTS ?= "" |
| 55 | GPROFNG_ALTS:x86 = "${GPROFNGS}" |
| 56 | GPROFNG_ALTS:x86-64 = "${GPROFNGS}" |
| 57 | GPROFNG_ALTS:aarch64 = "${GPROFNGS}" |
| 58 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 59 | LDGOLD_ALTS ?= "ld.gold dwp" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 60 | LDGOLD_ALTS:riscv64 = "" |
| 61 | LDGOLD_ALTS:riscv32 = "" |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 62 | LDGOLD_ALTS:loongarch64 = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 63 | LDGOLD_ALTS:libc-glibc:mipsarch = "" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 64 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 65 | USE_ALTERNATIVES_FOR = " \ |
| 66 | addr2line \ |
| 67 | ar \ |
| 68 | as \ |
| 69 | c++filt \ |
| 70 | elfedit \ |
| 71 | gprof \ |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 72 | ${GPROFNG_ALTS} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | ld \ |
| 74 | ld.bfd \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 75 | ${LDGOLD_ALTS} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | nm \ |
| 77 | objcopy \ |
| 78 | objdump \ |
| 79 | ranlib \ |
| 80 | readelf \ |
| 81 | size \ |
| 82 | strings \ |
| 83 | strip \ |
| 84 | " |
| 85 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 86 | python do_package:prepend() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 87 | make_alts = d.getVar("USE_ALTERNATIVES_FOR") or "" |
| 88 | prefix = d.getVar("TARGET_PREFIX") |
| 89 | bindir = d.getVar("bindir") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | for alt in make_alts.split(): |
| 91 | d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt) |
| 92 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt) |
| 93 | } |
| 94 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | B = "${S}/build.${HOST_SYS}.${TARGET_SYS}" |
| 96 | |
| 97 | EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \ |
| 98 | --disable-werror \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 99 | --enable-deterministic-archives \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | --enable-plugins \ |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 101 | --enable-new-dtags \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 102 | --disable-gdb \ |
| 103 | --disable-gdbserver \ |
| 104 | --disable-libdecnumber \ |
| 105 | --disable-readline \ |
| 106 | --disable-sim \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | ${LDGOLD} \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 108 | ${EXTRA_TARGETS} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}" |
| 110 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 111 | EXTRA_TARGETS = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 112 | EXTRA_TARGETS:x86-64 = " --enable-targets=x86_64-pe,x86_64-pep " |
| 113 | EXTRA_TARGETS:class-native = "" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 114 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 115 | LDGOLD:class-native = "" |
| 116 | LDGOLD:class-crosssdk = "" |
| 117 | LDGOLD:libc-glibc:mipsarch = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 120 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 121 | # This is necessary due to a bug in the binutils Makefiles |
| 122 | # EXTRA_OEMAKE = "configure-build-libiberty all" |
| 123 | |
| 124 | export AR = "${HOST_PREFIX}ar" |
| 125 | export AS = "${HOST_PREFIX}as" |
| 126 | export LD = "${HOST_PREFIX}ld" |
| 127 | export NM = "${HOST_PREFIX}nm" |
| 128 | export RANLIB = "${HOST_PREFIX}ranlib" |
| 129 | export OBJCOPY = "${HOST_PREFIX}objcopy" |
| 130 | export OBJDUMP = "${HOST_PREFIX}objdump" |
| 131 | |
| 132 | export AR_FOR_TARGET = "${TARGET_PREFIX}ar" |
| 133 | export AS_FOR_TARGET = "${TARGET_PREFIX}as" |
| 134 | export LD_FOR_TARGET = "${TARGET_PREFIX}ld" |
| 135 | export NM_FOR_TARGET = "${TARGET_PREFIX}nm" |
| 136 | export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib" |
| 137 | |
| 138 | export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}" |
| 139 | export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}" |
| 140 | |
| 141 | # autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need |
| 142 | # to unset LD_LIBRARY_PATH. |
| 143 | export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}" |
| 144 | |
| 145 | MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}" |
| 146 | do_configure[vardeps] += "MULTIARCH" |
| 147 | do_configure () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 148 | (cd ${S} && gnu-configize) |
| 149 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 150 | oe_runconf |
| 151 | # |
| 152 | # must prime config.cache to ensure the build of libiberty |
| 153 | # |
| 154 | mkdir -p ${B}/build-${BUILD_SYS} |
| 155 | for i in ${CONFIG_SITE}; do |
| 156 | cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true |
| 157 | done |
| 158 | } |
| 159 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 160 | do_install () { |
| 161 | autotools_do_install |
| 162 | |
| 163 | # We don't really need these, so we'll remove them... |
| 164 | rm -rf ${D}${libdir}/ldscripts |
| 165 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 166 | bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')} |
| 167 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 168 | # Fix the /usr/${TARGET_SYS}/bin/* links |
| 169 | for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do |
| 170 | rm -f $l |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 171 | ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | done |
| 173 | |
| 174 | # Install the libiberty header |
| 175 | install -d ${D}${includedir} |
| 176 | install -m 644 ${S}/include/ansidecl.h ${D}${includedir} |
| 177 | install -m 644 ${S}/include/libiberty.h ${D}${includedir} |
| 178 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 179 | # insall pic version of libiberty if available |
| 180 | if [ -e ${B}/libiberty/pic/libiberty.a ]; then |
| 181 | install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a |
| 182 | fi |
| 183 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 | cd ${D}${bindir} |
| 185 | |
| 186 | # Symlinks for ease of running these on the native target |
| 187 | for p in ${TARGET_PREFIX}* ; do |
| 188 | ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,` |
| 189 | done |
| 190 | |
| 191 | for alt in ${USE_ALTERNATIVES_FOR}; do |
| 192 | rm -f ${D}${bindir}/$alt |
| 193 | done |
| 194 | |
| 195 | oe_multilib_header bfd.h |
| 196 | } |
| 197 | |
| 198 | inherit update-alternatives |
| 199 | |
| 200 | ALTERNATIVE_PRIORITY = "100" |
| 201 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 202 | ALTERNATIVE:${PN}:class-target = "${USE_ALTERNATIVES_FOR}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 203 | |
| 204 | python () { |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 205 | 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): |
| 206 | bb.fatal("Gold linker does not _yet_ support RISC-V and LoongArch architecture please remove ld-is-gold from DISTRO_FEATURES") |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 207 | } |