aportgen binutils: modernize (MR 2199)
Set CTARGET and CTARGET_ARCH on top of the generated APKBUILD and use the existing code in the APKBUILD for build(), package(), makedepends, subpackages. This is now possible, because the pmbootstrap parser for APKBUILDs has been improved a lot since this was originally written and because the Alpine APKBUILD does everything that was hacked in here, like removing man, info directories and bfd-plugins if doing a cross build. This is now very similar to bootstrapping binutils for another architecture via scripts/bootstrap.sh in aports.git. Most importantly this sets --disable-gprofng, which fails to build against musl and is the reason why our cross/binutils-* packages generated from binutils 2.39.x didn't build anymore. Related: https://git.alpinelinux.org/aports/tree/main/binutils/APKBUILD Related: https://sourceware.org/bugzilla/show_bug.cgi?id=29477
This commit is contained in:
parent
e5d580e98a
commit
b41e4a418f
|
@ -16,45 +16,12 @@ def generate(args, pkgname):
|
|||
"pkgname": pkgname,
|
||||
"pkgdesc": f"Tools necessary to build programs for {arch} targets",
|
||||
"arch": pmb.config.arch_native,
|
||||
"makedepends_build": "",
|
||||
"makedepends_host": "",
|
||||
"makedepends": "gettext libtool autoconf automake bison texinfo",
|
||||
"subpackages": "",
|
||||
}
|
||||
|
||||
replace_functions = {
|
||||
"build": """
|
||||
_target="$(arch_to_hostspec """ + arch + """)"
|
||||
"$builddir"/configure \\
|
||||
--build="$CBUILD" \\
|
||||
--target=$_target \\
|
||||
--with-lib-path=/usr/lib \\
|
||||
--prefix=/usr \\
|
||||
--with-sysroot=/usr/$_target \\
|
||||
--enable-ld=default \\
|
||||
--enable-gold=yes \\
|
||||
--enable-plugins \\
|
||||
--enable-deterministic-archives \\
|
||||
--disable-multilib \\
|
||||
--disable-werror \\
|
||||
--disable-nls
|
||||
make
|
||||
""",
|
||||
"package": """
|
||||
make install DESTDIR="$pkgdir"
|
||||
|
||||
# remove man, info folders
|
||||
rm -rf "$pkgdir"/usr/share
|
||||
|
||||
# remove files that conflict with non-cross binutils
|
||||
rm -rf "$pkgdir"/usr/lib/bfd-plugins
|
||||
""",
|
||||
"libs": None,
|
||||
"gold": None,
|
||||
}
|
||||
|
||||
replace_simple = {"\tsubpackages=*": "\tsubpackages=\"\""}
|
||||
below_header = """
|
||||
CTARGET_ARCH=""" + arch + """
|
||||
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
|
||||
"""
|
||||
|
||||
pmb.aportgen.core.rewrite(args, pkgname, "main/binutils", fields,
|
||||
"binutils", replace_functions, replace_simple,
|
||||
remove_indent=8)
|
||||
"binutils", below_header=below_header)
|
||||
|
|
|
@ -2,14 +2,21 @@
|
|||
# Generator: pmbootstrap aportgen binutils-armhf
|
||||
# Based on: main/binutils
|
||||
|
||||
|
||||
CTARGET_ARCH=armhf
|
||||
CTARGET="$(arch_to_hostspec $CTARGET_ARCH)"
|
||||
|
||||
pkgname=binutils-armhf
|
||||
pkgver=2.35.2
|
||||
pkgrel=1
|
||||
pkgdesc="Tools necessary to build programs for armhf targets"
|
||||
url="https://www.gnu.org/software/binutils/"
|
||||
makedepends="gettext libtool autoconf automake bison texinfo"
|
||||
makedepends_build="bison flex texinfo"
|
||||
makedepends_host="zlib-dev"
|
||||
makedepends="$makedepends_build $makedepends_host"
|
||||
arch="x86_64"
|
||||
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
|
||||
subpackages="binutils-dev binutils-doc"
|
||||
source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
|
||||
binutils-ld-fix-static-linking.patch
|
||||
gold-mips.patch
|
||||
|
@ -20,7 +27,7 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
|
|||
builddir="$srcdir/binutils-$pkgver"
|
||||
|
||||
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
|
||||
subpackages=""
|
||||
subpackages="$subpackages binutils-gold"
|
||||
fi
|
||||
|
||||
if [ "$CHOST" != "$CTARGET" ]; then
|
||||
|
@ -41,34 +48,91 @@ fi
|
|||
# - CVE-2017-7614
|
||||
|
||||
build() {
|
||||
_target="$(arch_to_hostspec armhf)"
|
||||
"$builddir"/configure \
|
||||
--build="$CBUILD" \
|
||||
--target=$_target \
|
||||
--with-lib-path=/usr/lib \
|
||||
local _sysroot=/
|
||||
local _cross_configure="--enable-install-libiberty --enable-shared"
|
||||
local _arch_configure=""
|
||||
local _gold_configure="--disable-gold"
|
||||
|
||||
if [ "$CHOST" != "$CTARGET" ]; then
|
||||
_sysroot="$CBUILDROOT"
|
||||
_cross_configure="--disable-install-libiberty"
|
||||
fi
|
||||
|
||||
if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then
|
||||
_gold_configure="--enable-gold"
|
||||
fi
|
||||
|
||||
if [ "$CTARGET_ARCH" = "x86_64" ]; then
|
||||
_arch_configure="--enable-targets=x86_64-pep"
|
||||
fi
|
||||
|
||||
if [ "$CTARGET_ARCH" = "riscv64" ]; then
|
||||
_gold_configure="--disable-gold"
|
||||
fi
|
||||
|
||||
case "$CTARGET_ARCH" in
|
||||
mips*) _hash_style_configure="--enable-default-hash-style=sysv" ;;
|
||||
*) _hash_style_configure="--enable-default-hash-style=gnu" ;;
|
||||
esac
|
||||
|
||||
./configure \
|
||||
--build=$CBUILD \
|
||||
--host=$CHOST \
|
||||
--target=$CTARGET \
|
||||
--with-build-sysroot="$CBUILDROOT" \
|
||||
--with-sysroot=$_sysroot \
|
||||
--prefix=/usr \
|
||||
--with-sysroot=/usr/$_target \
|
||||
--enable-ld=default \
|
||||
--enable-gold=yes \
|
||||
--enable-plugins \
|
||||
--enable-deterministic-archives \
|
||||
--mandir=/usr/share/man \
|
||||
--infodir=/usr/share/info \
|
||||
--disable-multilib \
|
||||
--enable-ld=default \
|
||||
$_gold_configure \
|
||||
--enable-64-bit-bfd \
|
||||
--enable-plugins \
|
||||
--enable-relro \
|
||||
--enable-deterministic-archives \
|
||||
$_cross_configure \
|
||||
$_arch_configure \
|
||||
$_hash_style_configure \
|
||||
--with-pic \
|
||||
--disable-werror \
|
||||
--disable-nls
|
||||
--disable-nls \
|
||||
--with-mmap \
|
||||
--with-system-zlib
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
make install DESTDIR="$pkgdir"
|
||||
|
||||
# remove man, info folders
|
||||
rm -rf "$pkgdir"/usr/share
|
||||
|
||||
# remove files that conflict with non-cross binutils
|
||||
rm -rf "$pkgdir"/usr/lib/bfd-plugins
|
||||
if [ -d "$pkgdir"/usr/lib64 ]; then
|
||||
mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/
|
||||
rmdir "$pkgdir"/usr/lib64
|
||||
fi
|
||||
if [ "$CHOST" != "$CTARGET" ]; then
|
||||
# creating cross tools: remove any files that would conflict
|
||||
# with the native tools, or other cross tools
|
||||
rm -r "${pkgdir:?}"/usr/share
|
||||
rm -f "$pkgdir"/usr/lib/libiberty.a
|
||||
fi
|
||||
}
|
||||
|
||||
libs() {
|
||||
pkgdesc="Runtime libraries from binutils - libbfd and libopcodes"
|
||||
|
||||
mkdir -p "$subpkgdir"/usr/lib
|
||||
mv "$pkgdir"/usr/lib/lib*.so "$subpkgdir"/usr/lib/
|
||||
}
|
||||
|
||||
gold() {
|
||||
pkgdesc="GNU binutils - gold linker"
|
||||
|
||||
if [ -e "$pkgdir"/usr/bin/ld.gold ]; then
|
||||
mkdir -p "$subpkgdir"/usr/bin
|
||||
mv "$pkgdir"/usr/bin/ld.gold "$subpkgdir"/usr/bin
|
||||
fi
|
||||
mkdir -p "$subpkgdir"/usr/$CTARGET/bin
|
||||
mv "$pkgdir"/usr/$CTARGET/bin/ld.gold "$subpkgdir"/usr/$CTARGET/bin/ld.gold
|
||||
}
|
||||
|
||||
sha512sums="9974ede5978d32e0d68fef23da48fa00bd06b0bff7ec45b00ca075c126d6bbe0cf2defc03ecc3f17bc6cc85b64271a13009c4049d7ba17de26e84e3a6e2c0348 binutils-2.35.2.tar.xz
|
||||
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
|
||||
|
|
Loading…
Reference in New Issue