blob: c69d29448f3a266746000650726e69ac041b68f0 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "GNU binary utilities"
2DESCRIPTION = "The GNU Binutils are a collection of binary tools. \
3The main ones are ld (GNU Linker), and as (GNU Assembler). This \
4package also includes addition tools such as addr2line (Converts \
5addresses into filenames and line numbers), ar (utility for creating, \
6modifying and extracting archives), nm (list symbols in object \
7files), objcopy (copy and translate object files), objdump (Display \
8object information), and other tools and related libraries."
9HOMEPAGE = "http://www.gnu.org/software/binutils/"
10BUGTRACKER = "http://sourceware.org/bugzilla/"
11SECTION = "devel"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000012LICENSE = "GPL-3.0-only"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
14DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native"
15
Andrew Geissler5199d832021-09-24 16:47:35 -050016inherit autotools gettext multilib_header pkgconfig texinfo
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017
Patrick Williams213cb262021-08-07 19:21:33 -050018FILES:${PN} = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 ${bindir}/${TARGET_PREFIX}* \
Andrew Geissler82c905d2020-04-13 13:39:40 -050020 ${libdir}/lib*.so.* \
Andrew Geisslerd1e89492021-02-12 15:35:20 -060021 ${libdir}/bfd-plugins/lib*.so \
Andrew Geissler82c905d2020-04-13 13:39:40 -050022 ${libdir}/lib*-${PV}*.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 ${prefix}/${TARGET_SYS}/bin/* \
24 ${bindir}/embedspu"
25
Patrick Williams213cb262021-08-07 19:21:33 -050026RPROVIDES:${PN} += "${PN}-symlinks"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
Patrick Williams213cb262021-08-07 19:21:33 -050028FILES:${PN}-dev = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 ${includedir} \
30 ${libdir}/*.la \
31 ${libdir}/libbfd.so \
Andrew Geissler82c905d2020-04-13 13:39:40 -050032 ${libdir}/libctf.so \
33 ${libdir}/libctf-nobfd.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 ${libdir}/libopcodes.so"
35
36# Rather than duplicating multiple entries for these, make one
37# list and reuse it.
38
Andrew Geissler87f5cff2022-09-30 13:13:31 -050039GPROFNGS = " \
40 gp-archive \
41 gp-collect-app \
42 gp-display-html \
43 gp-display-src \
44 gp-display-text \
45 gprofng \
46"
47
48# it disables gprofng for clang and musl in the bb file
49GPROFNGS:toolchain-clang = ""
50GPROFNGS:libc-musl = ""
51
52GPROFNG_ALTS ?= ""
53GPROFNG_ALTS:x86 = "${GPROFNGS}"
54GPROFNG_ALTS:x86-64 = "${GPROFNGS}"
55GPROFNG_ALTS:aarch64 = "${GPROFNGS}"
56
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057LDGOLD_ALTS ?= "ld.gold dwp"
Patrick Williams213cb262021-08-07 19:21:33 -050058LDGOLD_ALTS:riscv64 = ""
59LDGOLD_ALTS:riscv32 = ""
Patrick Williams864cc432023-02-09 14:54:44 -060060LDGOLD_ALTS:loongarch64 = ""
Patrick Williams213cb262021-08-07 19:21:33 -050061LDGOLD_ALTS:libc-glibc:mipsarch = ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080062
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063USE_ALTERNATIVES_FOR = " \
64 addr2line \
65 ar \
66 as \
67 c++filt \
68 elfedit \
69 gprof \
Andrew Geissler87f5cff2022-09-30 13:13:31 -050070 ${GPROFNG_ALTS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 ld \
72 ld.bfd \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080073 ${LDGOLD_ALTS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 nm \
75 objcopy \
76 objdump \
77 ranlib \
78 readelf \
79 size \
80 strings \
81 strip \
82"
83
Patrick Williams213cb262021-08-07 19:21:33 -050084python do_package:prepend() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050085 make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
86 prefix = d.getVar("TARGET_PREFIX")
87 bindir = d.getVar("bindir")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 for alt in make_alts.split():
89 d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
90 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
91}
92
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
94
95EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
96 --disable-werror \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060097 --enable-deterministic-archives \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 --enable-plugins \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050099 --enable-new-dtags \
Andrew Geissler82c905d2020-04-13 13:39:40 -0500100 --disable-gdb \
101 --disable-gdbserver \
102 --disable-libdecnumber \
103 --disable-readline \
104 --disable-sim \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 ${LDGOLD} \
Andrew Geissler82c905d2020-04-13 13:39:40 -0500106 ${EXTRA_TARGETS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
108
Andrew Geissler82c905d2020-04-13 13:39:40 -0500109EXTRA_TARGETS = ""
Patrick Williams213cb262021-08-07 19:21:33 -0500110EXTRA_TARGETS:x86-64 = " --enable-targets=x86_64-pe,x86_64-pep "
111EXTRA_TARGETS:class-native = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -0500112
Patrick Williams213cb262021-08-07 19:21:33 -0500113LDGOLD:class-native = ""
114LDGOLD:class-crosssdk = ""
115LDGOLD:libc-glibc:mipsarch = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500116LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117
Andrew Geissler82c905d2020-04-13 13:39:40 -0500118
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119# This is necessary due to a bug in the binutils Makefiles
120# EXTRA_OEMAKE = "configure-build-libiberty all"
121
122export AR = "${HOST_PREFIX}ar"
123export AS = "${HOST_PREFIX}as"
124export LD = "${HOST_PREFIX}ld"
125export NM = "${HOST_PREFIX}nm"
126export RANLIB = "${HOST_PREFIX}ranlib"
127export OBJCOPY = "${HOST_PREFIX}objcopy"
128export OBJDUMP = "${HOST_PREFIX}objdump"
129
130export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
131export AS_FOR_TARGET = "${TARGET_PREFIX}as"
132export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
133export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
134export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
135
136export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
137export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
138
139# autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
140# to unset LD_LIBRARY_PATH.
141export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
142
143MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
144do_configure[vardeps] += "MULTIARCH"
145do_configure () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500146 (cd ${S} && gnu-configize)
147
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 oe_runconf
149#
150# must prime config.cache to ensure the build of libiberty
151#
152 mkdir -p ${B}/build-${BUILD_SYS}
153 for i in ${CONFIG_SITE}; do
154 cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
155 done
156}
157
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158do_install () {
159 autotools_do_install
160
161 # We don't really need these, so we'll remove them...
162 rm -rf ${D}${libdir}/ldscripts
163
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800164 bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
165
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 # Fix the /usr/${TARGET_SYS}/bin/* links
167 for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
168 rm -f $l
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800169 ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170 done
171
172 # Install the libiberty header
173 install -d ${D}${includedir}
174 install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
175 install -m 644 ${S}/include/libiberty.h ${D}${includedir}
176
Andrew Geissler82c905d2020-04-13 13:39:40 -0500177 # insall pic version of libiberty if available
178 if [ -e ${B}/libiberty/pic/libiberty.a ]; then
179 install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a
180 fi
181
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182 cd ${D}${bindir}
183
184 # Symlinks for ease of running these on the native target
185 for p in ${TARGET_PREFIX}* ; do
186 ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
187 done
188
189 for alt in ${USE_ALTERNATIVES_FOR}; do
190 rm -f ${D}${bindir}/$alt
191 done
192
193 oe_multilib_header bfd.h
194}
195
196inherit update-alternatives
197
198ALTERNATIVE_PRIORITY = "100"
199
Patrick Williams213cb262021-08-07 19:21:33 -0500200ALTERNATIVE:${PN}:class-target = "${USE_ALTERNATIVES_FOR}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500201
202python () {
Patrick Williams864cc432023-02-09 14:54:44 -0600203 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):
204 bb.fatal("Gold linker does not _yet_ support RISC-V and LoongArch architecture please remove ld-is-gold from DISTRO_FEATURES")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500205}