* rework cross-compilers for powerpc{,64,64le} and riscv64 to work with pacman cross wrapper prototypes

This commit is contained in:
Alexander Baldeck 2023-09-12 13:32:06 +02:00
parent 115ae77e83
commit 823cf7068e
79 changed files with 4767 additions and 1456 deletions

View File

@ -7,7 +7,7 @@ _target=powerpc-unknown-linux-gnu
pkgname=$_target-binutils
pkgver=2.41
_commit=31b78cc991781265d9404bd55151691bedd6d556
pkgrel=3
pkgrel=3.1
pkgdesc='Assemble and manipulate binary and object files for powerpc64 be'
arch=(x86_64 powerpc64le powerpc64 riscv64)
url='https://gnu.org/software/binutils/'
@ -48,11 +48,12 @@ build() {
--target=$_target \
--with-gnu-as \
--with-gnu-ld \
--with-sysroot=/usr/$_target \
--with-sysroot=/usr/$_target/usr \
--with-system-zlib \
--disable-werror \
--disable-sim \
--enable-colored-disassembly
--enable-colored-disassembly \
--enable-targets=no
make
}
@ -65,11 +66,14 @@ check() {
package() {
make -C "binutils-gdb" DESTDIR="$pkgdir" install
install -d -m755 "$pkgdir/usr/$_target/usr"
mv $pkgdir/usr/$_target/{bin,lib} "$pkgdir/usr/$_target/usr/"
# Remove info documents that conflict with host version
rm -r "$pkgdir/usr/share/info"
rm -r "$pkgdir/usr/share/gdb"
rm "$pkgdir//usr/include/gdb/jit-reader.h"
rm "$pkgdir/usr/include/gdb/jit-reader.h"
rm "$pkgdir"/usr/lib/bfd-plugins/libdep.so
}

View File

@ -1,114 +0,0 @@
From 20ea3acc727f3be6322dfbd881e506873535231d Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 11 Feb 2022 15:13:19 -0800
Subject: [PATCH] ld: Keep indirect symbol from IR if referenced from shared
object
Don't change indirect symbol defined in IR to undefined if it is
referenced from shared object.
bfd/
PR ld/28879
* elflink.c (_bfd_elf_merge_symbol): Don't change indirect
symbol defined in IR to undefined if it is referenced from
shared object.
ld/
PR ld/28879
* testsuite/ld-plugin/lto.exp: Run PR ld/28879 tests.
* testsuite/ld-plugin/pr28879a.cc: New file.
* testsuite/ld-plugin/pr28879b.cc: Likewise.
---
bfd/elflink.c | 5 ++---
ld/testsuite/ld-plugin/lto.exp | 26 ++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28879a.cc | 7 +++++++
ld/testsuite/ld-plugin/pr28879b.cc | 8 ++++++++
4 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 ld/testsuite/ld-plugin/pr28879a.cc
create mode 100644 ld/testsuite/ld-plugin/pr28879b.cc
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 6fa18d92007..f8521426cad 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1294,9 +1294,8 @@ _bfd_elf_merge_symbol (bfd *abfd,
h->root.non_ir_ref_dynamic = true;
hi->root.non_ir_ref_dynamic = true;
}
-
- if ((oldbfd->flags & BFD_PLUGIN) != 0
- && hi->root.type == bfd_link_hash_indirect)
+ else if ((oldbfd->flags & BFD_PLUGIN) != 0
+ && hi->root.type == bfd_link_hash_indirect)
{
/* Change indirect symbol from IR to undefined. */
hi->root.type = bfd_link_hash_undefined;
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index a70a84562b8..64b880265ee 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -471,6 +471,32 @@ set lto_link_elf_tests [list \
[list {pr27441c.so} \
{-shared -fPIC -Wl,--as-needed tmpdir/pr27441c.o tmpdir/pr27441b.so tmpdir/pr27441a.so} {-fPIC} \
{dummy.c} {{readelf {-dW} pr27441c.d}} {pr27441c.so}] \
+ [list \
+ "Build libpr28879a.so" \
+ "-shared" \
+ "-O0 -fpic" \
+ {pr28879a.cc} \
+ {} \
+ "libpr28879a.so" \
+ "c++" \
+ ] \
+ [list \
+ "Build libpr28879b.so" \
+ "-shared -Wl,--no-as-needed tmpdir/libpr28879a.so" \
+ "-O2 -fpic" \
+ {dummy.c} \
+ {} \
+ "libpr28879b.so" \
+ ] \
+ [list \
+ "Build pr28879" \
+ "-Wl,--no-as-needed tmpdir/libpr28879b.so -Wl,-rpath-link,." \
+ "-O0 -flto -D_GLIBCXX_ASSERTIONS" \
+ {pr28879b.cc} \
+ {} \
+ "pr28879" \
+ "c++" \
+ ] \
]
# PR 14918 checks that libgcc is not spuriously included in a shared link of
diff --git a/ld/testsuite/ld-plugin/pr28879a.cc b/ld/testsuite/ld-plugin/pr28879a.cc
new file mode 100644
index 00000000000..8307a42e2fb
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28879a.cc
@@ -0,0 +1,7 @@
+#include <string>
+
+void
+func (std::string *s)
+{
+ delete s;
+}
diff --git a/ld/testsuite/ld-plugin/pr28879b.cc b/ld/testsuite/ld-plugin/pr28879b.cc
new file mode 100644
index 00000000000..02fc351366c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28879b.cc
@@ -0,0 +1,8 @@
+#include <string>
+
+int
+main (void)
+{
+ std::string header;
+ return 0;
+}
--
2.35.1

View File

@ -11,7 +11,7 @@ pkgname=${_target}-gcc-stage2
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.1
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 2 for toolchain building (${_target})"
arch=(x86_64 powerpc64le powerpc64 riscv64)
license=(GPL LGPL FDL custom)
@ -22,12 +22,14 @@ options=(!emptydirs !strip)
conflicts=("${_target}-gcc-stage1")
replaces=("${_target}-gcc-stage1")
provides=("${_target}-gcc-stage1=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -39,6 +41,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -11,7 +11,7 @@ pkgname="${_target}-gcc"
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.1
pkgrel=3.2
pkgdesc="The GNU Compiler Collection (${_target})"
arch=(x86_64 powerpc64le powerpc64 riscv64)
license=(GPL LGPL FDL custom)
@ -23,12 +23,14 @@ options=(!emptydirs !distcc !strip)
conflicts=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
replaces=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
provides=("${_target}-gcc-stage1=${pkgver}" "${_target}-gcc-stage2=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -40,6 +42,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -106,4 +111,7 @@ package() {
strip "$pkgdir/usr/bin/"* 2>/dev/null || true
find "$pkgdir/usr/lib" -type f -exec /usr/bin/${_target}-strip \
--strip-unneeded {} \; 2>/dev/null || true
install -d -m 755 "$pkgdir/usr/$_target/usr/lib"
mv "$pkgdir/usr/$_target/lib" "$pkgdir/usr/$_target/usr/"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -10,7 +10,7 @@ _target=powerpc-unknown-linux-gnu
pkgname=${_target}-glibc-headers
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3
pkgrel=3.1
pkgdesc="GNU C Library headers (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
@ -45,8 +45,8 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
@ -64,10 +64,10 @@ build() {
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -79,8 +79,8 @@ build() {
export RANLIB=${_target}-ranlib
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
@ -88,10 +88,6 @@ build() {
# make some libs and stubs
make csu/subdir_lib
case "${CARCH}" in
powerpc64) sed 's@RTLDLIST=.*@RTLDLIST="/usr/lib/ld64.so.2"@g' -i ${pkgdir}/usr/bin/ldd ;;
esac
}
package() {
@ -102,15 +98,14 @@ package() {
# glibc doesn't support eglibc's install-bootstrap-headers
# Luckily a blank gnu/stubs.h is all we need
touch "$pkgdir/usr/$_target/include/gnu/stubs.h"
touch "$pkgdir/usr/$_target/usr/include/gnu/stubs.h"
mkdir -p "$pkgdir/usr/$_target/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/lib"
mkdir -p "$pkgdir/usr/$_target/usr/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/usr/lib"
# create stub lib
${_target}-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
-o "$pkgdir/usr/$_target/lib/libc.so"
-o "$pkgdir/usr/$_target/usr/lib/libc.so"
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
}

View File

@ -1,22 +0,0 @@
diff --git a/sysdeps/unix/sysv/linux/clone-internal.c b/sysdeps/unix/sysv/linux/clone-internal.c
index 1e7a8f6b35..4046c81180 100644
--- a/sysdeps/unix/sysv/linux/clone-internal.c
+++ b/sysdeps/unix/sysv/linux/clone-internal.c
@@ -48,17 +48,6 @@ __clone_internal (struct clone_args *cl_args,
int (*func) (void *arg), void *arg)
{
int ret;
-#ifdef HAVE_CLONE3_WRAPPER
- /* Try clone3 first. */
- int saved_errno = errno;
- ret = __clone3 (cl_args, sizeof (*cl_args), func, arg);
- if (ret != -1 || errno != ENOSYS)
- return ret;
-
- /* NB: Restore errno since errno may be checked against non-zero
- return value. */
- __set_errno (saved_errno);
-#endif
/* Map clone3 arguments to clone arguments. NB: No need to check
invalid clone3 specific bits in flags nor exit_signal since this

View File

@ -1,145 +0,0 @@
From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 29 Apr 2022 16:37:51 +0200
Subject: [PATCH] Do not use --hash-style=both for building glibc shared
objects
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
Makeconfig | 9 +++++++++
Makerules | 7 +++++++
config.make.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
diff --git b/Makeconfig a/Makeconfig
index 760f14e92f..0aa5fb0099 100644
--- b/Makeconfig
+++ a/Makeconfig
@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
ifeq (no,$(build-pie-default))
pie-default = $(no-pie-ccflag)
else # build-pie-default
diff --git b/Makerules a/Makerules
index 354528b8c7..428464f092 100644
--- b/Makerules
+++ a/Makerules
@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
-Wl,--verbose 2>/dev/null | \
sed > $@T \
-e '/^=========/,/^=========/!d;/^=========/d' \
+ $(if $(filter yes,$(have-hash-style)), \
+ -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
+ -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+ , \
+ -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ ) \
-e 's/^.*\*(\.dynbss).*$$/& \
PROVIDE(__start___libc_freeres_ptrs = .); \
*(__libc_freeres_ptrs) \
diff --git b/config.make.in a/config.make.in
index fff4c78dd0..bf728c71c0 100644
--- b/config.make.in
+++ a/config.make.in
@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
+have-hash-style = @libc_cv_hashstyle@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
have-loop-to-function = @libc_cv_cc_loop_to_function@
diff --git b/configure a/configure
index 716dc041b6..5a730dc5fc 100755
--- b/configure
+++ a/configure
@@ -622,6 +622,7 @@ libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
fno_unit_at_a_time
libc_cv_has_glob_dat
+libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
ASFLAGS_config
@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
+$as_echo_n "checking for --hash-style option... " >&6; }
+if ${libc_cv_hashstyle+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
+$as_echo "$libc_cv_hashstyle" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
if ${libc_cv_has_glob_dat+:} false; then :
diff --git b/configure.ac a/configure.ac
index d08ad4d64e..a045f6608e 100644
--- b/configure.ac
+++ a/configure.ac
@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for --hash-style option,
+ libc_cv_hashstyle, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_hashstyle)
+
AC_CACHE_CHECK(for GLOB_DAT reloc,
libc_cv_has_glob_dat, [dnl
cat > conftest.c <<EOF
--
2.37.1

View File

@ -10,7 +10,7 @@
_target=powerpc-unknown-linux-gnu
pkgname=${_target}-libxcrypt
pkgver=4.4.36
pkgrel=1
pkgrel=1.1
pkgdesc='Modern library for one-way hashing of passwords'
arch=(any)
url='https://github.com/besser82/libxcrypt'
@ -34,7 +34,7 @@ build() {
cd "${srcdir}/build-libxcrypt/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr/${_target}/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
@ -46,7 +46,7 @@ build() {
cd "${srcdir}/build-libxcrypt-compat/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr/${_target}/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \

View File

@ -10,7 +10,7 @@ _target_arch=powerpc
_target=${_target_arch}-unknown-linux-gnu
pkgname=${_target}-linux-api-headers
pkgver=6.4
pkgrel=1
pkgrel=2
pkgdesc="Kernel headers sanitized for use in userspace (${_target})"
arch=(any)
url='http://www.gnu.org/software/libc'
@ -29,10 +29,10 @@ build() {
package() {
cd linux-${pkgver}
make INSTALL_HDR_PATH="$pkgdir/usr/$_target" ARCH=powerpc headers_install
make INSTALL_HDR_PATH="$pkgdir/usr/$_target/usr" ARCH=powerpc headers_install
# use headers from libdrm
rm -rf "$pkgdir/usr/$_target/include/drm"
rm -rf "$pkgdir/usr/$_target/usr/include/drm"
# clean-up unnecessary files generated during install
find ${pkgdir} \( -name .install -o -name ..install.cmd \) -delete

View File

@ -0,0 +1,58 @@
# Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
_arch=powerpc
_target=${_arch}-unknown-linux-gnu
pkgname=${_target}-pacman
pkgver=2023.09
pkgrel=1
pkgdesc="Pacman configurations for ${_target} to install dependencies for cross-compilation"
arch=(any)
url="https://archlinuxpower.org"
depends=(
${_target}-gcc
${_target}-glibc
)
source=(pacman-arch.sh
pacman.conf
fakebase.desc)
backup=(etc/pacman-${_arch}.conf)
sha256sums=('5fd18c74198312560579d900af2b0e52b757b47fb70e4f78e995b29cf0b5ee7a'
'6be22d041e30ca7475d7700ff35b4ca34ad62f3ad415b8f429edbbc03c295d0e'
'c7d16160e0d91becce572abee7954e61411c729eec7a367a96335fba6bc470f1')
prepare() {
if [ -d /usr/${_target}/var/lib/pacman ]; then
echo "Remove existing synced dbs etc from /usr/${_target}/var/lib/pacman/ and try again"
exit 1
fi
}
build() {
sed "s/@@CARCH@@/${_arch}/g" -i pacman-arch.sh
sed "s/@@CHOST_PREFIX@@/\/usr\/${_target}\//g" -i pacman.conf
sed "s/@@TIMESTAMP@@/$(date "+%s")/g" -i fakebase.desc
sed "s/@@FAKEBASE_VERSION@@/${pkgver}-${pkgrel}/g" -i fakebase.desc
}
package() {
install -d -m755 ${pkgdir}/usr/bin
install -m755 ${srcdir}/pacman-arch.sh ${pkgdir}/usr/bin/pacman-${_arch}
install -d -m 755 ${pkgdir}/etc
install -m644 ${srcdir}/pacman.conf ${pkgdir}/etc/pacman-${_arch}.conf
# fake that we install a few basic packages via pacman
install -d -m 755 ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}
pushd /usr/${_target}/
shopt -s dotglob globstar
printf '%s\0' **/* | LANG=C bsdtar -cnf - --format=mtree --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' --null --files-from - --exclude .MTREE | gzip -c -f -n > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/mtree
shopt -u dotglob globstar
echo '%FILES%' > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
find | sed 's@^./@@g' | grep -v '^\.$' | grep -v '.*mtree$' >> ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
echo 9 > ${pkgdir}/usr/${_target}/var/lib/pacman/local/ALPM_DB_VERSION
install -m644 ${srcdir}/fakebase.desc ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/desc
popd
}

View File

@ -0,0 +1,42 @@
%NAME%
fakebase
%VERSION%
@@FAKEBASE_VERSION@@
%DESC%
Masking that some packages from crosscompilers on the host
%URL%
https://archlinuxpower.org
%ARCH%
any
%BUILDDATE%
@@TIMESTAMP@@
%INSTALLDATE%
@@TIMESTAMP@@
%PACKAGER%
Alexander Baldeck <alex.bldck@gmail.com>
%SIZE%
10
%LICENSE%
GPL
%VALIDATION%
sha256
%PROVIDES%
binutils
filesystem
gcc
gcc-libs
glibc
libxcrypt
linux-api-headers
zlib

View File

@ -0,0 +1,141 @@
%FILES%
bin
boot/
dev/
etc/
etc/arch-release
etc/crypttab
etc/fstab
etc/group
etc/gshadow
etc/host.conf
etc/hosts
etc/issue
etc/ld.so.conf
etc/ld.so.conf.d/
etc/mtab
etc/nsswitch.conf
etc/passwd
etc/profile
etc/profile.d/
etc/profile.d/locale.sh
etc/resolv.conf
etc/securetty
etc/shadow
etc/shells
etc/skel/
etc/subgid
etc/subuid
home/
lib
lib64
mnt/
opt/
proc/
root/
run/
sbin
srv/
srv/ftp/
srv/http/
sys/
tmp/
usr/
usr/bin/
usr/include/
usr/lib/
usr/lib/os-release
usr/lib/sysctl.d/
usr/lib/sysctl.d/10-arch.conf
usr/lib/systemd/
usr/lib/systemd/system-environment-generators/
usr/lib/systemd/system-environment-generators/10-arch
usr/lib/sysusers.d/
usr/lib/sysusers.d/arch.conf
usr/lib/tmpfiles.d/
usr/lib/tmpfiles.d/arch.conf
usr/lib64
usr/local/
usr/local/bin/
usr/local/etc/
usr/local/games/
usr/local/include/
usr/local/lib/
usr/local/man/
usr/local/sbin/
usr/local/share/
usr/local/share/man
usr/local/src/
usr/sbin
usr/share/
usr/share/factory/
usr/share/factory/etc/
usr/share/factory/etc/crypttab
usr/share/factory/etc/fstab
usr/share/factory/etc/group
usr/share/factory/etc/gshadow
usr/share/factory/etc/host.conf
usr/share/factory/etc/hosts
usr/share/factory/etc/issue
usr/share/factory/etc/ld.so.conf
usr/share/factory/etc/nsswitch.conf
usr/share/factory/etc/passwd
usr/share/factory/etc/profile
usr/share/factory/etc/resolv.conf
usr/share/factory/etc/securetty
usr/share/factory/etc/shadow
usr/share/factory/etc/shells
usr/share/factory/etc/subgid
usr/share/factory/etc/subuid
usr/share/man/
usr/share/man/man1/
usr/share/man/man2/
usr/share/man/man3/
usr/share/man/man4/
usr/share/man/man5/
usr/share/man/man6/
usr/share/man/man7/
usr/share/man/man8/
usr/share/misc/
usr/share/pixmaps/
usr/share/pixmaps/archlinux-logo-text-dark.svg
usr/share/pixmaps/archlinux-logo-text.svg
usr/share/pixmaps/archlinux-logo.png
usr/share/pixmaps/archlinux-logo.svg
usr/src/
var/
var/cache/
var/empty/
var/games/
var/lib/
var/lib/misc/
var/local/
var/lock
var/log/
var/log/old/
var/mail
var/opt/
var/run
var/spool/
var/spool/mail/
var/tmp/
%BACKUP%
etc/crypttab 5fa6674df7645d7f5895f2d12b4ef4e9
etc/fstab e33f6dfdd61978fcb3ddf1431286e05a
etc/group 7fed1e1fb855e41a6d64d41f8521d69a
etc/gshadow 1c1e3b08acfa286f4b417c49de3e4366
etc/host.conf 7d119a9cce152aa182fb3392ddeecea7
etc/hosts a1315ea3e2b64d197b6efaf9c14ff778
etc/issue f36195a7ed232b8520a68a867f166a3b
etc/ld.so.conf 5deb9f890a4d08a245e9752ede77271e
etc/nsswitch.conf a3de66d416718325442f739d6c1d4e50
etc/passwd 5182ac38a0de85da8ade93ef71975ca4
etc/profile 448fe7cbcb566e8d318dc0db0c9cb710
etc/resolv.conf 0ee015fad07732676d9488ae498eed41
etc/securetty f04bcb2803afc4dcb95670fe87343b4d
etc/shadow 815652599be54fd3607cf276e89a0a19
etc/shells 8fe5095f1116c2c61b4608c4840063a2
etc/subuid d41d8cd98f00b204e9800998ecf8427e
etc/subgid d41d8cd98f00b204e9800998ecf8427e

View File

@ -0,0 +1,3 @@
#!/bin/sh
pacman --config /etc/pacman-@@CARCH@@.conf $@

View File

@ -0,0 +1,96 @@
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
RootDir = @@CHOST_PREFIX@@
DBPath = @@CHOST_PREFIX@@/var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = powerpc
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
#Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
#ParallelDownloads = 5
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[repo-local-any]
SigLevel = Never
Server = http://172.23.23.10/repo/any
[repo-local]
SigLevel = Never
Server = http://172.23.23.10/repo/$arch
[testing-any]
Server = https://repo.archlinuxpower.org/testing/any
[testing]
Server = https://repo.archlinuxpower.org/testing/$arch
[base-any]
Server = https://repo.archlinuxpower.org/base/any
[base]
Server = https://repo.archlinuxpower.org/base/$arch
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

View File

@ -7,12 +7,11 @@ _target=powerpc64-unknown-linux-gnu
pkgname=$_target-binutils
pkgver=2.41
_commit=31b78cc991781265d9404bd55151691bedd6d556
pkgrel=3
pkgdesc='Assemble and manipulate binary and object files for powerpc64 be'
pkgrel=3.1
pkgdesc='Assemble and manipulate binary and object files for riscv64'
arch=(x86_64 powerpc64le powerpc riscv64)
url='https://gnu.org/software/binutils/'
license=(GPL)
groups=(risc-v)
depends=(glibc zlib libelf jansson)
makedepends=(git setconf)
source=(git+https://sourceware.org/git/binutils-gdb.git#commit=${_commit}
@ -22,7 +21,7 @@ sha512sums=('SKIP'
prepare() {
cd ${srcdir}
[[ ! -d binutils-gdb ]] && ln -s binutils-$pkgver binutils-gdb
[[ ! -d binutils-gdb ]] && ln -s binutils-$pkgver binutils-gdb
cd "binutils-gdb"
# Creds @Fedora
@ -49,11 +48,12 @@ build() {
--target=$_target \
--with-gnu-as \
--with-gnu-ld \
--with-sysroot=/usr/$_target \
--with-sysroot=/usr/$_target/usr \
--with-system-zlib \
--disable-werror \
--disable-sim \
--enable-colored-disassembly
--enable-colored-disassembly \
--enable-targets=no
make
}
@ -66,10 +66,13 @@ check() {
package() {
make -C "binutils-gdb" DESTDIR="$pkgdir" install
install -d -m755 "$pkgdir/usr/$_target/usr"
mv $pkgdir/usr/$_target/{bin,lib} "$pkgdir/usr/$_target/usr/"
# Remove info documents that conflict with host version
rm -r "$pkgdir/usr/share/info"
rm -r "$pkgdir/usr/share/gdb"
rm "$pkgdir//usr/include/gdb/jit-reader.h"
rm "$pkgdir/usr/include/gdb/jit-reader.h"
rm "$pkgdir"/usr/lib/bfd-plugins/libdep.so
}

View File

@ -9,16 +9,16 @@
_target=powerpc64-unknown-linux-gnu
pkgname=${_target}-gcc-stage1
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 1 for toolchain building (${_target})"
arch=(x86_64 powerpc64le powerpc riscv64)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=(${_target}-binutils libmpc zlib libisl)
makedepends=(git)
options=(!emptydirs !distcc !strip)
options=(!emptydirs !strip)
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
@ -37,6 +37,7 @@ prepare() {
# Arch Linux installs x86_64 libraries /lib
sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
sed -i 's@/lib64@/lib@g' gcc/config/rs6000/t-*
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
@ -61,7 +62,7 @@ build() {
--program-prefix=${_target}- \
--with-local-prefix=/usr/${_target} \
--with-sysroot=/usr/${_target} \
--with-build-sysroot=/usr/${_target} \
--with-build-sysroot=/usr/${_target}/usr \
--with-as=/usr/bin/${_target}-as \
--with-ld=/usr/bin/${_target}-ld \
--libdir=/usr/lib \
@ -92,8 +93,8 @@ build() {
--target=${_target} \
--host=${CHOST} \
--build=${CHOST} \
--with-abi=elfv2 \
--enable-secureplt
--enable-secureplt \
--with-abi=elfv2
make STAGE1_CFLAGS="-O2" all-gcc all-target-libgcc
}

View File

@ -9,25 +9,27 @@
_target=powerpc64-unknown-linux-gnu
pkgname=${_target}-gcc-stage2
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 2 for toolchain building (${_target})"
arch=(x86_64 powerpc64le powerpc riscv64)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=("${_target}-binutils>=2.40-1" "${_target}-glibc-headers>=2.37-3" libmpc zlib)
depends=("${_target}-binutils>=2.41" "${_target}-glibc-headers>=2.38" libmpc zlib)
makedepends=(git)
options=(!emptydirs !distcc !strip)
options=(!emptydirs !strip)
conflicts=("${_target}-gcc-stage1")
replaces=("${_target}-gcc-stage1")
provides=("${_target}-gcc-stage1=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -39,6 +41,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -9,9 +9,9 @@
_target=powerpc64-unknown-linux-gnu
pkgname="${_target}-gcc"
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection (${_target})"
arch=(x86_64 powerpc64le powerpc riscv64)
license=(GPL LGPL FDL custom)
@ -23,12 +23,14 @@ options=(!emptydirs !distcc !strip)
conflicts=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
replaces=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
provides=("${_target}-gcc-stage1=${pkgver}" "${_target}-gcc-stage2=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -40,6 +42,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -86,9 +91,9 @@ build() {
--target=${_target} \
--host=${CHOST} \
--build=${CHOST} \
--with-abi=elfv2 \
--with-build-config=bootstrap-lto \
--enable-link-serialization=1 \
--with-abi=elfv2 \
--enable-secureplt
make STAGE1_CFLAGS="${CFLAGS}" STAGE2_CFLAGS="${CFLAGS}"
@ -106,4 +111,7 @@ package() {
strip "$pkgdir/usr/bin/"* 2>/dev/null || true
find "$pkgdir/usr/lib" -type f -exec /usr/bin/${_target}-strip \
--strip-unneeded {} \; 2>/dev/null || true
install -d -m 755 "$pkgdir/usr/$_target/usr/lib"
mv "$pkgdir/usr/$_target/lib" "$pkgdir/usr/$_target/usr/"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -10,22 +10,28 @@ _target=powerpc64-unknown-linux-gnu
pkgname=${_target}-glibc-headers
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3
pkgrel=3.1
pkgdesc="GNU C Library headers (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=6.3")
makedepends=("${_target}-gcc-stage1>=13.1.1" "python" "git")
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage1>=13.2.1" python git)
options=(!buildflags !strip staticlibs)
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
sdt.h)
sdt.h
fix-malloc-p1.patch
fix-malloc-p2.patch
reenable_DT_HASH.patch)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
sha256sums=('SKIP'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70')
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'1e22a2226fe308154e70981c0036c7c4ebac488b26b9959cb803d7a3d831d0c4'
'59f37c6f3a27e08d846c1dcb0ac08c1aebb14c11afb9be10652ca1a80fd54c3e'
'cf9fe494f7ec69752a63d1b0a9ad689aa620888ae9b902b6383a6fbc7c1726a7')
prepare() {
mkdir -p glibc-build
@ -45,8 +51,8 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
@ -59,15 +65,16 @@ build() {
case "${CARCH}" in
x86_64) _configure_flags+=(--enable-cet --enable-multi-arch) ;;
powerpc64) _configure_flags+=(--disable-multi-arch --with-cpu=970); CFLAGS='-O2 -pipe' ;;
*) _configure_flags+=(--disable-multi-arch); CFLAGS='-O2 -pipe' ;;
esac
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -77,10 +84,12 @@ build() {
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
export OBJCOPY=${_target}-objcopy
export OBJDUMP=${_target}-objdump
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
@ -102,15 +111,19 @@ package() {
# glibc doesn't support eglibc's install-bootstrap-headers
# Luckily a blank gnu/stubs.h is all we need
touch "$pkgdir/usr/$_target/include/gnu/stubs.h"
touch "$pkgdir/usr/$_target/usr/include/gnu/stubs.h"
mkdir -p "$pkgdir/usr/$_target/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/lib"
mkdir -p "$pkgdir/usr/$_target/usr/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/usr/lib"
# create stub lib
${_target}-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
-o "$pkgdir/usr/$_target/lib/libc.so"
-o "$pkgdir/usr/$_target/usr/lib/libc.so"
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -1,22 +0,0 @@
diff --git a/sysdeps/unix/sysv/linux/clone-internal.c b/sysdeps/unix/sysv/linux/clone-internal.c
index 1e7a8f6b35..4046c81180 100644
--- a/sysdeps/unix/sysv/linux/clone-internal.c
+++ b/sysdeps/unix/sysv/linux/clone-internal.c
@@ -48,17 +48,6 @@ __clone_internal (struct clone_args *cl_args,
int (*func) (void *arg), void *arg)
{
int ret;
-#ifdef HAVE_CLONE3_WRAPPER
- /* Try clone3 first. */
- int saved_errno = errno;
- ret = __clone3 (cl_args, sizeof (*cl_args), func, arg);
- if (ret != -1 || errno != ENOSYS)
- return ret;
-
- /* NB: Restore errno since errno may be checked against non-zero
- return value. */
- __set_errno (saved_errno);
-#endif
/* Map clone3 arguments to clone arguments. NB: No need to check
invalid clone3 specific bits in flags nor exit_signal since this

View File

@ -0,0 +1,294 @@
commit 542b1105852568c3ebc712225ae78b8c8ba31a78
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 11 11:18:17 2023 +0200
malloc: Enable merging of remainders in memalign (bug 30723)
Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator. This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.
Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own. We can still give it back if it can be merged
with the following unused chunk. This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.
Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e2f1a615a4..948f9759af 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1086,6 +1086,11 @@ typedef struct malloc_chunk* mchunkptr;
static void* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr, int);
+static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
+static INTERNAL_SIZE_T _int_free_create_chunk (mstate,
+ mchunkptr, INTERNAL_SIZE_T,
+ mchunkptr, INTERNAL_SIZE_T);
+static void _int_free_maybe_consolidate (mstate, INTERNAL_SIZE_T);
static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
INTERNAL_SIZE_T);
static void* _int_memalign(mstate, size_t, size_t);
@@ -4637,31 +4642,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (!have_lock)
__libc_lock_lock (av->mutex);
- nextchunk = chunk_at_offset(p, size);
-
- /* Lightweight tests: check whether the block is already the
- top block. */
- if (__glibc_unlikely (p == av->top))
- malloc_printerr ("double free or corruption (top)");
- /* Or whether the next chunk is beyond the boundaries of the arena. */
- if (__builtin_expect (contiguous (av)
- && (char *) nextchunk
- >= ((char *) av->top + chunksize(av->top)), 0))
- malloc_printerr ("double free or corruption (out)");
- /* Or whether the block is actually not marked used. */
- if (__glibc_unlikely (!prev_inuse(nextchunk)))
- malloc_printerr ("double free or corruption (!prev)");
-
- nextsize = chunksize(nextchunk);
- if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
- || __builtin_expect (nextsize >= av->system_mem, 0))
- malloc_printerr ("free(): invalid next size (normal)");
+ _int_free_merge_chunk (av, p, size);
- free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
+ if (!have_lock)
+ __libc_lock_unlock (av->mutex);
+ }
+ /*
+ If the chunk was allocated via mmap, release via munmap().
+ */
+
+ else {
+ munmap_chunk (p);
+ }
+}
+
+/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
+ resulting chunk on the appropriate bin list. P must not be on a
+ bin list yet, and it can be in use. */
+static void
+_int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
+{
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+
+ /* Lightweight tests: check whether the block is already the
+ top block. */
+ if (__glibc_unlikely (p == av->top))
+ malloc_printerr ("double free or corruption (top)");
+ /* Or whether the next chunk is beyond the boundaries of the arena. */
+ if (__builtin_expect (contiguous (av)
+ && (char *) nextchunk
+ >= ((char *) av->top + chunksize(av->top)), 0))
+ malloc_printerr ("double free or corruption (out)");
+ /* Or whether the block is actually not marked used. */
+ if (__glibc_unlikely (!prev_inuse(nextchunk)))
+ malloc_printerr ("double free or corruption (!prev)");
+
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
+ || __builtin_expect (nextsize >= av->system_mem, 0))
+ malloc_printerr ("free(): invalid next size (normal)");
+
+ free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
- /* consolidate backward */
- if (!prev_inuse(p)) {
- prevsize = prev_size (p);
+ /* Consolidate backward. */
+ if (!prev_inuse(p))
+ {
+ INTERNAL_SIZE_T prevsize = prev_size (p);
size += prevsize;
p = chunk_at_offset(p, -((long) prevsize));
if (__glibc_unlikely (chunksize(p) != prevsize))
@@ -4669,9 +4695,25 @@ _int_free (mstate av, mchunkptr p, int have_lock)
unlink_chunk (av, p);
}
- if (nextchunk != av->top) {
+ /* Write the chunk header, maybe after merging with the following chunk. */
+ size = _int_free_create_chunk (av, p, size, nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, size);
+}
+
+/* Create a chunk at P of SIZE bytes, with SIZE potentially increased
+ to cover the immediately following chunk NEXTCHUNK of NEXTSIZE
+ bytes (if NEXTCHUNK is unused). The chunk at P is not actually
+ read and does not have to be initialized. After creation, it is
+ placed on the appropriate bin list. The function returns the size
+ of the new chunk. */
+static INTERNAL_SIZE_T
+_int_free_create_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size,
+ mchunkptr nextchunk, INTERNAL_SIZE_T nextsize)
+{
+ if (nextchunk != av->top)
+ {
/* get and clear inuse bit */
- nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
+ bool nextinuse = inuse_bit_at_offset (nextchunk, nextsize);
/* consolidate forward */
if (!nextinuse) {
@@ -4686,8 +4728,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
been given one chance to be used in malloc.
*/
- bck = unsorted_chunks(av);
- fwd = bck->fd;
+ mchunkptr bck = unsorted_chunks (av);
+ mchunkptr fwd = bck->fd;
if (__glibc_unlikely (fwd->bk != bck))
malloc_printerr ("free(): corrupted unsorted chunks");
p->fd = fwd;
@@ -4706,61 +4748,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
check_free_chunk(av, p);
}
- /*
- If the chunk borders the current high end of memory,
- consolidate into top
- */
-
- else {
+ else
+ {
+ /* If the chunk borders the current high end of memory,
+ consolidate into top. */
size += nextsize;
set_head(p, size | PREV_INUSE);
av->top = p;
check_chunk(av, p);
}
- /*
- If freeing a large space, consolidate possibly-surrounding
- chunks. Then, if the total unused topmost memory exceeds trim
- threshold, ask malloc_trim to reduce top.
-
- Unless max_fast is 0, we don't know if there are fastbins
- bordering top, so we cannot tell for sure whether threshold
- has been reached unless fastbins are consolidated. But we
- don't want to consolidate on each free. As a compromise,
- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD
- is reached.
- */
+ return size;
+}
- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
+/* If freeing a large space, consolidate possibly-surrounding
+ chunks. Then, if the total unused topmost memory exceeds trim
+ threshold, ask malloc_trim to reduce top. */
+static void
+_int_free_maybe_consolidate (mstate av, INTERNAL_SIZE_T size)
+{
+ /* Unless max_fast is 0, we don't know if there are fastbins
+ bordering top, so we cannot tell for sure whether threshold has
+ been reached unless fastbins are consolidated. But we don't want
+ to consolidate on each free. As a compromise, consolidation is
+ performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */
+ if (size >= FASTBIN_CONSOLIDATION_THRESHOLD)
+ {
if (atomic_load_relaxed (&av->have_fastchunks))
malloc_consolidate(av);
- if (av == &main_arena) {
+ if (av == &main_arena)
+ {
#ifndef MORECORE_CANNOT_TRIM
- if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ if (chunksize (av->top) >= mp_.trim_threshold)
+ systrim (mp_.top_pad, av);
#endif
- } else {
- /* Always try heap_trim(), even if the top chunk is not
- large, because the corresponding heap might go away. */
- heap_info *heap = heap_for_ptr(top(av));
+ }
+ else
+ {
+ /* Always try heap_trim, even if the top chunk is not large,
+ because the corresponding heap might go away. */
+ heap_info *heap = heap_for_ptr (top (av));
- assert(heap->ar_ptr == av);
- heap_trim(heap, mp_.top_pad);
- }
+ assert (heap->ar_ptr == av);
+ heap_trim (heap, mp_.top_pad);
+ }
}
-
- if (!have_lock)
- __libc_lock_unlock (av->mutex);
- }
- /*
- If the chunk was allocated via mmap, release via munmap().
- */
-
- else {
- munmap_chunk (p);
- }
}
/*
@@ -5221,7 +5254,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
(av != &main_arena ? NON_MAIN_ARENA : 0));
set_inuse_bit_at_offset (newp, newsize);
set_head_size (p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0));
- _int_free (av, p, 1);
+ _int_free_merge_chunk (av, p, leadsize);
p = newp;
assert (newsize >= nb &&
@@ -5232,15 +5265,27 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
if (!chunk_is_mmapped (p))
{
size = chunksize (p);
- if ((unsigned long) (size) > (unsigned long) (nb + MINSIZE))
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (size > nb)
{
remainder_size = size - nb;
- remainder = chunk_at_offset (p, nb);
- set_head (remainder, remainder_size | PREV_INUSE |
- (av != &main_arena ? NON_MAIN_ARENA : 0));
- set_head_size (p, nb);
- _int_free (av, remainder, 1);
- }
+ if (remainder_size >= MINSIZE
+ || nextchunk == av->top
+ || !inuse_bit_at_offset (nextchunk, nextsize))
+ {
+ /* We can only give back the tail if it is larger than
+ MINSIZE, or if the following chunk is unused (top
+ chunk or unused in-heap chunk). Otherwise we would
+ create a chunk that is smaller than MINSIZE. */
+ remainder = chunk_at_offset (p, nb);
+ set_head_size (p, nb);
+ remainder_size = _int_free_create_chunk (av, remainder,
+ remainder_size,
+ nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, remainder_size);
+ }
+ }
}
check_inuse_chunk (av, p);

View File

@ -0,0 +1,249 @@
commit 0dc7fc1cf094406a138e4d1bcf9553e59edcf89d
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Aug 10 19:36:56 2023 +0200
malloc: Remove bin scanning from memalign (bug 30723)
On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%). The tcache
scanning has about 50% success rate, so keep that.
Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests. Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.
Remove leftover variables from _int_free from refactoring in the
same commit.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 948f9759af..d0bbbf3710 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4488,12 +4488,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
{
INTERNAL_SIZE_T size; /* its size */
mfastbinptr *fb; /* associated fastbin */
- mchunkptr nextchunk; /* next contiguous chunk */
- INTERNAL_SIZE_T nextsize; /* its size */
- int nextinuse; /* true if nextchunk is used */
- INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr fwd; /* misc temp for linking */
size = chunksize (p);
@@ -5032,42 +5026,6 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
------------------------------ memalign ------------------------------
*/
-/* Returns 0 if the chunk is not and does not contain the requested
- aligned sub-chunk, else returns the amount of "waste" from
- trimming. NB is the *chunk* byte size, not the user byte
- size. */
-static size_t
-chunk_ok_for_memalign (mchunkptr p, size_t alignment, size_t nb)
-{
- void *m = chunk2mem (p);
- INTERNAL_SIZE_T size = chunksize (p);
- void *aligned_m = m;
-
- if (__glibc_unlikely (misaligned_chunk (p)))
- malloc_printerr ("_int_memalign(): unaligned chunk detected");
-
- aligned_m = PTR_ALIGN_UP (m, alignment);
-
- INTERNAL_SIZE_T front_extra = (intptr_t) aligned_m - (intptr_t) m;
-
- /* We can't trim off the front as it's too small. */
- if (front_extra > 0 && front_extra < MINSIZE)
- return 0;
-
- /* If it's a perfect fit, it's an exception to the return value rule
- (we would return zero waste, which looks like "not usable"), so
- handle it here by returning a small non-zero value instead. */
- if (size == nb && front_extra == 0)
- return 1;
-
- /* If the block we need fits in the chunk, calculate total waste. */
- if (size > nb + front_extra)
- return size - nb;
-
- /* Can't use this chunk. */
- return 0;
-}
-
/* BYTES is user requested bytes, not requested chunksize bytes. */
static void *
_int_memalign (mstate av, size_t alignment, size_t bytes)
@@ -5082,7 +5040,6 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
INTERNAL_SIZE_T size;
- mchunkptr victim;
nb = checked_request2size (bytes);
if (nb == 0)
@@ -5101,129 +5058,13 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
we don't find anything in those bins, the common malloc code will
scan starting at 2x. */
- /* This will be set if we found a candidate chunk. */
- victim = NULL;
-
- /* Fast bins are singly-linked, hard to remove a chunk from the middle
- and unlikely to meet our alignment requirements. We have not done
- any experimentation with searching for aligned fastbins. */
-
- if (av != NULL)
- {
- int first_bin_index;
- int first_largebin_index;
- int last_bin_index;
-
- if (in_smallbin_range (nb))
- first_bin_index = smallbin_index (nb);
- else
- first_bin_index = largebin_index (nb);
-
- if (in_smallbin_range (nb * 2))
- last_bin_index = smallbin_index (nb * 2);
- else
- last_bin_index = largebin_index (nb * 2);
-
- first_largebin_index = largebin_index (MIN_LARGE_SIZE);
-
- int victim_index; /* its bin index */
-
- for (victim_index = first_bin_index;
- victim_index < last_bin_index;
- victim_index ++)
- {
- victim = NULL;
-
- if (victim_index < first_largebin_index)
- {
- /* Check small bins. Small bin chunks are doubly-linked despite
- being the same size. */
-
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
- while (fwd != bck)
- {
- if (chunk_ok_for_memalign (fwd, alignment, nb) > 0)
- {
- victim = fwd;
-
- /* Unlink it */
- victim->fd->bk = victim->bk;
- victim->bk->fd = victim->fd;
- break;
- }
-
- fwd = fwd->fd;
- }
- }
- else
- {
- /* Check large bins. */
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr best = NULL;
- size_t best_size = 0;
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
+ /* Call malloc with worst case padding to hit alignment. */
+ m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
- while (fwd != bck)
- {
- int extra;
-
- if (chunksize (fwd) < nb)
- break;
- extra = chunk_ok_for_memalign (fwd, alignment, nb);
- if (extra > 0
- && (extra <= best_size || best == NULL))
- {
- best = fwd;
- best_size = extra;
- }
+ if (m == 0)
+ return 0; /* propagate failure */
- fwd = fwd->fd;
- }
- victim = best;
-
- if (victim != NULL)
- {
- unlink_chunk (av, victim);
- break;
- }
- }
-
- if (victim != NULL)
- break;
- }
- }
-
- /* Strategy: find a spot within that chunk that meets the alignment
- request, and then possibly free the leading and trailing space.
- This strategy is incredibly costly and can lead to external
- fragmentation if header and footer chunks are unused. */
-
- if (victim != NULL)
- {
- p = victim;
- m = chunk2mem (p);
- set_inuse (p);
- if (av != &main_arena)
- set_non_main_arena (p);
- }
- else
- {
- /* Call malloc with worst case padding to hit alignment. */
-
- m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
-
- if (m == 0)
- return 0; /* propagate failure */
-
- p = mem2chunk (m);
- }
+ p = mem2chunk (m);
if ((((unsigned long) (m)) % alignment) != 0) /* misaligned */
{
diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c
index f229283dbf..ecd6fa249e 100644
--- a/malloc/tst-memalign-2.c
+++ b/malloc/tst-memalign-2.c
@@ -86,7 +86,8 @@ do_test (void)
TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);
}
- /* Test for non-head tcache hits. */
+ /* Test for non-head tcache hits. This exercises the memalign
+ scanning code to find matching allocations. */
for (i = 0; i < array_length (ptr); ++ i)
{
if (i == 4)
@@ -113,7 +114,9 @@ do_test (void)
free (p);
TEST_VERIFY (count > 0);
- /* Large bins test. */
+ /* Large bins test. This verifies that the over-allocated parts
+ that memalign releases for future allocations can be reused by
+ memalign itself at least in some cases. */
for (i = 0; i < LN; ++ i)
{

View File

@ -1,145 +1,28 @@
From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 29 Apr 2022 16:37:51 +0200
Subject: [PATCH] Do not use --hash-style=both for building glibc shared
objects
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
Makeconfig | 9 +++++++++
Makerules | 7 +++++++
config.make.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git b/Makeconfig a/Makeconfig
index 760f14e92f..0aa5fb0099 100644
--- b/Makeconfig
+++ a/Makeconfig
@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
ifeq (no,$(build-pie-default))
pie-default = $(no-pie-ccflag)
else # build-pie-default
diff --git b/Makerules a/Makerules
index 354528b8c7..428464f092 100644
--- b/Makerules
+++ a/Makerules
@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
-Wl,--verbose 2>/dev/null | \
sed > $@T \
-e '/^=========/,/^=========/!d;/^=========/d' \
+ $(if $(filter yes,$(have-hash-style)), \
+ -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
+ -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+ , \
+ -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ ) \
-e 's/^.*\*(\.dynbss).*$$/& \
PROVIDE(__start___libc_freeres_ptrs = .); \
*(__libc_freeres_ptrs) \
diff --git b/config.make.in a/config.make.in
index fff4c78dd0..bf728c71c0 100644
--- b/config.make.in
+++ a/config.make.in
@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
+have-hash-style = @libc_cv_hashstyle@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
have-loop-to-function = @libc_cv_cc_loop_to_function@
diff --git b/configure a/configure
index 716dc041b6..5a730dc5fc 100755
--- b/configure
+++ a/configure
@@ -622,6 +622,7 @@ libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
fno_unit_at_a_time
libc_cv_has_glob_dat
+libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
ASFLAGS_config
@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
+$as_echo_n "checking for --hash-style option... " >&6; }
+if ${libc_cv_hashstyle+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
+$as_echo "$libc_cv_hashstyle" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
if ${libc_cv_has_glob_dat+:} false; then :
diff --git b/configure.ac a/configure.ac
index d08ad4d64e..a045f6608e 100644
--- b/configure.ac
+++ a/configure.ac
@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for --hash-style option,
+ libc_cv_hashstyle, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_hashstyle)
+
AC_CACHE_CHECK(for GLOB_DAT reloc,
libc_cv_has_glob_dat, [dnl
cat > conftest.c <<EOF
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.37.1
2.41.0

View File

@ -10,25 +10,31 @@ _target=powerpc64-unknown-linux-gnu
pkgname=${_target}-glibc
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3
pkgrel=3.1
pkgdesc="GNU C Library (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=6.3")
makedepends=("${_target}-gcc-stage2>=13.1.1" "python" "git")
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage2>=13.2.1" python git)
provides=("${_target}-glibc-headers=${pkgver}" "${_target}-eglibc")
conflicts=("${_target}-glibc-headers" "${_target}-eglibc")
replaces=("${_target}-glibc-headers")
options=(!buildflags !strip staticlibs)
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
sdt.h)
sdt.h
fix-malloc-p1.patch
fix-malloc-p2.patch
reenable_DT_HASH.patch)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
sha256sums=('SKIP'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70')
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'1e22a2226fe308154e70981c0036c7c4ebac488b26b9959cb803d7a3d831d0c4'
'59f37c6f3a27e08d846c1dcb0ac08c1aebb14c11afb9be10652ca1a80fd54c3e'
'cf9fe494f7ec69752a63d1b0a9ad689aa620888ae9b902b6383a6fbc7c1726a7')
prepare() {
mkdir -p glibc-build
@ -48,12 +54,16 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
--disable-multi-arch
--enable-kernel=4.4
--enable-multi-arch
--enable-stack-protector=strong
--enable-systemtap
--enable-stack-protector=strong
--enable-stackguard-randomization
--disable-profile
@ -62,10 +72,10 @@ build() {
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -75,19 +85,25 @@ build() {
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
export OBJCOPY=${_target}-objcopy
export OBJDUMP=${_target}-objdump
unset LD_LIBRARY_PATH
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
--build=${CHOST}
--build=${_target}
echo "build-programs=no" >> configparms
make
case "${CARCH}" in
powerpc64) sed 's@RTLDLIST=.*@RTLDLIST="/usr/lib/ld64.so.2"@g' -i ${pkgdir}/usr/bin/ldd ;;
esac
}
package() {
@ -96,8 +112,13 @@ package() {
make install_root="$pkgdir/usr/$_target" install
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Remove unneeded for compilation files
rm -rf "$pkgdir/usr/$_target/"{bin,sbin,etc,share,var}
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -0,0 +1,294 @@
commit 542b1105852568c3ebc712225ae78b8c8ba31a78
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 11 11:18:17 2023 +0200
malloc: Enable merging of remainders in memalign (bug 30723)
Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator. This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.
Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own. We can still give it back if it can be merged
with the following unused chunk. This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.
Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e2f1a615a4..948f9759af 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1086,6 +1086,11 @@ typedef struct malloc_chunk* mchunkptr;
static void* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr, int);
+static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
+static INTERNAL_SIZE_T _int_free_create_chunk (mstate,
+ mchunkptr, INTERNAL_SIZE_T,
+ mchunkptr, INTERNAL_SIZE_T);
+static void _int_free_maybe_consolidate (mstate, INTERNAL_SIZE_T);
static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
INTERNAL_SIZE_T);
static void* _int_memalign(mstate, size_t, size_t);
@@ -4637,31 +4642,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (!have_lock)
__libc_lock_lock (av->mutex);
- nextchunk = chunk_at_offset(p, size);
-
- /* Lightweight tests: check whether the block is already the
- top block. */
- if (__glibc_unlikely (p == av->top))
- malloc_printerr ("double free or corruption (top)");
- /* Or whether the next chunk is beyond the boundaries of the arena. */
- if (__builtin_expect (contiguous (av)
- && (char *) nextchunk
- >= ((char *) av->top + chunksize(av->top)), 0))
- malloc_printerr ("double free or corruption (out)");
- /* Or whether the block is actually not marked used. */
- if (__glibc_unlikely (!prev_inuse(nextchunk)))
- malloc_printerr ("double free or corruption (!prev)");
-
- nextsize = chunksize(nextchunk);
- if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
- || __builtin_expect (nextsize >= av->system_mem, 0))
- malloc_printerr ("free(): invalid next size (normal)");
+ _int_free_merge_chunk (av, p, size);
- free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
+ if (!have_lock)
+ __libc_lock_unlock (av->mutex);
+ }
+ /*
+ If the chunk was allocated via mmap, release via munmap().
+ */
+
+ else {
+ munmap_chunk (p);
+ }
+}
+
+/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
+ resulting chunk on the appropriate bin list. P must not be on a
+ bin list yet, and it can be in use. */
+static void
+_int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
+{
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+
+ /* Lightweight tests: check whether the block is already the
+ top block. */
+ if (__glibc_unlikely (p == av->top))
+ malloc_printerr ("double free or corruption (top)");
+ /* Or whether the next chunk is beyond the boundaries of the arena. */
+ if (__builtin_expect (contiguous (av)
+ && (char *) nextchunk
+ >= ((char *) av->top + chunksize(av->top)), 0))
+ malloc_printerr ("double free or corruption (out)");
+ /* Or whether the block is actually not marked used. */
+ if (__glibc_unlikely (!prev_inuse(nextchunk)))
+ malloc_printerr ("double free or corruption (!prev)");
+
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
+ || __builtin_expect (nextsize >= av->system_mem, 0))
+ malloc_printerr ("free(): invalid next size (normal)");
+
+ free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
- /* consolidate backward */
- if (!prev_inuse(p)) {
- prevsize = prev_size (p);
+ /* Consolidate backward. */
+ if (!prev_inuse(p))
+ {
+ INTERNAL_SIZE_T prevsize = prev_size (p);
size += prevsize;
p = chunk_at_offset(p, -((long) prevsize));
if (__glibc_unlikely (chunksize(p) != prevsize))
@@ -4669,9 +4695,25 @@ _int_free (mstate av, mchunkptr p, int have_lock)
unlink_chunk (av, p);
}
- if (nextchunk != av->top) {
+ /* Write the chunk header, maybe after merging with the following chunk. */
+ size = _int_free_create_chunk (av, p, size, nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, size);
+}
+
+/* Create a chunk at P of SIZE bytes, with SIZE potentially increased
+ to cover the immediately following chunk NEXTCHUNK of NEXTSIZE
+ bytes (if NEXTCHUNK is unused). The chunk at P is not actually
+ read and does not have to be initialized. After creation, it is
+ placed on the appropriate bin list. The function returns the size
+ of the new chunk. */
+static INTERNAL_SIZE_T
+_int_free_create_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size,
+ mchunkptr nextchunk, INTERNAL_SIZE_T nextsize)
+{
+ if (nextchunk != av->top)
+ {
/* get and clear inuse bit */
- nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
+ bool nextinuse = inuse_bit_at_offset (nextchunk, nextsize);
/* consolidate forward */
if (!nextinuse) {
@@ -4686,8 +4728,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
been given one chance to be used in malloc.
*/
- bck = unsorted_chunks(av);
- fwd = bck->fd;
+ mchunkptr bck = unsorted_chunks (av);
+ mchunkptr fwd = bck->fd;
if (__glibc_unlikely (fwd->bk != bck))
malloc_printerr ("free(): corrupted unsorted chunks");
p->fd = fwd;
@@ -4706,61 +4748,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
check_free_chunk(av, p);
}
- /*
- If the chunk borders the current high end of memory,
- consolidate into top
- */
-
- else {
+ else
+ {
+ /* If the chunk borders the current high end of memory,
+ consolidate into top. */
size += nextsize;
set_head(p, size | PREV_INUSE);
av->top = p;
check_chunk(av, p);
}
- /*
- If freeing a large space, consolidate possibly-surrounding
- chunks. Then, if the total unused topmost memory exceeds trim
- threshold, ask malloc_trim to reduce top.
-
- Unless max_fast is 0, we don't know if there are fastbins
- bordering top, so we cannot tell for sure whether threshold
- has been reached unless fastbins are consolidated. But we
- don't want to consolidate on each free. As a compromise,
- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD
- is reached.
- */
+ return size;
+}
- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
+/* If freeing a large space, consolidate possibly-surrounding
+ chunks. Then, if the total unused topmost memory exceeds trim
+ threshold, ask malloc_trim to reduce top. */
+static void
+_int_free_maybe_consolidate (mstate av, INTERNAL_SIZE_T size)
+{
+ /* Unless max_fast is 0, we don't know if there are fastbins
+ bordering top, so we cannot tell for sure whether threshold has
+ been reached unless fastbins are consolidated. But we don't want
+ to consolidate on each free. As a compromise, consolidation is
+ performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */
+ if (size >= FASTBIN_CONSOLIDATION_THRESHOLD)
+ {
if (atomic_load_relaxed (&av->have_fastchunks))
malloc_consolidate(av);
- if (av == &main_arena) {
+ if (av == &main_arena)
+ {
#ifndef MORECORE_CANNOT_TRIM
- if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ if (chunksize (av->top) >= mp_.trim_threshold)
+ systrim (mp_.top_pad, av);
#endif
- } else {
- /* Always try heap_trim(), even if the top chunk is not
- large, because the corresponding heap might go away. */
- heap_info *heap = heap_for_ptr(top(av));
+ }
+ else
+ {
+ /* Always try heap_trim, even if the top chunk is not large,
+ because the corresponding heap might go away. */
+ heap_info *heap = heap_for_ptr (top (av));
- assert(heap->ar_ptr == av);
- heap_trim(heap, mp_.top_pad);
- }
+ assert (heap->ar_ptr == av);
+ heap_trim (heap, mp_.top_pad);
+ }
}
-
- if (!have_lock)
- __libc_lock_unlock (av->mutex);
- }
- /*
- If the chunk was allocated via mmap, release via munmap().
- */
-
- else {
- munmap_chunk (p);
- }
}
/*
@@ -5221,7 +5254,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
(av != &main_arena ? NON_MAIN_ARENA : 0));
set_inuse_bit_at_offset (newp, newsize);
set_head_size (p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0));
- _int_free (av, p, 1);
+ _int_free_merge_chunk (av, p, leadsize);
p = newp;
assert (newsize >= nb &&
@@ -5232,15 +5265,27 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
if (!chunk_is_mmapped (p))
{
size = chunksize (p);
- if ((unsigned long) (size) > (unsigned long) (nb + MINSIZE))
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (size > nb)
{
remainder_size = size - nb;
- remainder = chunk_at_offset (p, nb);
- set_head (remainder, remainder_size | PREV_INUSE |
- (av != &main_arena ? NON_MAIN_ARENA : 0));
- set_head_size (p, nb);
- _int_free (av, remainder, 1);
- }
+ if (remainder_size >= MINSIZE
+ || nextchunk == av->top
+ || !inuse_bit_at_offset (nextchunk, nextsize))
+ {
+ /* We can only give back the tail if it is larger than
+ MINSIZE, or if the following chunk is unused (top
+ chunk or unused in-heap chunk). Otherwise we would
+ create a chunk that is smaller than MINSIZE. */
+ remainder = chunk_at_offset (p, nb);
+ set_head_size (p, nb);
+ remainder_size = _int_free_create_chunk (av, remainder,
+ remainder_size,
+ nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, remainder_size);
+ }
+ }
}
check_inuse_chunk (av, p);

View File

@ -0,0 +1,249 @@
commit 0dc7fc1cf094406a138e4d1bcf9553e59edcf89d
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Aug 10 19:36:56 2023 +0200
malloc: Remove bin scanning from memalign (bug 30723)
On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%). The tcache
scanning has about 50% success rate, so keep that.
Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests. Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.
Remove leftover variables from _int_free from refactoring in the
same commit.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 948f9759af..d0bbbf3710 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4488,12 +4488,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
{
INTERNAL_SIZE_T size; /* its size */
mfastbinptr *fb; /* associated fastbin */
- mchunkptr nextchunk; /* next contiguous chunk */
- INTERNAL_SIZE_T nextsize; /* its size */
- int nextinuse; /* true if nextchunk is used */
- INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr fwd; /* misc temp for linking */
size = chunksize (p);
@@ -5032,42 +5026,6 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
------------------------------ memalign ------------------------------
*/
-/* Returns 0 if the chunk is not and does not contain the requested
- aligned sub-chunk, else returns the amount of "waste" from
- trimming. NB is the *chunk* byte size, not the user byte
- size. */
-static size_t
-chunk_ok_for_memalign (mchunkptr p, size_t alignment, size_t nb)
-{
- void *m = chunk2mem (p);
- INTERNAL_SIZE_T size = chunksize (p);
- void *aligned_m = m;
-
- if (__glibc_unlikely (misaligned_chunk (p)))
- malloc_printerr ("_int_memalign(): unaligned chunk detected");
-
- aligned_m = PTR_ALIGN_UP (m, alignment);
-
- INTERNAL_SIZE_T front_extra = (intptr_t) aligned_m - (intptr_t) m;
-
- /* We can't trim off the front as it's too small. */
- if (front_extra > 0 && front_extra < MINSIZE)
- return 0;
-
- /* If it's a perfect fit, it's an exception to the return value rule
- (we would return zero waste, which looks like "not usable"), so
- handle it here by returning a small non-zero value instead. */
- if (size == nb && front_extra == 0)
- return 1;
-
- /* If the block we need fits in the chunk, calculate total waste. */
- if (size > nb + front_extra)
- return size - nb;
-
- /* Can't use this chunk. */
- return 0;
-}
-
/* BYTES is user requested bytes, not requested chunksize bytes. */
static void *
_int_memalign (mstate av, size_t alignment, size_t bytes)
@@ -5082,7 +5040,6 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
INTERNAL_SIZE_T size;
- mchunkptr victim;
nb = checked_request2size (bytes);
if (nb == 0)
@@ -5101,129 +5058,13 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
we don't find anything in those bins, the common malloc code will
scan starting at 2x. */
- /* This will be set if we found a candidate chunk. */
- victim = NULL;
-
- /* Fast bins are singly-linked, hard to remove a chunk from the middle
- and unlikely to meet our alignment requirements. We have not done
- any experimentation with searching for aligned fastbins. */
-
- if (av != NULL)
- {
- int first_bin_index;
- int first_largebin_index;
- int last_bin_index;
-
- if (in_smallbin_range (nb))
- first_bin_index = smallbin_index (nb);
- else
- first_bin_index = largebin_index (nb);
-
- if (in_smallbin_range (nb * 2))
- last_bin_index = smallbin_index (nb * 2);
- else
- last_bin_index = largebin_index (nb * 2);
-
- first_largebin_index = largebin_index (MIN_LARGE_SIZE);
-
- int victim_index; /* its bin index */
-
- for (victim_index = first_bin_index;
- victim_index < last_bin_index;
- victim_index ++)
- {
- victim = NULL;
-
- if (victim_index < first_largebin_index)
- {
- /* Check small bins. Small bin chunks are doubly-linked despite
- being the same size. */
-
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
- while (fwd != bck)
- {
- if (chunk_ok_for_memalign (fwd, alignment, nb) > 0)
- {
- victim = fwd;
-
- /* Unlink it */
- victim->fd->bk = victim->bk;
- victim->bk->fd = victim->fd;
- break;
- }
-
- fwd = fwd->fd;
- }
- }
- else
- {
- /* Check large bins. */
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr best = NULL;
- size_t best_size = 0;
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
+ /* Call malloc with worst case padding to hit alignment. */
+ m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
- while (fwd != bck)
- {
- int extra;
-
- if (chunksize (fwd) < nb)
- break;
- extra = chunk_ok_for_memalign (fwd, alignment, nb);
- if (extra > 0
- && (extra <= best_size || best == NULL))
- {
- best = fwd;
- best_size = extra;
- }
+ if (m == 0)
+ return 0; /* propagate failure */
- fwd = fwd->fd;
- }
- victim = best;
-
- if (victim != NULL)
- {
- unlink_chunk (av, victim);
- break;
- }
- }
-
- if (victim != NULL)
- break;
- }
- }
-
- /* Strategy: find a spot within that chunk that meets the alignment
- request, and then possibly free the leading and trailing space.
- This strategy is incredibly costly and can lead to external
- fragmentation if header and footer chunks are unused. */
-
- if (victim != NULL)
- {
- p = victim;
- m = chunk2mem (p);
- set_inuse (p);
- if (av != &main_arena)
- set_non_main_arena (p);
- }
- else
- {
- /* Call malloc with worst case padding to hit alignment. */
-
- m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
-
- if (m == 0)
- return 0; /* propagate failure */
-
- p = mem2chunk (m);
- }
+ p = mem2chunk (m);
if ((((unsigned long) (m)) % alignment) != 0) /* misaligned */
{
diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c
index f229283dbf..ecd6fa249e 100644
--- a/malloc/tst-memalign-2.c
+++ b/malloc/tst-memalign-2.c
@@ -86,7 +86,8 @@ do_test (void)
TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);
}
- /* Test for non-head tcache hits. */
+ /* Test for non-head tcache hits. This exercises the memalign
+ scanning code to find matching allocations. */
for (i = 0; i < array_length (ptr); ++ i)
{
if (i == 4)
@@ -113,7 +114,9 @@ do_test (void)
free (p);
TEST_VERIFY (count > 0);
- /* Large bins test. */
+ /* Large bins test. This verifies that the over-allocated parts
+ that memalign releases for future allocations can be reused by
+ memalign itself at least in some cases. */
for (i = 0; i < LN; ++ i)
{

View File

@ -1,145 +1,28 @@
From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 29 Apr 2022 16:37:51 +0200
Subject: [PATCH] Do not use --hash-style=both for building glibc shared
objects
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
Makeconfig | 9 +++++++++
Makerules | 7 +++++++
config.make.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git b/Makeconfig a/Makeconfig
index 760f14e92f..0aa5fb0099 100644
--- b/Makeconfig
+++ a/Makeconfig
@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
ifeq (no,$(build-pie-default))
pie-default = $(no-pie-ccflag)
else # build-pie-default
diff --git b/Makerules a/Makerules
index 354528b8c7..428464f092 100644
--- b/Makerules
+++ a/Makerules
@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
-Wl,--verbose 2>/dev/null | \
sed > $@T \
-e '/^=========/,/^=========/!d;/^=========/d' \
+ $(if $(filter yes,$(have-hash-style)), \
+ -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
+ -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+ , \
+ -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ ) \
-e 's/^.*\*(\.dynbss).*$$/& \
PROVIDE(__start___libc_freeres_ptrs = .); \
*(__libc_freeres_ptrs) \
diff --git b/config.make.in a/config.make.in
index fff4c78dd0..bf728c71c0 100644
--- b/config.make.in
+++ a/config.make.in
@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
+have-hash-style = @libc_cv_hashstyle@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
have-loop-to-function = @libc_cv_cc_loop_to_function@
diff --git b/configure a/configure
index 716dc041b6..5a730dc5fc 100755
--- b/configure
+++ a/configure
@@ -622,6 +622,7 @@ libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
fno_unit_at_a_time
libc_cv_has_glob_dat
+libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
ASFLAGS_config
@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
+$as_echo_n "checking for --hash-style option... " >&6; }
+if ${libc_cv_hashstyle+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
+$as_echo "$libc_cv_hashstyle" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
if ${libc_cv_has_glob_dat+:} false; then :
diff --git b/configure.ac a/configure.ac
index d08ad4d64e..a045f6608e 100644
--- b/configure.ac
+++ a/configure.ac
@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for --hash-style option,
+ libc_cv_hashstyle, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_hashstyle)
+
AC_CACHE_CHECK(for GLOB_DAT reloc,
libc_cv_has_glob_dat, [dnl
cat > conftest.c <<EOF
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.37.1
2.41.0

View File

@ -10,7 +10,7 @@
_target=powerpc64-unknown-linux-gnu
pkgname=${_target}-libxcrypt
pkgver=4.4.36
pkgrel=1
pkgrel=1.1
pkgdesc='Modern library for one-way hashing of passwords'
arch=(any)
url='https://github.com/besser82/libxcrypt'
@ -34,7 +34,7 @@ build() {
cd "${srcdir}/build-libxcrypt/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
@ -46,7 +46,7 @@ build() {
cd "${srcdir}/build-libxcrypt-compat/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
@ -59,8 +59,8 @@ build() {
package() {
cd ${srcdir}/build-libxcrypt/
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}/usr/${_target}/" install
cd ${srcdir}/build-libxcrypt-compat/
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}/usr/${_target}/" install
}

View File

@ -9,15 +9,15 @@
_target_arch=powerpc64
_target=${_target_arch}-unknown-linux-gnu
pkgname=${_target}-linux-api-headers
pkgver=6.3
pkgrel=1
pkgver=6.4
pkgrel=2
pkgdesc="Kernel headers sanitized for use in userspace (${_target})"
arch=(any)
url='http://www.gnu.org/software/libc'
license=(GPL2)
makedepends=(rsync make)
source=(https://www.kernel.org/pub/linux/kernel/v6.x/linux-${pkgver}.tar.xz)
sha256sums=('ba3491f5ed6bd270a370c440434e3d69085fcdd528922fa01e73d7657db73b1e')
sha256sums=('8fa0588f0c2ceca44cac77a0e39ba48c9f00a6b9dc69761c02a5d3efac8da7f3')
validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E') # Greg Kroah-Hartman
@ -29,10 +29,10 @@ build() {
package() {
cd linux-${pkgver}
make INSTALL_HDR_PATH="$pkgdir/usr/$_target" ARCH=powerpc headers_install
make INSTALL_HDR_PATH="$pkgdir/usr/$_target/usr" ARCH=powerpc headers_install
# use headers from libdrm
rm -rf "$pkgdir/usr/$_target/include/drm"
rm -rf "$pkgdir/usr/$_target/usr/include/drm"
# clean-up unnecessary files generated during install
find ${pkgdir} \( -name .install -o -name ..install.cmd \) -delete

View File

@ -0,0 +1,58 @@
# Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
_arch=powerpc64
_target=${_arch}-unknown-linux-gnu
pkgname=${_target}-pacman
pkgver=2023.09
pkgrel=1
pkgdesc="Pacman configurations for ${_target} to install dependencies for cross-compilation"
arch=(any)
url="https://archlinuxpower.org"
depends=(
${_target}-gcc
${_target}-glibc
)
source=(pacman-arch.sh
pacman.conf
fakebase.desc)
backup=(etc/pacman-${_arch}.conf)
sha256sums=('5fd18c74198312560579d900af2b0e52b757b47fb70e4f78e995b29cf0b5ee7a'
'6be22d041e30ca7475d7700ff35b4ca34ad62f3ad415b8f429edbbc03c295d0e'
'c7d16160e0d91becce572abee7954e61411c729eec7a367a96335fba6bc470f1')
prepare() {
if [ -d /usr/${_target}/var/lib/pacman ]; then
echo "Remove existing synced dbs etc from /usr/${_target}/var/lib/pacman/ and try again"
exit 1
fi
}
build() {
sed "s/@@CARCH@@/${_arch}/g" -i pacman-arch.sh
sed "s/@@CHOST_PREFIX@@/\/usr\/${_target}\//g" -i pacman.conf
sed "s/@@TIMESTAMP@@/$(date "+%s")/g" -i fakebase.desc
sed "s/@@FAKEBASE_VERSION@@/${pkgver}-${pkgrel}/g" -i fakebase.desc
}
package() {
install -d -m755 ${pkgdir}/usr/bin
install -m755 ${srcdir}/pacman-arch.sh ${pkgdir}/usr/bin/pacman-${_arch}
install -d -m 755 ${pkgdir}/etc
install -m644 ${srcdir}/pacman.conf ${pkgdir}/etc/pacman-${_arch}.conf
# fake that we install a few basic packages via pacman
install -d -m 755 ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}
pushd /usr/${_target}/
shopt -s dotglob globstar
printf '%s\0' **/* | LANG=C bsdtar -cnf - --format=mtree --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' --null --files-from - --exclude .MTREE | gzip -c -f -n > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/mtree
shopt -u dotglob globstar
echo '%FILES%' > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
find | sed 's@^./@@g' | grep -v '^\.$' | grep -v '.*mtree$' >> ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
echo 9 > ${pkgdir}/usr/${_target}/var/lib/pacman/local/ALPM_DB_VERSION
install -m644 ${srcdir}/fakebase.desc ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/desc
popd
}

View File

@ -0,0 +1,42 @@
%NAME%
fakebase
%VERSION%
@@FAKEBASE_VERSION@@
%DESC%
Masking that some packages from crosscompilers on the host
%URL%
https://archlinuxpower.org
%ARCH%
any
%BUILDDATE%
@@TIMESTAMP@@
%INSTALLDATE%
@@TIMESTAMP@@
%PACKAGER%
Alexander Baldeck <alex.bldck@gmail.com>
%SIZE%
10
%LICENSE%
GPL
%VALIDATION%
sha256
%PROVIDES%
binutils
filesystem
gcc
gcc-libs
glibc
libxcrypt
linux-api-headers
zlib

View File

@ -0,0 +1,141 @@
%FILES%
bin
boot/
dev/
etc/
etc/arch-release
etc/crypttab
etc/fstab
etc/group
etc/gshadow
etc/host.conf
etc/hosts
etc/issue
etc/ld.so.conf
etc/ld.so.conf.d/
etc/mtab
etc/nsswitch.conf
etc/passwd
etc/profile
etc/profile.d/
etc/profile.d/locale.sh
etc/resolv.conf
etc/securetty
etc/shadow
etc/shells
etc/skel/
etc/subgid
etc/subuid
home/
lib
lib64
mnt/
opt/
proc/
root/
run/
sbin
srv/
srv/ftp/
srv/http/
sys/
tmp/
usr/
usr/bin/
usr/include/
usr/lib/
usr/lib/os-release
usr/lib/sysctl.d/
usr/lib/sysctl.d/10-arch.conf
usr/lib/systemd/
usr/lib/systemd/system-environment-generators/
usr/lib/systemd/system-environment-generators/10-arch
usr/lib/sysusers.d/
usr/lib/sysusers.d/arch.conf
usr/lib/tmpfiles.d/
usr/lib/tmpfiles.d/arch.conf
usr/lib64
usr/local/
usr/local/bin/
usr/local/etc/
usr/local/games/
usr/local/include/
usr/local/lib/
usr/local/man/
usr/local/sbin/
usr/local/share/
usr/local/share/man
usr/local/src/
usr/sbin
usr/share/
usr/share/factory/
usr/share/factory/etc/
usr/share/factory/etc/crypttab
usr/share/factory/etc/fstab
usr/share/factory/etc/group
usr/share/factory/etc/gshadow
usr/share/factory/etc/host.conf
usr/share/factory/etc/hosts
usr/share/factory/etc/issue
usr/share/factory/etc/ld.so.conf
usr/share/factory/etc/nsswitch.conf
usr/share/factory/etc/passwd
usr/share/factory/etc/profile
usr/share/factory/etc/resolv.conf
usr/share/factory/etc/securetty
usr/share/factory/etc/shadow
usr/share/factory/etc/shells
usr/share/factory/etc/subgid
usr/share/factory/etc/subuid
usr/share/man/
usr/share/man/man1/
usr/share/man/man2/
usr/share/man/man3/
usr/share/man/man4/
usr/share/man/man5/
usr/share/man/man6/
usr/share/man/man7/
usr/share/man/man8/
usr/share/misc/
usr/share/pixmaps/
usr/share/pixmaps/archlinux-logo-text-dark.svg
usr/share/pixmaps/archlinux-logo-text.svg
usr/share/pixmaps/archlinux-logo.png
usr/share/pixmaps/archlinux-logo.svg
usr/src/
var/
var/cache/
var/empty/
var/games/
var/lib/
var/lib/misc/
var/local/
var/lock
var/log/
var/log/old/
var/mail
var/opt/
var/run
var/spool/
var/spool/mail/
var/tmp/
%BACKUP%
etc/crypttab 5fa6674df7645d7f5895f2d12b4ef4e9
etc/fstab e33f6dfdd61978fcb3ddf1431286e05a
etc/group 7fed1e1fb855e41a6d64d41f8521d69a
etc/gshadow 1c1e3b08acfa286f4b417c49de3e4366
etc/host.conf 7d119a9cce152aa182fb3392ddeecea7
etc/hosts a1315ea3e2b64d197b6efaf9c14ff778
etc/issue f36195a7ed232b8520a68a867f166a3b
etc/ld.so.conf 5deb9f890a4d08a245e9752ede77271e
etc/nsswitch.conf a3de66d416718325442f739d6c1d4e50
etc/passwd 5182ac38a0de85da8ade93ef71975ca4
etc/profile 448fe7cbcb566e8d318dc0db0c9cb710
etc/resolv.conf 0ee015fad07732676d9488ae498eed41
etc/securetty f04bcb2803afc4dcb95670fe87343b4d
etc/shadow 815652599be54fd3607cf276e89a0a19
etc/shells 8fe5095f1116c2c61b4608c4840063a2
etc/subuid d41d8cd98f00b204e9800998ecf8427e
etc/subgid d41d8cd98f00b204e9800998ecf8427e

View File

@ -0,0 +1,3 @@
#!/bin/sh
pacman --config /etc/pacman-@@CARCH@@.conf $@

View File

@ -0,0 +1,96 @@
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
RootDir = @@CHOST_PREFIX@@
DBPath = @@CHOST_PREFIX@@/var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = powerpc
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
#Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
#ParallelDownloads = 5
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[repo-local-any]
SigLevel = Never
Server = http://172.23.23.10/repo/any
[repo-local]
SigLevel = Never
Server = http://172.23.23.10/repo/$arch
[testing-any]
Server = https://repo.archlinuxpower.org/testing/any
[testing]
Server = https://repo.archlinuxpower.org/testing/$arch
[base-any]
Server = https://repo.archlinuxpower.org/base/any
[base]
Server = https://repo.archlinuxpower.org/base/$arch
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

View File

@ -5,43 +5,36 @@
_target=powerpc64le-unknown-linux-gnu
pkgname=$_target-binutils
pkgver=2.38
pkgrel=1
pkgdesc='Assemble and manipulate binary and object files for 32-bit and 64-bit RISC-V'
arch=(x86_64 powerpc)
pkgver=2.41
_commit=31b78cc991781265d9404bd55151691bedd6d556
pkgrel=3.1
pkgdesc='Assemble and manipulate binary and object files for riscv64'
arch=(x86_64 powerpc64 powerpc riscv64)
url='https://gnu.org/software/binutils/'
license=(GPL)
groups=(risc-v)
makedepends=(setconf)
source=("https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz"
gold-warn-unsupported.patch
fix-incorrect-undefined-symbol.patch
"binutils-pr28733.patch::https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=e4028336b19998e74a51dd0918a8b3922e08a537;hp=df0a549ebdae74ef9d233243b869d424e6a33c73")
sha512sums=('8bf0b0d193c9c010e0518ee2b2e5a830898af206510992483b427477ed178396cd210235e85fd7bd99a96fc6d5eedbeccbd48317a10f752b7336ada8b2bb826d'
'5d827b349b4456f8314776f1545396945c751b822a77604157b3fe436e5ff82bb313af3a215c99fd9d1f1f8ebb9f92033cc1a4968e35734619ad28b9bb3839a7'
'36da578519db4665f959a64813173ecbf3f999bc6b3acfb216e24d73a617ded22202e08915d2fa4c86b46c627127bc6e22e6dba07ce89588c0da7771c6f34a58'
'302e1fe276fdc54ffc3285b48839777c182014952bc0383c32d1316a818a3a58599ca4a5ac8f7cf55081c1bf8749c8452f8e8572fb29ae4995dafc53abdc5211')
depends=(glibc zlib libelf jansson)
makedepends=(git setconf)
source=(git+https://sourceware.org/git/binutils-gdb.git#commit=${_commit}
gold-warn-unsupported.patch)
sha512sums=('SKIP'
'5d827b349b4456f8314776f1545396945c751b822a77604157b3fe436e5ff82bb313af3a215c99fd9d1f1f8ebb9f92033cc1a4968e35734619ad28b9bb3839a7')
prepare() {
cd "binutils-$pkgver"
cd ${srcdir}
[[ ! -d binutils-gdb ]] && ln -s binutils-$pkgver binutils-gdb
cd "binutils-gdb"
# Creds @Fedora
# Change the gold configuration script to only warn about
# unsupported targets. This allows the binutils to be built with
# BPF support enabled.
patch -Np1 -i "${srcdir}"/gold-warn-unsupported.patch
# fix incorrect "undefined reference" errors
# https://sourceware.org/bugzilla/show_bug.cgi?id=28879
patch -Np1 -i "${srcdir}"/fix-incorrect-undefined-symbol.patch
# riscv64: PR28733, add missing extension info to 'unrecognized opcode' error
patch -Np1 -i "${srcdir}"/binutils-pr28733.patch
setconf libiberty/configure ac_cpp "'\$CPP \$CPPFLAGS -O2'"
}
build() {
cd "binutils-$pkgver"
cd "binutils-gdb"
unset CPPFLAGS
./configure \
@ -55,22 +48,31 @@ build() {
--target=$_target \
--with-gnu-as \
--with-gnu-ld \
--with-sysroot=/usr/$_target \
--with-system-zlib
--with-sysroot=/usr/$_target/usr \
--with-system-zlib \
--disable-werror \
--disable-sim \
--enable-colored-disassembly \
--enable-targets=no
make
}
check() {
# * Unset LDFLAGS as testsuite makes assumptions about which ones are active.
# * Do not abort on errors - manually check log files.
make -C "binutils-$pkgver" LDFLAGS="" -k check
make -C "binutils-gdb" LDFLAGS="" -k check
}
package() {
make -C "binutils-$pkgver" DESTDIR="$pkgdir" install
make -C "binutils-gdb" DESTDIR="$pkgdir" install
install -d -m755 "$pkgdir/usr/$_target/usr"
mv $pkgdir/usr/$_target/{bin,lib} "$pkgdir/usr/$_target/usr/"
# Remove info documents that conflict with host version
rm -r "$pkgdir/usr/share/info"
rm -r "$pkgdir/usr/share/gdb"
rm "$pkgdir/usr/include/gdb/jit-reader.h"
rm "$pkgdir"/usr/lib/bfd-plugins/libdep.so
}

View File

@ -1,114 +0,0 @@
From 20ea3acc727f3be6322dfbd881e506873535231d Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 11 Feb 2022 15:13:19 -0800
Subject: [PATCH] ld: Keep indirect symbol from IR if referenced from shared
object
Don't change indirect symbol defined in IR to undefined if it is
referenced from shared object.
bfd/
PR ld/28879
* elflink.c (_bfd_elf_merge_symbol): Don't change indirect
symbol defined in IR to undefined if it is referenced from
shared object.
ld/
PR ld/28879
* testsuite/ld-plugin/lto.exp: Run PR ld/28879 tests.
* testsuite/ld-plugin/pr28879a.cc: New file.
* testsuite/ld-plugin/pr28879b.cc: Likewise.
---
bfd/elflink.c | 5 ++---
ld/testsuite/ld-plugin/lto.exp | 26 ++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28879a.cc | 7 +++++++
ld/testsuite/ld-plugin/pr28879b.cc | 8 ++++++++
4 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 ld/testsuite/ld-plugin/pr28879a.cc
create mode 100644 ld/testsuite/ld-plugin/pr28879b.cc
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 6fa18d92007..f8521426cad 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1294,9 +1294,8 @@ _bfd_elf_merge_symbol (bfd *abfd,
h->root.non_ir_ref_dynamic = true;
hi->root.non_ir_ref_dynamic = true;
}
-
- if ((oldbfd->flags & BFD_PLUGIN) != 0
- && hi->root.type == bfd_link_hash_indirect)
+ else if ((oldbfd->flags & BFD_PLUGIN) != 0
+ && hi->root.type == bfd_link_hash_indirect)
{
/* Change indirect symbol from IR to undefined. */
hi->root.type = bfd_link_hash_undefined;
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index a70a84562b8..64b880265ee 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -471,6 +471,32 @@ set lto_link_elf_tests [list \
[list {pr27441c.so} \
{-shared -fPIC -Wl,--as-needed tmpdir/pr27441c.o tmpdir/pr27441b.so tmpdir/pr27441a.so} {-fPIC} \
{dummy.c} {{readelf {-dW} pr27441c.d}} {pr27441c.so}] \
+ [list \
+ "Build libpr28879a.so" \
+ "-shared" \
+ "-O0 -fpic" \
+ {pr28879a.cc} \
+ {} \
+ "libpr28879a.so" \
+ "c++" \
+ ] \
+ [list \
+ "Build libpr28879b.so" \
+ "-shared -Wl,--no-as-needed tmpdir/libpr28879a.so" \
+ "-O2 -fpic" \
+ {dummy.c} \
+ {} \
+ "libpr28879b.so" \
+ ] \
+ [list \
+ "Build pr28879" \
+ "-Wl,--no-as-needed tmpdir/libpr28879b.so -Wl,-rpath-link,." \
+ "-O0 -flto -D_GLIBCXX_ASSERTIONS" \
+ {pr28879b.cc} \
+ {} \
+ "pr28879" \
+ "c++" \
+ ] \
]
# PR 14918 checks that libgcc is not spuriously included in a shared link of
diff --git a/ld/testsuite/ld-plugin/pr28879a.cc b/ld/testsuite/ld-plugin/pr28879a.cc
new file mode 100644
index 00000000000..8307a42e2fb
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28879a.cc
@@ -0,0 +1,7 @@
+#include <string>
+
+void
+func (std::string *s)
+{
+ delete s;
+}
diff --git a/ld/testsuite/ld-plugin/pr28879b.cc b/ld/testsuite/ld-plugin/pr28879b.cc
new file mode 100644
index 00000000000..02fc351366c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28879b.cc
@@ -0,0 +1,8 @@
+#include <string>
+
+int
+main (void)
+{
+ std::string header;
+ return 0;
+}
--
2.35.1

View File

@ -8,23 +8,24 @@
_target=powerpc64le-unknown-linux-gnu
pkgname=${_target}-gcc-stage1
pkgver=12.1.0
_majorver=${pkgver:0:1}
pkgrel=1
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 1 for toolchain building (${_target})"
arch=(x86_64 powerpc)
arch=(x86_64 powerpc64 powerpc riscv64)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=(${_target}-binutils libmpc zlib libisl)
options=(!emptydirs !distcc !strip)
source=(https://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/gcc-${pkgver}.tar.xz{,.sig}
makedepends=(git)
options=(!emptydirs !strip)
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b'
'SKIP'
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
@ -36,6 +37,7 @@ prepare() {
# Arch Linux installs x86_64 libraries /lib
sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
sed -i 's@/lib64@/lib@g' gcc/config/rs6000/t-*
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
@ -60,7 +62,7 @@ build() {
--program-prefix=${_target}- \
--with-local-prefix=/usr/${_target} \
--with-sysroot=/usr/${_target} \
--with-build-sysroot=/usr/${_target} \
--with-build-sysroot=/usr/${_target}/usr \
--with-as=/usr/bin/${_target}-as \
--with-ld=/usr/bin/${_target}-ld \
--libdir=/usr/lib \
@ -90,7 +92,8 @@ build() {
--enable-default-ssp \
--target=${_target} \
--host=${CHOST} \
--build=${CHOST}
--build=${CHOST} \
--enable-secureplt
make STAGE1_CFLAGS="-O2" all-gcc all-target-libgcc
}

View File

@ -8,25 +8,28 @@
_target=powerpc64le-unknown-linux-gnu
pkgname=${_target}-gcc-stage2
pkgver=12.1.0
_majorver=${pkgver:0:1}
pkgrel=1
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 2 for toolchain building (${_target})"
arch=(x86_64 powerpc)
arch=(x86_64 powerpc64 powerpc riscv64)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=("${_target}-binutils>=2.38-1" "${_target}-glibc-headers>=2.35-2" libmpc zlib)
options=(!emptydirs !distcc !strip)
depends=("${_target}-binutils>=2.41" "${_target}-glibc-headers>=2.38" libmpc zlib)
makedepends=(git)
options=(!emptydirs !strip)
conflicts=("${_target}-gcc-stage1")
replaces=("${_target}-gcc-stage1")
provides=("${_target}-gcc-stage1=${pkgver}")
source=(https://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/gcc-${pkgver}.tar.xz{,.sig})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b'
'SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -38,6 +41,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -84,7 +90,8 @@ build() {
--enable-default-ssp \
--target=${_target} \
--host=${CHOST} \
--build=${CHOST}
--build=${CHOST} \
--enable-secureplt
make STAGE1_CFLAGS="-O2" all-gcc all-target-libgcc
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -8,26 +8,29 @@
_target=powerpc64le-unknown-linux-gnu
pkgname="${_target}-gcc"
pkgver=12.1.0
_majorver=${pkgver:0:1}
pkgrel=1
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection (${_target})"
arch=(x86_64 powerpc)
arch=(x86_64 powerpc64 powerpc riscv64)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=("${_target}-binutils>=2.38-1" "${_target}-glibc>=2.35-2" libmpc elfutils zlib)
depends=("${_target}-binutils>=2.41" "${_target}-glibc>=2.38" "${_target}-libxcrypt" libmpc elfutils zlib)
makedepends=(git)
checkdepends=(dejagnu inetutils)
options=(!emptydirs !distcc !strip)
conflicts=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
replaces=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
provides=("${_target}-gcc-stage1=${pkgver}" "${_target}-gcc-stage2=${pkgver}")
source=(https://ftp.gnu.org/gnu/gcc/gcc-${pkgver}/gcc-${pkgver}.tar.xz{,.sig})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b'
'SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -39,6 +42,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -61,7 +67,7 @@ build() {
--with-ld=/usr/bin/${_target}-ld \
--libdir=/usr/lib --libexecdir=/usr/lib \
--disable-nls \
--enable-languages=c,c++ \
--enable-languages=c,c++,lto \
--enable-shared \
--enable-threads=posix \
--with-system-zlib \
@ -84,9 +90,12 @@ build() {
--enable-default-ssp \
--target=${_target} \
--host=${CHOST} \
--build=${CHOST}
--build=${CHOST} \
--with-build-config=bootstrap-lto \
--enable-link-serialization=1 \
--enable-secureplt
make STAGE1_CFLAGS="-O2 -mcpu=power8" STAGE2_CFLAGS="-O2 -mcpu=power8"
make STAGE1_CFLAGS="${CFLAGS}" STAGE2_CFLAGS="${CFLAGS}"
}
package() {
@ -101,4 +110,7 @@ package() {
strip "$pkgdir/usr/bin/"* 2>/dev/null || true
find "$pkgdir/usr/lib" -type f -exec /usr/bin/${_target}-strip \
--strip-unneeded {} \; 2>/dev/null || true
install -d -m 755 "$pkgdir/usr/$_target/usr/lib"
mv "$pkgdir/usr/$_target/lib" "$pkgdir/usr/$_target/usr/"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -1,195 +0,0 @@
From 2cbf10ae2ea9e378ff91b8f5c4d8cb77ed05378e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Piotrowski?= <bpiotrowski@archlinux.org>
Date: Fri, 10 Aug 2018 14:12:40 +0000
Subject: [PATCH] Revert "elf: Correct absolute (SHN_ABS) symbol run-time
calculation [BZ #19818]"
This reverts commit e7feec374c635b6a29d65c39ae5e1855528fed39.
---
elf/Makefile | 14 ++-----------
elf/dl-addr.c | 2 --
elf/tst-absolute-sym-lib.c | 25 ------------------------
elf/tst-absolute-sym-lib.lds | 19 ------------------
elf/tst-absolute-sym.c | 38 ------------------------------------
sysdeps/generic/ldsodefs.h | 3 +--
6 files changed, 3 insertions(+), 98 deletions(-)
delete mode 100644 elf/tst-absolute-sym-lib.c
delete mode 100644 elf/tst-absolute-sym-lib.lds
delete mode 100644 elf/tst-absolute-sym.c
diff --git a/elf/Makefile b/elf/Makefile
index cd0771307f..5084ba4f6f 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -186,7 +186,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-noload \
tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \
- tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note
+ tst-debug1 tst-main1
# reldep9
tests-internal += loadtest unload unload2 circleload1 \
neededtest neededtest2 neededtest3 neededtest4 \
@@ -272,9 +272,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12 \
tst-latepthreadmod $(tst-tls-many-dynamic-modules) \
tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin \
- tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \
- tst-absolute-zero-lib tst-big-note-lib
-
+ tst-main1mod tst-libc_dlvsym-dso
ifeq (yes,$(have-mtls-dialect-gnu2))
tests += tst-gnu2-tls1
modules-names += tst-gnu2-tls1mod
@@ -1465,14 +1463,6 @@ tst-main1-no-pie = yes
LDLIBS-tst-main1 = $(libsupport)
tst-main1mod.so-no-z-defs = yes
-LDLIBS-tst-absolute-sym-lib.so = tst-absolute-sym-lib.lds
-$(objpfx)tst-absolute-sym-lib.so: $(LDLIBS-tst-absolute-sym-lib.so)
-$(objpfx)tst-absolute-sym: $(objpfx)tst-absolute-sym-lib.so
-
-LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
-$(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
-$(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
-
# Both the main program and the DSO for tst-libc_dlvsym need to link
# against libdl.
$(objpfx)tst-libc_dlvsym: $(libdl)
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index e6c7d02094..2250617a73 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -59,7 +59,6 @@ determine_info (const ElfW(Addr) addr, struct link_map *match, Dl_info *info,
we can omit that test here. */
if ((symtab[symndx].st_shndx != SHN_UNDEF
|| symtab[symndx].st_value != 0)
- && symtab[symndx].st_shndx != SHN_ABS
&& ELFW(ST_TYPE) (symtab[symndx].st_info) != STT_TLS
&& DL_ADDR_SYM_MATCH (match, &symtab[symndx],
matchsym, addr)
@@ -92,7 +91,6 @@ determine_info (const ElfW(Addr) addr, struct link_map *match, Dl_info *info,
&& ELFW(ST_TYPE) (symtab->st_info) != STT_TLS
&& (symtab->st_shndx != SHN_UNDEF
|| symtab->st_value != 0)
- && symtab->st_shndx != SHN_ABS
&& DL_ADDR_SYM_MATCH (match, symtab, matchsym, addr)
&& symtab->st_name < strtabsize)
matchsym = (ElfW(Sym) *) symtab;
diff --git a/elf/tst-absolute-sym-lib.c b/elf/tst-absolute-sym-lib.c
deleted file mode 100644
index 912cb0048a..0000000000
--- a/elf/tst-absolute-sym-lib.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* BZ #19818 absolute symbol calculation shared module.
- Copyright (C) 2018 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-extern char absolute;
-
-void *
-get_absolute (void)
-{
- return &absolute;
-}
diff --git a/elf/tst-absolute-sym-lib.lds b/elf/tst-absolute-sym-lib.lds
deleted file mode 100644
index d4a4128514..0000000000
--- a/elf/tst-absolute-sym-lib.lds
+++ /dev/null
@@ -1,19 +0,0 @@
-/* BZ #19818 absolute symbol calculation linker script.
- Copyright (C) 2018 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-"absolute" = 0x55aa;
diff --git a/elf/tst-absolute-sym.c b/elf/tst-absolute-sym.c
deleted file mode 100644
index 111491d159..0000000000
--- a/elf/tst-absolute-sym.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BZ #19818 absolute symbol calculation main executable.
- Copyright (C) 2018 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <support/check.h>
-#include <support/support.h>
-#include <support/test-driver.h>
-
-void *get_absolute (void);
-
-static int
-do_test (void)
-{
- void *ref = (void *) 0x55aa;
- void *ptr;
-
- ptr = get_absolute ();
- if (ptr != ref)
- FAIL_EXIT1 ("Got %p, expected %p\n", ptr, ref);
-
- return 0;
-}
-
-#include <support/test-driver.c>
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 95dc87519b..3cac4fa362 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -72,8 +72,7 @@ typedef struct link_map *lookup_t;
if non-NULL. Don't check for NULL map if MAP_SET is TRUE. */
#define SYMBOL_ADDRESS(map, ref, map_set) \
((ref) == NULL ? 0 \
- : (__glibc_unlikely ((ref)->st_shndx == SHN_ABS) ? 0 \
- : LOOKUP_VALUE_ADDRESS (map, map_set)) + (ref)->st_value)
+ : LOOKUP_VALUE_ADDRESS (map, map_set) + (ref)->st_value)
/* On some architectures a pointer to a function is not just a pointer
to the actual code of the function but rather an architecture
--
2.18.0

View File

@ -1,4 +1,3 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Contributor: Alexander 'hatred' Drozdov <adrozdoff@gmail.com>
# Contributor: toha257 <toha257@gmail.com>
# Contributor: Allan McRae <allan@archlinux.org>
@ -9,26 +8,30 @@
_target=powerpc64le-unknown-linux-gnu
pkgname=${_target}-glibc-headers
pkgver=2.35
pkgrel=2
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3.1
pkgdesc="GNU C Library headers (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=5.17.5")
makedepends=("${_target}-gcc-stage1>=11.1.0" "python")
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage1>=13.2.1" python git)
options=(!buildflags !strip staticlibs)
source=(https://ftp.gnu.org/gnu/glibc/glibc-$pkgver.tar.xz{,.sig}
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
sdt.h
disable-clone3.diff)
fix-malloc-p1.patch
fix-malloc-p2.patch
reenable_DT_HASH.patch)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
sha256sums=('5123732f6b67ccd319305efd399971d58592122bcc2a6518a1bd2510dd0cf52e'
'SKIP'
sha256sums=('SKIP'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'f5df8fc95592cce7825744aeb8c9699a5b4b5b7ccf7bcf554355167c3a7e375e')
'1e22a2226fe308154e70981c0036c7c4ebac488b26b9959cb803d7a3d831d0c4'
'59f37c6f3a27e08d846c1dcb0ac08c1aebb14c11afb9be10652ca1a80fd54c3e'
'cf9fe494f7ec69752a63d1b0a9ad689aa620888ae9b902b6383a6fbc7c1726a7')
prepare() {
mkdir -p glibc-build
@ -48,8 +51,8 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
@ -60,12 +63,18 @@ build() {
--disable-werror
)
case "${CARCH}" in
x86_64) _configure_flags+=(--enable-cet --enable-multi-arch) ;;
powerpc64) _configure_flags+=(--disable-multi-arch --with-cpu=970); CFLAGS='-O2 -pipe' ;;
*) _configure_flags+=(--disable-multi-arch); CFLAGS='-O2 -pipe' ;;
esac
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -75,10 +84,12 @@ build() {
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
export OBJCOPY=${_target}-objcopy
export OBJDUMP=${_target}-objdump
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
@ -86,6 +97,10 @@ build() {
# make some libs and stubs
make csu/subdir_lib
case "${CARCH}" in
powerpc64) sed 's@RTLDLIST=.*@RTLDLIST="/usr/lib/ld64.so.2"@g' -i ${pkgdir}/usr/bin/ldd ;;
esac
}
package() {
@ -96,15 +111,19 @@ package() {
# glibc doesn't support eglibc's install-bootstrap-headers
# Luckily a blank gnu/stubs.h is all we need
touch "$pkgdir/usr/$_target/include/gnu/stubs.h"
touch "$pkgdir/usr/$_target/usr/include/gnu/stubs.h"
mkdir -p "$pkgdir/usr/$_target/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/lib"
mkdir -p "$pkgdir/usr/$_target/usr/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/usr/lib"
# create stub lib
${_target}-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
-o "$pkgdir/usr/$_target/lib/libc.so"
-o "$pkgdir/usr/$_target/usr/lib/libc.so"
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -0,0 +1,294 @@
commit 542b1105852568c3ebc712225ae78b8c8ba31a78
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 11 11:18:17 2023 +0200
malloc: Enable merging of remainders in memalign (bug 30723)
Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator. This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.
Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own. We can still give it back if it can be merged
with the following unused chunk. This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.
Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e2f1a615a4..948f9759af 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1086,6 +1086,11 @@ typedef struct malloc_chunk* mchunkptr;
static void* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr, int);
+static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
+static INTERNAL_SIZE_T _int_free_create_chunk (mstate,
+ mchunkptr, INTERNAL_SIZE_T,
+ mchunkptr, INTERNAL_SIZE_T);
+static void _int_free_maybe_consolidate (mstate, INTERNAL_SIZE_T);
static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
INTERNAL_SIZE_T);
static void* _int_memalign(mstate, size_t, size_t);
@@ -4637,31 +4642,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (!have_lock)
__libc_lock_lock (av->mutex);
- nextchunk = chunk_at_offset(p, size);
-
- /* Lightweight tests: check whether the block is already the
- top block. */
- if (__glibc_unlikely (p == av->top))
- malloc_printerr ("double free or corruption (top)");
- /* Or whether the next chunk is beyond the boundaries of the arena. */
- if (__builtin_expect (contiguous (av)
- && (char *) nextchunk
- >= ((char *) av->top + chunksize(av->top)), 0))
- malloc_printerr ("double free or corruption (out)");
- /* Or whether the block is actually not marked used. */
- if (__glibc_unlikely (!prev_inuse(nextchunk)))
- malloc_printerr ("double free or corruption (!prev)");
-
- nextsize = chunksize(nextchunk);
- if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
- || __builtin_expect (nextsize >= av->system_mem, 0))
- malloc_printerr ("free(): invalid next size (normal)");
+ _int_free_merge_chunk (av, p, size);
- free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
+ if (!have_lock)
+ __libc_lock_unlock (av->mutex);
+ }
+ /*
+ If the chunk was allocated via mmap, release via munmap().
+ */
+
+ else {
+ munmap_chunk (p);
+ }
+}
+
+/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
+ resulting chunk on the appropriate bin list. P must not be on a
+ bin list yet, and it can be in use. */
+static void
+_int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
+{
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+
+ /* Lightweight tests: check whether the block is already the
+ top block. */
+ if (__glibc_unlikely (p == av->top))
+ malloc_printerr ("double free or corruption (top)");
+ /* Or whether the next chunk is beyond the boundaries of the arena. */
+ if (__builtin_expect (contiguous (av)
+ && (char *) nextchunk
+ >= ((char *) av->top + chunksize(av->top)), 0))
+ malloc_printerr ("double free or corruption (out)");
+ /* Or whether the block is actually not marked used. */
+ if (__glibc_unlikely (!prev_inuse(nextchunk)))
+ malloc_printerr ("double free or corruption (!prev)");
+
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
+ || __builtin_expect (nextsize >= av->system_mem, 0))
+ malloc_printerr ("free(): invalid next size (normal)");
+
+ free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
- /* consolidate backward */
- if (!prev_inuse(p)) {
- prevsize = prev_size (p);
+ /* Consolidate backward. */
+ if (!prev_inuse(p))
+ {
+ INTERNAL_SIZE_T prevsize = prev_size (p);
size += prevsize;
p = chunk_at_offset(p, -((long) prevsize));
if (__glibc_unlikely (chunksize(p) != prevsize))
@@ -4669,9 +4695,25 @@ _int_free (mstate av, mchunkptr p, int have_lock)
unlink_chunk (av, p);
}
- if (nextchunk != av->top) {
+ /* Write the chunk header, maybe after merging with the following chunk. */
+ size = _int_free_create_chunk (av, p, size, nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, size);
+}
+
+/* Create a chunk at P of SIZE bytes, with SIZE potentially increased
+ to cover the immediately following chunk NEXTCHUNK of NEXTSIZE
+ bytes (if NEXTCHUNK is unused). The chunk at P is not actually
+ read and does not have to be initialized. After creation, it is
+ placed on the appropriate bin list. The function returns the size
+ of the new chunk. */
+static INTERNAL_SIZE_T
+_int_free_create_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size,
+ mchunkptr nextchunk, INTERNAL_SIZE_T nextsize)
+{
+ if (nextchunk != av->top)
+ {
/* get and clear inuse bit */
- nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
+ bool nextinuse = inuse_bit_at_offset (nextchunk, nextsize);
/* consolidate forward */
if (!nextinuse) {
@@ -4686,8 +4728,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
been given one chance to be used in malloc.
*/
- bck = unsorted_chunks(av);
- fwd = bck->fd;
+ mchunkptr bck = unsorted_chunks (av);
+ mchunkptr fwd = bck->fd;
if (__glibc_unlikely (fwd->bk != bck))
malloc_printerr ("free(): corrupted unsorted chunks");
p->fd = fwd;
@@ -4706,61 +4748,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
check_free_chunk(av, p);
}
- /*
- If the chunk borders the current high end of memory,
- consolidate into top
- */
-
- else {
+ else
+ {
+ /* If the chunk borders the current high end of memory,
+ consolidate into top. */
size += nextsize;
set_head(p, size | PREV_INUSE);
av->top = p;
check_chunk(av, p);
}
- /*
- If freeing a large space, consolidate possibly-surrounding
- chunks. Then, if the total unused topmost memory exceeds trim
- threshold, ask malloc_trim to reduce top.
-
- Unless max_fast is 0, we don't know if there are fastbins
- bordering top, so we cannot tell for sure whether threshold
- has been reached unless fastbins are consolidated. But we
- don't want to consolidate on each free. As a compromise,
- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD
- is reached.
- */
+ return size;
+}
- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
+/* If freeing a large space, consolidate possibly-surrounding
+ chunks. Then, if the total unused topmost memory exceeds trim
+ threshold, ask malloc_trim to reduce top. */
+static void
+_int_free_maybe_consolidate (mstate av, INTERNAL_SIZE_T size)
+{
+ /* Unless max_fast is 0, we don't know if there are fastbins
+ bordering top, so we cannot tell for sure whether threshold has
+ been reached unless fastbins are consolidated. But we don't want
+ to consolidate on each free. As a compromise, consolidation is
+ performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */
+ if (size >= FASTBIN_CONSOLIDATION_THRESHOLD)
+ {
if (atomic_load_relaxed (&av->have_fastchunks))
malloc_consolidate(av);
- if (av == &main_arena) {
+ if (av == &main_arena)
+ {
#ifndef MORECORE_CANNOT_TRIM
- if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ if (chunksize (av->top) >= mp_.trim_threshold)
+ systrim (mp_.top_pad, av);
#endif
- } else {
- /* Always try heap_trim(), even if the top chunk is not
- large, because the corresponding heap might go away. */
- heap_info *heap = heap_for_ptr(top(av));
+ }
+ else
+ {
+ /* Always try heap_trim, even if the top chunk is not large,
+ because the corresponding heap might go away. */
+ heap_info *heap = heap_for_ptr (top (av));
- assert(heap->ar_ptr == av);
- heap_trim(heap, mp_.top_pad);
- }
+ assert (heap->ar_ptr == av);
+ heap_trim (heap, mp_.top_pad);
+ }
}
-
- if (!have_lock)
- __libc_lock_unlock (av->mutex);
- }
- /*
- If the chunk was allocated via mmap, release via munmap().
- */
-
- else {
- munmap_chunk (p);
- }
}
/*
@@ -5221,7 +5254,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
(av != &main_arena ? NON_MAIN_ARENA : 0));
set_inuse_bit_at_offset (newp, newsize);
set_head_size (p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0));
- _int_free (av, p, 1);
+ _int_free_merge_chunk (av, p, leadsize);
p = newp;
assert (newsize >= nb &&
@@ -5232,15 +5265,27 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
if (!chunk_is_mmapped (p))
{
size = chunksize (p);
- if ((unsigned long) (size) > (unsigned long) (nb + MINSIZE))
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (size > nb)
{
remainder_size = size - nb;
- remainder = chunk_at_offset (p, nb);
- set_head (remainder, remainder_size | PREV_INUSE |
- (av != &main_arena ? NON_MAIN_ARENA : 0));
- set_head_size (p, nb);
- _int_free (av, remainder, 1);
- }
+ if (remainder_size >= MINSIZE
+ || nextchunk == av->top
+ || !inuse_bit_at_offset (nextchunk, nextsize))
+ {
+ /* We can only give back the tail if it is larger than
+ MINSIZE, or if the following chunk is unused (top
+ chunk or unused in-heap chunk). Otherwise we would
+ create a chunk that is smaller than MINSIZE. */
+ remainder = chunk_at_offset (p, nb);
+ set_head_size (p, nb);
+ remainder_size = _int_free_create_chunk (av, remainder,
+ remainder_size,
+ nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, remainder_size);
+ }
+ }
}
check_inuse_chunk (av, p);

View File

@ -0,0 +1,249 @@
commit 0dc7fc1cf094406a138e4d1bcf9553e59edcf89d
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Aug 10 19:36:56 2023 +0200
malloc: Remove bin scanning from memalign (bug 30723)
On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%). The tcache
scanning has about 50% success rate, so keep that.
Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests. Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.
Remove leftover variables from _int_free from refactoring in the
same commit.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 948f9759af..d0bbbf3710 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4488,12 +4488,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
{
INTERNAL_SIZE_T size; /* its size */
mfastbinptr *fb; /* associated fastbin */
- mchunkptr nextchunk; /* next contiguous chunk */
- INTERNAL_SIZE_T nextsize; /* its size */
- int nextinuse; /* true if nextchunk is used */
- INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr fwd; /* misc temp for linking */
size = chunksize (p);
@@ -5032,42 +5026,6 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
------------------------------ memalign ------------------------------
*/
-/* Returns 0 if the chunk is not and does not contain the requested
- aligned sub-chunk, else returns the amount of "waste" from
- trimming. NB is the *chunk* byte size, not the user byte
- size. */
-static size_t
-chunk_ok_for_memalign (mchunkptr p, size_t alignment, size_t nb)
-{
- void *m = chunk2mem (p);
- INTERNAL_SIZE_T size = chunksize (p);
- void *aligned_m = m;
-
- if (__glibc_unlikely (misaligned_chunk (p)))
- malloc_printerr ("_int_memalign(): unaligned chunk detected");
-
- aligned_m = PTR_ALIGN_UP (m, alignment);
-
- INTERNAL_SIZE_T front_extra = (intptr_t) aligned_m - (intptr_t) m;
-
- /* We can't trim off the front as it's too small. */
- if (front_extra > 0 && front_extra < MINSIZE)
- return 0;
-
- /* If it's a perfect fit, it's an exception to the return value rule
- (we would return zero waste, which looks like "not usable"), so
- handle it here by returning a small non-zero value instead. */
- if (size == nb && front_extra == 0)
- return 1;
-
- /* If the block we need fits in the chunk, calculate total waste. */
- if (size > nb + front_extra)
- return size - nb;
-
- /* Can't use this chunk. */
- return 0;
-}
-
/* BYTES is user requested bytes, not requested chunksize bytes. */
static void *
_int_memalign (mstate av, size_t alignment, size_t bytes)
@@ -5082,7 +5040,6 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
INTERNAL_SIZE_T size;
- mchunkptr victim;
nb = checked_request2size (bytes);
if (nb == 0)
@@ -5101,129 +5058,13 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
we don't find anything in those bins, the common malloc code will
scan starting at 2x. */
- /* This will be set if we found a candidate chunk. */
- victim = NULL;
-
- /* Fast bins are singly-linked, hard to remove a chunk from the middle
- and unlikely to meet our alignment requirements. We have not done
- any experimentation with searching for aligned fastbins. */
-
- if (av != NULL)
- {
- int first_bin_index;
- int first_largebin_index;
- int last_bin_index;
-
- if (in_smallbin_range (nb))
- first_bin_index = smallbin_index (nb);
- else
- first_bin_index = largebin_index (nb);
-
- if (in_smallbin_range (nb * 2))
- last_bin_index = smallbin_index (nb * 2);
- else
- last_bin_index = largebin_index (nb * 2);
-
- first_largebin_index = largebin_index (MIN_LARGE_SIZE);
-
- int victim_index; /* its bin index */
-
- for (victim_index = first_bin_index;
- victim_index < last_bin_index;
- victim_index ++)
- {
- victim = NULL;
-
- if (victim_index < first_largebin_index)
- {
- /* Check small bins. Small bin chunks are doubly-linked despite
- being the same size. */
-
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
- while (fwd != bck)
- {
- if (chunk_ok_for_memalign (fwd, alignment, nb) > 0)
- {
- victim = fwd;
-
- /* Unlink it */
- victim->fd->bk = victim->bk;
- victim->bk->fd = victim->fd;
- break;
- }
-
- fwd = fwd->fd;
- }
- }
- else
- {
- /* Check large bins. */
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr best = NULL;
- size_t best_size = 0;
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
+ /* Call malloc with worst case padding to hit alignment. */
+ m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
- while (fwd != bck)
- {
- int extra;
-
- if (chunksize (fwd) < nb)
- break;
- extra = chunk_ok_for_memalign (fwd, alignment, nb);
- if (extra > 0
- && (extra <= best_size || best == NULL))
- {
- best = fwd;
- best_size = extra;
- }
+ if (m == 0)
+ return 0; /* propagate failure */
- fwd = fwd->fd;
- }
- victim = best;
-
- if (victim != NULL)
- {
- unlink_chunk (av, victim);
- break;
- }
- }
-
- if (victim != NULL)
- break;
- }
- }
-
- /* Strategy: find a spot within that chunk that meets the alignment
- request, and then possibly free the leading and trailing space.
- This strategy is incredibly costly and can lead to external
- fragmentation if header and footer chunks are unused. */
-
- if (victim != NULL)
- {
- p = victim;
- m = chunk2mem (p);
- set_inuse (p);
- if (av != &main_arena)
- set_non_main_arena (p);
- }
- else
- {
- /* Call malloc with worst case padding to hit alignment. */
-
- m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
-
- if (m == 0)
- return 0; /* propagate failure */
-
- p = mem2chunk (m);
- }
+ p = mem2chunk (m);
if ((((unsigned long) (m)) % alignment) != 0) /* misaligned */
{
diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c
index f229283dbf..ecd6fa249e 100644
--- a/malloc/tst-memalign-2.c
+++ b/malloc/tst-memalign-2.c
@@ -86,7 +86,8 @@ do_test (void)
TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);
}
- /* Test for non-head tcache hits. */
+ /* Test for non-head tcache hits. This exercises the memalign
+ scanning code to find matching allocations. */
for (i = 0; i < array_length (ptr); ++ i)
{
if (i == 4)
@@ -113,7 +114,9 @@ do_test (void)
free (p);
TEST_VERIFY (count > 0);
- /* Large bins test. */
+ /* Large bins test. This verifies that the over-allocated parts
+ that memalign releases for future allocations can be reused by
+ memalign itself at least in some cases. */
for (i = 0; i < LN; ++ i)
{

View File

@ -0,0 +1,28 @@
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
---
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.41.0

View File

@ -8,29 +8,33 @@
_target=powerpc64le-unknown-linux-gnu
pkgname=${_target}-glibc
pkgver=2.35
pkgrel=2
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3.1
pkgdesc="GNU C Library (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=5.17.5")
makedepends=("${_target}-gcc-stage2>=11.3.0" "python")
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage2>=13.2.1" python git)
provides=("${_target}-glibc-headers=${pkgver}" "${_target}-eglibc")
conflicts=("${_target}-glibc-headers" "${_target}-eglibc")
replaces=("${_target}-glibc-headers")
options=(!buildflags !strip staticlibs)
source=(https://ftp.gnu.org/gnu/glibc/glibc-$pkgver.tar.xz{,.sig}
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
sdt.h
disable-clone3.diff)
fix-malloc-p1.patch
fix-malloc-p2.patch
reenable_DT_HASH.patch)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
sha256sums=('5123732f6b67ccd319305efd399971d58592122bcc2a6518a1bd2510dd0cf52e'
'SKIP'
sha256sums=('SKIP'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'f5df8fc95592cce7825744aeb8c9699a5b4b5b7ccf7bcf554355167c3a7e375e')
'1e22a2226fe308154e70981c0036c7c4ebac488b26b9959cb803d7a3d831d0c4'
'59f37c6f3a27e08d846c1dcb0ac08c1aebb14c11afb9be10652ca1a80fd54c3e'
'cf9fe494f7ec69752a63d1b0a9ad689aa620888ae9b902b6383a6fbc7c1726a7')
prepare() {
mkdir -p glibc-build
@ -50,12 +54,16 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
--disable-multi-arch
--enable-kernel=4.4
--enable-multi-arch
--enable-stack-protector=strong
--enable-systemtap
--enable-stack-protector=strong
--enable-stackguard-randomization
--disable-profile
@ -64,10 +72,10 @@ build() {
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -77,19 +85,25 @@ build() {
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
export OBJCOPY=${_target}-objcopy
export OBJDUMP=${_target}-objdump
unset LD_LIBRARY_PATH
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
--build=${CHOST}
--build=${_target}
echo "build-programs=no" >> configparms
make
case "${CARCH}" in
powerpc64) sed 's@RTLDLIST=.*@RTLDLIST="/usr/lib/ld64.so.2"@g' -i ${pkgdir}/usr/bin/ldd ;;
esac
}
package() {
@ -98,8 +112,13 @@ package() {
make install_root="$pkgdir/usr/$_target" install
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Remove unneeded for compilation files
rm -rf "$pkgdir/usr/$_target/"{bin,sbin,etc,share,var}
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -0,0 +1,294 @@
commit 542b1105852568c3ebc712225ae78b8c8ba31a78
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 11 11:18:17 2023 +0200
malloc: Enable merging of remainders in memalign (bug 30723)
Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator. This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.
Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own. We can still give it back if it can be merged
with the following unused chunk. This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.
Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e2f1a615a4..948f9759af 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1086,6 +1086,11 @@ typedef struct malloc_chunk* mchunkptr;
static void* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr, int);
+static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
+static INTERNAL_SIZE_T _int_free_create_chunk (mstate,
+ mchunkptr, INTERNAL_SIZE_T,
+ mchunkptr, INTERNAL_SIZE_T);
+static void _int_free_maybe_consolidate (mstate, INTERNAL_SIZE_T);
static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
INTERNAL_SIZE_T);
static void* _int_memalign(mstate, size_t, size_t);
@@ -4637,31 +4642,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (!have_lock)
__libc_lock_lock (av->mutex);
- nextchunk = chunk_at_offset(p, size);
-
- /* Lightweight tests: check whether the block is already the
- top block. */
- if (__glibc_unlikely (p == av->top))
- malloc_printerr ("double free or corruption (top)");
- /* Or whether the next chunk is beyond the boundaries of the arena. */
- if (__builtin_expect (contiguous (av)
- && (char *) nextchunk
- >= ((char *) av->top + chunksize(av->top)), 0))
- malloc_printerr ("double free or corruption (out)");
- /* Or whether the block is actually not marked used. */
- if (__glibc_unlikely (!prev_inuse(nextchunk)))
- malloc_printerr ("double free or corruption (!prev)");
-
- nextsize = chunksize(nextchunk);
- if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
- || __builtin_expect (nextsize >= av->system_mem, 0))
- malloc_printerr ("free(): invalid next size (normal)");
+ _int_free_merge_chunk (av, p, size);
- free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
+ if (!have_lock)
+ __libc_lock_unlock (av->mutex);
+ }
+ /*
+ If the chunk was allocated via mmap, release via munmap().
+ */
+
+ else {
+ munmap_chunk (p);
+ }
+}
+
+/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
+ resulting chunk on the appropriate bin list. P must not be on a
+ bin list yet, and it can be in use. */
+static void
+_int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
+{
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+
+ /* Lightweight tests: check whether the block is already the
+ top block. */
+ if (__glibc_unlikely (p == av->top))
+ malloc_printerr ("double free or corruption (top)");
+ /* Or whether the next chunk is beyond the boundaries of the arena. */
+ if (__builtin_expect (contiguous (av)
+ && (char *) nextchunk
+ >= ((char *) av->top + chunksize(av->top)), 0))
+ malloc_printerr ("double free or corruption (out)");
+ /* Or whether the block is actually not marked used. */
+ if (__glibc_unlikely (!prev_inuse(nextchunk)))
+ malloc_printerr ("double free or corruption (!prev)");
+
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
+ || __builtin_expect (nextsize >= av->system_mem, 0))
+ malloc_printerr ("free(): invalid next size (normal)");
+
+ free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
- /* consolidate backward */
- if (!prev_inuse(p)) {
- prevsize = prev_size (p);
+ /* Consolidate backward. */
+ if (!prev_inuse(p))
+ {
+ INTERNAL_SIZE_T prevsize = prev_size (p);
size += prevsize;
p = chunk_at_offset(p, -((long) prevsize));
if (__glibc_unlikely (chunksize(p) != prevsize))
@@ -4669,9 +4695,25 @@ _int_free (mstate av, mchunkptr p, int have_lock)
unlink_chunk (av, p);
}
- if (nextchunk != av->top) {
+ /* Write the chunk header, maybe after merging with the following chunk. */
+ size = _int_free_create_chunk (av, p, size, nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, size);
+}
+
+/* Create a chunk at P of SIZE bytes, with SIZE potentially increased
+ to cover the immediately following chunk NEXTCHUNK of NEXTSIZE
+ bytes (if NEXTCHUNK is unused). The chunk at P is not actually
+ read and does not have to be initialized. After creation, it is
+ placed on the appropriate bin list. The function returns the size
+ of the new chunk. */
+static INTERNAL_SIZE_T
+_int_free_create_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size,
+ mchunkptr nextchunk, INTERNAL_SIZE_T nextsize)
+{
+ if (nextchunk != av->top)
+ {
/* get and clear inuse bit */
- nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
+ bool nextinuse = inuse_bit_at_offset (nextchunk, nextsize);
/* consolidate forward */
if (!nextinuse) {
@@ -4686,8 +4728,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
been given one chance to be used in malloc.
*/
- bck = unsorted_chunks(av);
- fwd = bck->fd;
+ mchunkptr bck = unsorted_chunks (av);
+ mchunkptr fwd = bck->fd;
if (__glibc_unlikely (fwd->bk != bck))
malloc_printerr ("free(): corrupted unsorted chunks");
p->fd = fwd;
@@ -4706,61 +4748,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
check_free_chunk(av, p);
}
- /*
- If the chunk borders the current high end of memory,
- consolidate into top
- */
-
- else {
+ else
+ {
+ /* If the chunk borders the current high end of memory,
+ consolidate into top. */
size += nextsize;
set_head(p, size | PREV_INUSE);
av->top = p;
check_chunk(av, p);
}
- /*
- If freeing a large space, consolidate possibly-surrounding
- chunks. Then, if the total unused topmost memory exceeds trim
- threshold, ask malloc_trim to reduce top.
-
- Unless max_fast is 0, we don't know if there are fastbins
- bordering top, so we cannot tell for sure whether threshold
- has been reached unless fastbins are consolidated. But we
- don't want to consolidate on each free. As a compromise,
- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD
- is reached.
- */
+ return size;
+}
- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
+/* If freeing a large space, consolidate possibly-surrounding
+ chunks. Then, if the total unused topmost memory exceeds trim
+ threshold, ask malloc_trim to reduce top. */
+static void
+_int_free_maybe_consolidate (mstate av, INTERNAL_SIZE_T size)
+{
+ /* Unless max_fast is 0, we don't know if there are fastbins
+ bordering top, so we cannot tell for sure whether threshold has
+ been reached unless fastbins are consolidated. But we don't want
+ to consolidate on each free. As a compromise, consolidation is
+ performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */
+ if (size >= FASTBIN_CONSOLIDATION_THRESHOLD)
+ {
if (atomic_load_relaxed (&av->have_fastchunks))
malloc_consolidate(av);
- if (av == &main_arena) {
+ if (av == &main_arena)
+ {
#ifndef MORECORE_CANNOT_TRIM
- if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ if (chunksize (av->top) >= mp_.trim_threshold)
+ systrim (mp_.top_pad, av);
#endif
- } else {
- /* Always try heap_trim(), even if the top chunk is not
- large, because the corresponding heap might go away. */
- heap_info *heap = heap_for_ptr(top(av));
+ }
+ else
+ {
+ /* Always try heap_trim, even if the top chunk is not large,
+ because the corresponding heap might go away. */
+ heap_info *heap = heap_for_ptr (top (av));
- assert(heap->ar_ptr == av);
- heap_trim(heap, mp_.top_pad);
- }
+ assert (heap->ar_ptr == av);
+ heap_trim (heap, mp_.top_pad);
+ }
}
-
- if (!have_lock)
- __libc_lock_unlock (av->mutex);
- }
- /*
- If the chunk was allocated via mmap, release via munmap().
- */
-
- else {
- munmap_chunk (p);
- }
}
/*
@@ -5221,7 +5254,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
(av != &main_arena ? NON_MAIN_ARENA : 0));
set_inuse_bit_at_offset (newp, newsize);
set_head_size (p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0));
- _int_free (av, p, 1);
+ _int_free_merge_chunk (av, p, leadsize);
p = newp;
assert (newsize >= nb &&
@@ -5232,15 +5265,27 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
if (!chunk_is_mmapped (p))
{
size = chunksize (p);
- if ((unsigned long) (size) > (unsigned long) (nb + MINSIZE))
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (size > nb)
{
remainder_size = size - nb;
- remainder = chunk_at_offset (p, nb);
- set_head (remainder, remainder_size | PREV_INUSE |
- (av != &main_arena ? NON_MAIN_ARENA : 0));
- set_head_size (p, nb);
- _int_free (av, remainder, 1);
- }
+ if (remainder_size >= MINSIZE
+ || nextchunk == av->top
+ || !inuse_bit_at_offset (nextchunk, nextsize))
+ {
+ /* We can only give back the tail if it is larger than
+ MINSIZE, or if the following chunk is unused (top
+ chunk or unused in-heap chunk). Otherwise we would
+ create a chunk that is smaller than MINSIZE. */
+ remainder = chunk_at_offset (p, nb);
+ set_head_size (p, nb);
+ remainder_size = _int_free_create_chunk (av, remainder,
+ remainder_size,
+ nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, remainder_size);
+ }
+ }
}
check_inuse_chunk (av, p);

View File

@ -0,0 +1,249 @@
commit 0dc7fc1cf094406a138e4d1bcf9553e59edcf89d
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Aug 10 19:36:56 2023 +0200
malloc: Remove bin scanning from memalign (bug 30723)
On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%). The tcache
scanning has about 50% success rate, so keep that.
Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests. Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.
Remove leftover variables from _int_free from refactoring in the
same commit.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 948f9759af..d0bbbf3710 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4488,12 +4488,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
{
INTERNAL_SIZE_T size; /* its size */
mfastbinptr *fb; /* associated fastbin */
- mchunkptr nextchunk; /* next contiguous chunk */
- INTERNAL_SIZE_T nextsize; /* its size */
- int nextinuse; /* true if nextchunk is used */
- INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr fwd; /* misc temp for linking */
size = chunksize (p);
@@ -5032,42 +5026,6 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
------------------------------ memalign ------------------------------
*/
-/* Returns 0 if the chunk is not and does not contain the requested
- aligned sub-chunk, else returns the amount of "waste" from
- trimming. NB is the *chunk* byte size, not the user byte
- size. */
-static size_t
-chunk_ok_for_memalign (mchunkptr p, size_t alignment, size_t nb)
-{
- void *m = chunk2mem (p);
- INTERNAL_SIZE_T size = chunksize (p);
- void *aligned_m = m;
-
- if (__glibc_unlikely (misaligned_chunk (p)))
- malloc_printerr ("_int_memalign(): unaligned chunk detected");
-
- aligned_m = PTR_ALIGN_UP (m, alignment);
-
- INTERNAL_SIZE_T front_extra = (intptr_t) aligned_m - (intptr_t) m;
-
- /* We can't trim off the front as it's too small. */
- if (front_extra > 0 && front_extra < MINSIZE)
- return 0;
-
- /* If it's a perfect fit, it's an exception to the return value rule
- (we would return zero waste, which looks like "not usable"), so
- handle it here by returning a small non-zero value instead. */
- if (size == nb && front_extra == 0)
- return 1;
-
- /* If the block we need fits in the chunk, calculate total waste. */
- if (size > nb + front_extra)
- return size - nb;
-
- /* Can't use this chunk. */
- return 0;
-}
-
/* BYTES is user requested bytes, not requested chunksize bytes. */
static void *
_int_memalign (mstate av, size_t alignment, size_t bytes)
@@ -5082,7 +5040,6 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
INTERNAL_SIZE_T size;
- mchunkptr victim;
nb = checked_request2size (bytes);
if (nb == 0)
@@ -5101,129 +5058,13 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
we don't find anything in those bins, the common malloc code will
scan starting at 2x. */
- /* This will be set if we found a candidate chunk. */
- victim = NULL;
-
- /* Fast bins are singly-linked, hard to remove a chunk from the middle
- and unlikely to meet our alignment requirements. We have not done
- any experimentation with searching for aligned fastbins. */
-
- if (av != NULL)
- {
- int first_bin_index;
- int first_largebin_index;
- int last_bin_index;
-
- if (in_smallbin_range (nb))
- first_bin_index = smallbin_index (nb);
- else
- first_bin_index = largebin_index (nb);
-
- if (in_smallbin_range (nb * 2))
- last_bin_index = smallbin_index (nb * 2);
- else
- last_bin_index = largebin_index (nb * 2);
-
- first_largebin_index = largebin_index (MIN_LARGE_SIZE);
-
- int victim_index; /* its bin index */
-
- for (victim_index = first_bin_index;
- victim_index < last_bin_index;
- victim_index ++)
- {
- victim = NULL;
-
- if (victim_index < first_largebin_index)
- {
- /* Check small bins. Small bin chunks are doubly-linked despite
- being the same size. */
-
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
- while (fwd != bck)
- {
- if (chunk_ok_for_memalign (fwd, alignment, nb) > 0)
- {
- victim = fwd;
-
- /* Unlink it */
- victim->fd->bk = victim->bk;
- victim->bk->fd = victim->fd;
- break;
- }
-
- fwd = fwd->fd;
- }
- }
- else
- {
- /* Check large bins. */
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr best = NULL;
- size_t best_size = 0;
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
+ /* Call malloc with worst case padding to hit alignment. */
+ m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
- while (fwd != bck)
- {
- int extra;
-
- if (chunksize (fwd) < nb)
- break;
- extra = chunk_ok_for_memalign (fwd, alignment, nb);
- if (extra > 0
- && (extra <= best_size || best == NULL))
- {
- best = fwd;
- best_size = extra;
- }
+ if (m == 0)
+ return 0; /* propagate failure */
- fwd = fwd->fd;
- }
- victim = best;
-
- if (victim != NULL)
- {
- unlink_chunk (av, victim);
- break;
- }
- }
-
- if (victim != NULL)
- break;
- }
- }
-
- /* Strategy: find a spot within that chunk that meets the alignment
- request, and then possibly free the leading and trailing space.
- This strategy is incredibly costly and can lead to external
- fragmentation if header and footer chunks are unused. */
-
- if (victim != NULL)
- {
- p = victim;
- m = chunk2mem (p);
- set_inuse (p);
- if (av != &main_arena)
- set_non_main_arena (p);
- }
- else
- {
- /* Call malloc with worst case padding to hit alignment. */
-
- m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
-
- if (m == 0)
- return 0; /* propagate failure */
-
- p = mem2chunk (m);
- }
+ p = mem2chunk (m);
if ((((unsigned long) (m)) % alignment) != 0) /* misaligned */
{
diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c
index f229283dbf..ecd6fa249e 100644
--- a/malloc/tst-memalign-2.c
+++ b/malloc/tst-memalign-2.c
@@ -86,7 +86,8 @@ do_test (void)
TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);
}
- /* Test for non-head tcache hits. */
+ /* Test for non-head tcache hits. This exercises the memalign
+ scanning code to find matching allocations. */
for (i = 0; i < array_length (ptr); ++ i)
{
if (i == 4)
@@ -113,7 +114,9 @@ do_test (void)
free (p);
TEST_VERIFY (count > 0);
- /* Large bins test. */
+ /* Large bins test. This verifies that the over-allocated parts
+ that memalign releases for future allocations can be reused by
+ memalign itself at least in some cases. */
for (i = 0; i < LN; ++ i)
{

View File

@ -0,0 +1,28 @@
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
---
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.41.0

View File

@ -0,0 +1,66 @@
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Contributor: Alexander 'hatred' Drozdov <adrozdoff@gmail.com>
# Contributor: toha257 <toha257@gmail.com>
# Contributor: Allan McRae <allan@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Kevin Mihelich <kevin@archlinuxarm.org>
# Contributor: Tavian Barnes <tavianator@tavianator.com>
# Maintainer: Stefan Schmidt <thrimbor.github@gmail.com>
_target=powerpc64le-unknown-linux-gnu
pkgname=${_target}-libxcrypt
pkgver=4.4.36
pkgrel=1.1
pkgdesc='Modern library for one-way hashing of passwords'
arch=(any)
url='https://github.com/besser82/libxcrypt'
license=('LGPL')
depends=("${_target}-glibc>=2.38")
makedepends=("${_target}-gcc-stage2")
validpgpkeys=('678CE3FEE430311596DB8C16F52E98007594C21D') # Björn 'besser82' Esser
source=("${url}/releases/download/v${pkgver}/libxcrypt-${pkgver}.tar.xz"{,.asc})
sha256sums=('e5e1f4caee0a01de2aee26e3138807d6d3ca2b8e67287966d1fefd65e1fd8943'
'SKIP')
build() {
mkdir build-libxcrypt build-libxcrypt-compat
# don't polute cross cflags
unset CFLAGS CXXFLAGS
export CFLAGS="-O2 -pipe"
export CXXFLAGS="-O2 -pipe"
export CC=${_target}-gcc
cd "${srcdir}/build-libxcrypt/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
--enable-obsolete-api=no \
--disable-failure-tokens \
--target=${_target} \
--host=${_target}
make
cd "${srcdir}/build-libxcrypt-compat/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
--enable-obsolete-api=glibc \
--disable-failure-tokens \
--target=${_target} \
--host=${_target}
make
}
package() {
cd ${srcdir}/build-libxcrypt/
make DESTDIR="${pkgdir}/usr/${_target}/" install
cd ${srcdir}/build-libxcrypt-compat/
make DESTDIR="${pkgdir}/usr/${_target}/" install
}

View File

@ -9,15 +9,15 @@
_target_arch=powerpc64le
_target=${_target_arch}-unknown-linux-gnu
pkgname=${_target}-linux-api-headers
pkgver=5.17.5
pkgrel=1
pkgver=6.4
pkgrel=2
pkgdesc="Kernel headers sanitized for use in userspace (${_target})"
arch=(any)
url='http://www.gnu.org/software/libc'
license=(GPL2)
makedepends=(rsync make)
source=(https://www.kernel.org/pub/linux/kernel/v5.x/linux-${pkgver}.tar.xz)
sha256sums=('9bbcd185b94436f9c8fe977fa0e862f60d34003562327fcebb27c9fa342fe987')
source=(https://www.kernel.org/pub/linux/kernel/v6.x/linux-${pkgver}.tar.xz)
sha256sums=('8fa0588f0c2ceca44cac77a0e39ba48c9f00a6b9dc69761c02a5d3efac8da7f3')
validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E') # Greg Kroah-Hartman
@ -29,10 +29,10 @@ build() {
package() {
cd linux-${pkgver}
make INSTALL_HDR_PATH="$pkgdir/usr/$_target" ARCH=powerpc headers_install
make INSTALL_HDR_PATH="$pkgdir/usr/$_target/usr" ARCH=powerpc headers_install
# use headers from libdrm
rm -rf "$pkgdir/usr/$_target/include/drm"
rm -rf "$pkgdir/usr/$_target/usr/include/drm"
# clean-up unnecessary files generated during install
find ${pkgdir} \( -name .install -o -name ..install.cmd \) -delete

View File

@ -0,0 +1,58 @@
# Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
_arch=powerpc64le
_target=${_arch}-unknown-linux-gnu
pkgname=${_target}-pacman
pkgver=2023.09
pkgrel=1
pkgdesc="Pacman configurations for ${_target} to install dependencies for cross-compilation"
arch=(any)
url="https://archlinuxpower.org"
depends=(
${_target}-gcc
${_target}-glibc
)
source=(pacman-arch.sh
pacman.conf
fakebase.desc)
backup=(etc/pacman-${_arch}.conf)
sha256sums=('5fd18c74198312560579d900af2b0e52b757b47fb70e4f78e995b29cf0b5ee7a'
'6be22d041e30ca7475d7700ff35b4ca34ad62f3ad415b8f429edbbc03c295d0e'
'c7d16160e0d91becce572abee7954e61411c729eec7a367a96335fba6bc470f1')
prepare() {
if [ -d /usr/${_target}/var/lib/pacman ]; then
echo "Remove existing synced dbs etc from /usr/${_target}/var/lib/pacman/ and try again"
exit 1
fi
}
build() {
sed "s/@@CARCH@@/${_arch}/g" -i pacman-arch.sh
sed "s/@@CHOST_PREFIX@@/\/usr\/${_target}\//g" -i pacman.conf
sed "s/@@TIMESTAMP@@/$(date "+%s")/g" -i fakebase.desc
sed "s/@@FAKEBASE_VERSION@@/${pkgver}-${pkgrel}/g" -i fakebase.desc
}
package() {
install -d -m755 ${pkgdir}/usr/bin
install -m755 ${srcdir}/pacman-arch.sh ${pkgdir}/usr/bin/pacman-${_arch}
install -d -m 755 ${pkgdir}/etc
install -m644 ${srcdir}/pacman.conf ${pkgdir}/etc/pacman-${_arch}.conf
# fake that we install a few basic packages via pacman
install -d -m 755 ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}
pushd /usr/${_target}/
shopt -s dotglob globstar
printf '%s\0' **/* | LANG=C bsdtar -cnf - --format=mtree --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' --null --files-from - --exclude .MTREE | gzip -c -f -n > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/mtree
shopt -u dotglob globstar
echo '%FILES%' > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
find | sed 's@^./@@g' | grep -v '^\.$' | grep -v '.*mtree$' >> ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
echo 9 > ${pkgdir}/usr/${_target}/var/lib/pacman/local/ALPM_DB_VERSION
install -m644 ${srcdir}/fakebase.desc ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/desc
popd
}

View File

@ -0,0 +1,42 @@
%NAME%
fakebase
%VERSION%
@@FAKEBASE_VERSION@@
%DESC%
Masking that some packages from crosscompilers on the host
%URL%
https://archlinuxpower.org
%ARCH%
any
%BUILDDATE%
@@TIMESTAMP@@
%INSTALLDATE%
@@TIMESTAMP@@
%PACKAGER%
Alexander Baldeck <alex.bldck@gmail.com>
%SIZE%
10
%LICENSE%
GPL
%VALIDATION%
sha256
%PROVIDES%
binutils
filesystem
gcc
gcc-libs
glibc
libxcrypt
linux-api-headers
zlib

View File

@ -0,0 +1,3 @@
#!/bin/sh
pacman --config /etc/pacman-@@CARCH@@.conf $@

View File

@ -0,0 +1,96 @@
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
RootDir = @@CHOST_PREFIX@@
DBPath = @@CHOST_PREFIX@@/var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = powerpc
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
#Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
#ParallelDownloads = 5
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[repo-local-any]
SigLevel = Never
Server = http://172.23.23.10/repo/any
[repo-local]
SigLevel = Never
Server = http://172.23.23.10/repo/$arch
[testing-any]
Server = https://repo.archlinuxpower.org/testing/any
[testing]
Server = https://repo.archlinuxpower.org/testing/$arch
[base-any]
Server = https://repo.archlinuxpower.org/base/any
[base]
Server = https://repo.archlinuxpower.org/base/$arch
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

View File

@ -7,12 +7,11 @@ _target=riscv64-unknown-linux-gnu
pkgname=$_target-binutils
pkgver=2.41
_commit=31b78cc991781265d9404bd55151691bedd6d556
pkgrel=3
pkgdesc='Assemble and manipulate binary and object files for 32-bit and 64-bit RISC-V'
pkgrel=3.1
pkgdesc='Assemble and manipulate binary and object files for riscv64'
arch=(x86_64 powerpc64le powerpc64 powerpc)
url='https://gnu.org/software/binutils/'
license=(GPL)
groups=(risc-v)
depends=(glibc zlib libelf jansson)
makedepends=(git setconf)
source=(git+https://sourceware.org/git/binutils-gdb.git#commit=${_commit}
@ -22,7 +21,7 @@ sha512sums=('SKIP'
prepare() {
cd ${srcdir}
[[ ! -d binutils-gdb ]] && ln -s binutils-$pkgver binutils-gdb
[[ ! -d binutils-gdb ]] && ln -s binutils-$pkgver binutils-gdb
cd "binutils-gdb"
# Creds @Fedora
@ -49,11 +48,12 @@ build() {
--target=$_target \
--with-gnu-as \
--with-gnu-ld \
--with-sysroot=/usr/$_target \
--with-sysroot=/usr/$_target/usr \
--with-system-zlib \
--disable-werror \
--disable-sim \
--enable-colored-disassembly
--enable-colored-disassembly \
--enable-targets=no
make
}
@ -66,10 +66,13 @@ check() {
package() {
make -C "binutils-gdb" DESTDIR="$pkgdir" install
install -d -m755 "$pkgdir/usr/$_target/usr"
mv $pkgdir/usr/$_target/{bin,lib} "$pkgdir/usr/$_target/usr/"
# Remove info documents that conflict with host version
rm -r "$pkgdir/usr/share/info"
rm -r "$pkgdir/usr/share/gdb"
rm "$pkgdir//usr/include/gdb/jit-reader.h"
rm "$pkgdir/usr/include/gdb/jit-reader.h"
rm "$pkgdir"/usr/lib/bfd-plugins/libdep.so
}

View File

@ -9,25 +9,27 @@
_target=riscv64-unknown-linux-gnu
pkgname=${_target}-gcc-stage2
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection. Stage 2 for toolchain building (${_target})"
arch=(x86_64 powerpc64le powerpc64 powerpc)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=("${_target}-binutils>=2.41" "${_target}-glibc-headers>=2.38" libmpc zlib)
makedepends=(git)
options=(!emptydirs !distcc !strip)
options=(!emptydirs !strip)
conflicts=("${_target}-gcc-stage1")
replaces=("${_target}-gcc-stage1")
provides=("${_target}-gcc-stage1=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -39,6 +41,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -85,7 +90,9 @@ build() {
--enable-default-ssp \
--target=${_target} \
--host=${CHOST} \
--build=${CHOST}
--build=${CHOST} \
--enable-secureplt
make STAGE1_CFLAGS="-O2" all-gcc all-target-libgcc
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -9,26 +9,28 @@
_target=riscv64-unknown-linux-gnu
pkgname="${_target}-gcc"
pkgver=13.2.1
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3
_majorver=${pkgver%%.*}
_commit=860b0f0ef787f756c0e293671b4c4622dff63a79
pkgrel=3.2
pkgdesc="The GNU Compiler Collection (${_target})"
arch=(x86_64 powerpc64le powerpc64 powerpc)
license=(GPL LGPL FDL custom)
url='http://gcc.gnu.org'
depends=("${_target}-binutils>=2.39-1" "${_target}-glibc>=2.36-2" libmpc elfutils zlib)
depends=("${_target}-binutils>=2.41" "${_target}-glibc>=2.38" "${_target}-libxcrypt" libmpc elfutils zlib)
makedepends=(git)
checkdepends=(dejagnu inetutils)
options=(!emptydirs !distcc !strip)
conflicts=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
replaces=("${_target}-gcc-stage1" "${_target}-gcc-stage2")
provides=("${_target}-gcc-stage1=${pkgver}" "${_target}-gcc-stage2=${pkgver}")
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit})
source=(git+https://sourceware.org/git/gcc.git#commit=${_commit}
gcc11-Wno-format-security.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
86CFFCA918CF3AF47147588051E8B148A9999C34 # evangelos@foutrelis.com
13975A70E63C361C73AE69EF6EEB81F8981C74C7 # richard.guenther@gmail.com
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62) # Jakub Jelinek <jakub@redhat.com>
sha256sums=('SKIP')
sha256sums=('SKIP'
'504e4b5a08eb25b6c35f19fdbe0c743ae4e9015d0af4759e74150006c283585e')
prepare() {
[[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
@ -40,6 +42,9 @@ prepare() {
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
# configure.ac: When adding -Wno-format, also add -Wno-format-security
patch -Np0 < "$srcdir/gcc11-Wno-format-security.patch"
mkdir -p "$srcdir/gcc-build"
}
@ -62,7 +67,7 @@ build() {
--with-ld=/usr/bin/${_target}-ld \
--libdir=/usr/lib --libexecdir=/usr/lib \
--disable-nls \
--enable-languages=c,c++ \
--enable-languages=c,c++,lto \
--enable-shared \
--enable-threads=posix \
--with-system-zlib \
@ -86,9 +91,9 @@ build() {
--target=${_target} \
--host=${CHOST} \
--build=${CHOST} \
--enable-secureplt \
--with-build-config=bootstrap-lto \
--enable-link-serialization=1
--enable-link-serialization=1 \
--enable-secureplt
make STAGE1_CFLAGS="${CFLAGS}" STAGE2_CFLAGS="${CFLAGS}"
}
@ -105,4 +110,7 @@ package() {
strip "$pkgdir/usr/bin/"* 2>/dev/null || true
find "$pkgdir/usr/lib" -type f -exec /usr/bin/${_target}-strip \
--strip-unneeded {} \; 2>/dev/null || true
install -d -m 755 "$pkgdir/usr/$_target/usr/lib"
mv "$pkgdir/usr/$_target/lib" "$pkgdir/usr/$_target/usr/"
}

View File

@ -0,0 +1,27 @@
2017-02-25 Jakub Jelinek <jakub@redhat.com>
* configure.ac: When adding -Wno-format, also add -Wno-format-security.
* configure: Regenerated.
--- gcc/configure.ac.jj 2017-02-13 12:20:53.000000000 +0100
+++ gcc/configure.ac 2017-02-25 12:42:32.859175403 +0100
@@ -480,7 +480,7 @@ AC_ARG_ENABLE(build-format-warnings,
AS_HELP_STRING([--disable-build-format-warnings],[don't use -Wformat while building GCC]),
[],[enable_build_format_warnings=yes])
AS_IF([test $enable_build_format_warnings = no],
- [wf_opt=-Wno-format],[wf_opt=])
+ [wf_opt="-Wno-format -Wno-format-security"],[wf_opt=])
ACX_PROG_CXX_WARNING_OPTS(
m4_quote(m4_do([-W -Wall -Wno-narrowing -Wwrite-strings ],
[-Wcast-qual -Wno-error=format-diag $wf_opt])),
--- gcc/configure.jj 2017-02-13 12:20:52.000000000 +0100
+++ gcc/configure 2017-02-25 12:42:50.041946391 +0100
@@ -6647,7 +6647,7 @@ else
fi
if test $enable_build_format_warnings = no; then :
- wf_opt=-Wno-format
+ wf_opt="-Wno-format -Wno-format-security"
else
wf_opt=
fi

View File

@ -10,13 +10,13 @@ _target=riscv64-unknown-linux-gnu
pkgname=${_target}-glibc-headers
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3
pkgrel=3.1
pkgdesc="GNU C Library headers (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=6.3")
makedepends=("${_target}-gcc-stage1>=13.1.1" python git)
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage1>=13.2.1" python git)
options=(!buildflags !strip staticlibs)
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
@ -45,8 +45,8 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
@ -57,12 +57,17 @@ build() {
--disable-werror
)
case "${CARCH}" in
x86_64) _configure_flags+=(--enable-cet --enable-multi-arch) ;;
*) _configure_flags+=(--disable-multi-arch); CFLAGS='-O2 -pipe' ;;
esac
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -74,8 +79,8 @@ build() {
export RANLIB=${_target}-ranlib
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
@ -93,15 +98,19 @@ package() {
# glibc doesn't support eglibc's install-bootstrap-headers
# Luckily a blank gnu/stubs.h is all we need
touch "$pkgdir/usr/$_target/include/gnu/stubs.h"
touch "$pkgdir/usr/$_target/usr/include/gnu/stubs.h"
mkdir -p "$pkgdir/usr/$_target/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/lib"
mkdir -p "$pkgdir/usr/$_target/usr/lib"
cp csu/crt1.o csu/crti.o csu/crtn.o "$pkgdir/usr/$_target/usr/lib"
# create stub lib
${_target}-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
-o "$pkgdir/usr/$_target/lib/libc.so"
-o "$pkgdir/usr/$_target/usr/lib/libc.so"
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -1,145 +0,0 @@
From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 29 Apr 2022 16:37:51 +0200
Subject: [PATCH] Do not use --hash-style=both for building glibc shared
objects
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
Makeconfig | 9 +++++++++
Makerules | 7 +++++++
config.make.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
diff --git b/Makeconfig a/Makeconfig
index 760f14e92f..0aa5fb0099 100644
--- b/Makeconfig
+++ a/Makeconfig
@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
ifeq (no,$(build-pie-default))
pie-default = $(no-pie-ccflag)
else # build-pie-default
diff --git b/Makerules a/Makerules
index 354528b8c7..428464f092 100644
--- b/Makerules
+++ a/Makerules
@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
-Wl,--verbose 2>/dev/null | \
sed > $@T \
-e '/^=========/,/^=========/!d;/^=========/d' \
+ $(if $(filter yes,$(have-hash-style)), \
+ -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
+ -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+ , \
+ -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ ) \
-e 's/^.*\*(\.dynbss).*$$/& \
PROVIDE(__start___libc_freeres_ptrs = .); \
*(__libc_freeres_ptrs) \
diff --git b/config.make.in a/config.make.in
index fff4c78dd0..bf728c71c0 100644
--- b/config.make.in
+++ a/config.make.in
@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
+have-hash-style = @libc_cv_hashstyle@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
have-loop-to-function = @libc_cv_cc_loop_to_function@
diff --git b/configure a/configure
index 716dc041b6..5a730dc5fc 100755
--- b/configure
+++ a/configure
@@ -622,6 +622,7 @@ libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
fno_unit_at_a_time
libc_cv_has_glob_dat
+libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
ASFLAGS_config
@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
+$as_echo_n "checking for --hash-style option... " >&6; }
+if ${libc_cv_hashstyle+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
+$as_echo "$libc_cv_hashstyle" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
if ${libc_cv_has_glob_dat+:} false; then :
diff --git b/configure.ac a/configure.ac
index d08ad4d64e..a045f6608e 100644
--- b/configure.ac
+++ a/configure.ac
@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for --hash-style option,
+ libc_cv_hashstyle, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_hashstyle)
+
AC_CACHE_CHECK(for GLOB_DAT reloc,
libc_cv_has_glob_dat, [dnl
cat > conftest.c <<EOF
--
2.37.1

View File

@ -10,25 +10,31 @@ _target=riscv64-unknown-linux-gnu
pkgname=${_target}-glibc
pkgver=2.38
_commit=6b99458d197ab779ebb6ff632c168e2cbfa4f543
pkgrel=3
pkgrel=3.1
pkgdesc="GNU C Library (${_target})"
arch=('any')
url="http://www.gnu.org/software/libc/"
license=(GPL LGPL)
depends=("${_target}-linux-api-headers>=5.18.15")
makedepends=("${_target}-gcc-stage2>=12.2.1" "python" "git")
depends=("${_target}-linux-api-headers>=6.4")
makedepends=("${_target}-gcc-stage2>=13.2.1" python git)
provides=("${_target}-glibc-headers=${pkgver}" "${_target}-eglibc")
conflicts=("${_target}-glibc-headers" "${_target}-eglibc")
replaces=("${_target}-glibc-headers")
options=(!buildflags !strip staticlibs)
source=(git+https://sourceware.org/git/glibc.git#commit=${_commit}
sdt-config.h
sdt.h)
sdt.h
fix-malloc-p1.patch
fix-malloc-p2.patch
reenable_DT_HASH.patch)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8 # Carlos O'Donell
BC7C7372637EC10C57D7AA6579C43DFBF1CF2187) # Siddhesh Poyarekar
sha256sums=('SKIP'
'cdc234959c6fdb43f000d3bb7d1080b0103f4080f5e67bcfe8ae1aaf477812f0'
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70')
'774061aff612a377714a509918a9e0e0aafce708b87d2d7e06b1bd1f6542fe70'
'1e22a2226fe308154e70981c0036c7c4ebac488b26b9959cb803d7a3d831d0c4'
'59f37c6f3a27e08d846c1dcb0ac08c1aebb14c11afb9be10652ca1a80fd54c3e'
'cf9fe494f7ec69752a63d1b0a9ad689aa620888ae9b902b6383a6fbc7c1726a7')
prepare() {
mkdir -p glibc-build
@ -48,12 +54,16 @@ prepare() {
build() {
local _configure_flags=(
--prefix=/
--with-headers=/usr/${_target}/include
--prefix=/usr
--with-headers=/usr/${_target}/usr/include
--enable-add-ons
--enable-bind-now
--enable-lock-elision
--disable-multi-arch
--enable-kernel=4.4
--enable-multi-arch
--enable-stack-protector=strong
--enable-systemtap
--enable-stack-protector=strong
--enable-stackguard-randomization
--disable-profile
@ -62,10 +72,10 @@ build() {
cd glibc-build
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/bin" >> configparms
echo "rootsbindir=/bin" >> configparms
echo "slibdir=/usr/lib" >> configparms
echo "rtlddir=/usr/lib" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/bin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
@ -75,16 +85,18 @@ build() {
export CXX=${_target}-g++
export AR=${_target}-ar
export RANLIB=${_target}-ranlib
export OBJCOPY=${_target}-objcopy
export OBJDUMP=${_target}-objdump
unset LD_LIBRARY_PATH
"$srcdir/glibc/configure" \
--libdir=/lib \
--libexecdir=/lib \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
${_configure_flags[@]} \
--target=${_target} \
--host=${_target} \
--build=${CHOST}
--build=${_target}
echo "build-programs=no" >> configparms
make
@ -96,8 +108,13 @@ package() {
make install_root="$pkgdir/usr/$_target" install
mkdir -p "$pkgdir/usr/$_target/usr"
ln -s ../{include,lib} "$pkgdir/usr/$_target/usr"
ln -s /usr/$_target/usr/lib "$pkgdir/usr/$_target/"
# Remove unneeded for compilation files
rm -rf "$pkgdir/usr/$_target/"{bin,sbin,etc,share,var}
# Provide tracing probes to libstdc++ for exceptions, possibly for other
# libraries too. Useful for gdb's catch command.
install -Dm644 "${srcdir}"/sdt.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt.h
install -Dm644 "${srcdir}"/sdt-config.h "${pkgdir}"/usr/${_target}/usr/include/sys/sdt-config.h
}

View File

@ -1,22 +0,0 @@
diff --git a/sysdeps/unix/sysv/linux/clone-internal.c b/sysdeps/unix/sysv/linux/clone-internal.c
index 1e7a8f6b35..4046c81180 100644
--- a/sysdeps/unix/sysv/linux/clone-internal.c
+++ b/sysdeps/unix/sysv/linux/clone-internal.c
@@ -48,17 +48,6 @@ __clone_internal (struct clone_args *cl_args,
int (*func) (void *arg), void *arg)
{
int ret;
-#ifdef HAVE_CLONE3_WRAPPER
- /* Try clone3 first. */
- int saved_errno = errno;
- ret = __clone3 (cl_args, sizeof (*cl_args), func, arg);
- if (ret != -1 || errno != ENOSYS)
- return ret;
-
- /* NB: Restore errno since errno may be checked against non-zero
- return value. */
- __set_errno (saved_errno);
-#endif
/* Map clone3 arguments to clone arguments. NB: No need to check
invalid clone3 specific bits in flags nor exit_signal since this

View File

@ -0,0 +1,294 @@
commit 542b1105852568c3ebc712225ae78b8c8ba31a78
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Aug 11 11:18:17 2023 +0200
malloc: Enable merging of remainders in memalign (bug 30723)
Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator. This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.
Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own. We can still give it back if it can be merged
with the following unused chunk. This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.
Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e2f1a615a4..948f9759af 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1086,6 +1086,11 @@ typedef struct malloc_chunk* mchunkptr;
static void* _int_malloc(mstate, size_t);
static void _int_free(mstate, mchunkptr, int);
+static void _int_free_merge_chunk (mstate, mchunkptr, INTERNAL_SIZE_T);
+static INTERNAL_SIZE_T _int_free_create_chunk (mstate,
+ mchunkptr, INTERNAL_SIZE_T,
+ mchunkptr, INTERNAL_SIZE_T);
+static void _int_free_maybe_consolidate (mstate, INTERNAL_SIZE_T);
static void* _int_realloc(mstate, mchunkptr, INTERNAL_SIZE_T,
INTERNAL_SIZE_T);
static void* _int_memalign(mstate, size_t, size_t);
@@ -4637,31 +4642,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (!have_lock)
__libc_lock_lock (av->mutex);
- nextchunk = chunk_at_offset(p, size);
-
- /* Lightweight tests: check whether the block is already the
- top block. */
- if (__glibc_unlikely (p == av->top))
- malloc_printerr ("double free or corruption (top)");
- /* Or whether the next chunk is beyond the boundaries of the arena. */
- if (__builtin_expect (contiguous (av)
- && (char *) nextchunk
- >= ((char *) av->top + chunksize(av->top)), 0))
- malloc_printerr ("double free or corruption (out)");
- /* Or whether the block is actually not marked used. */
- if (__glibc_unlikely (!prev_inuse(nextchunk)))
- malloc_printerr ("double free or corruption (!prev)");
-
- nextsize = chunksize(nextchunk);
- if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
- || __builtin_expect (nextsize >= av->system_mem, 0))
- malloc_printerr ("free(): invalid next size (normal)");
+ _int_free_merge_chunk (av, p, size);
- free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
+ if (!have_lock)
+ __libc_lock_unlock (av->mutex);
+ }
+ /*
+ If the chunk was allocated via mmap, release via munmap().
+ */
+
+ else {
+ munmap_chunk (p);
+ }
+}
+
+/* Try to merge chunk P of SIZE bytes with its neighbors. Put the
+ resulting chunk on the appropriate bin list. P must not be on a
+ bin list yet, and it can be in use. */
+static void
+_int_free_merge_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size)
+{
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+
+ /* Lightweight tests: check whether the block is already the
+ top block. */
+ if (__glibc_unlikely (p == av->top))
+ malloc_printerr ("double free or corruption (top)");
+ /* Or whether the next chunk is beyond the boundaries of the arena. */
+ if (__builtin_expect (contiguous (av)
+ && (char *) nextchunk
+ >= ((char *) av->top + chunksize(av->top)), 0))
+ malloc_printerr ("double free or corruption (out)");
+ /* Or whether the block is actually not marked used. */
+ if (__glibc_unlikely (!prev_inuse(nextchunk)))
+ malloc_printerr ("double free or corruption (!prev)");
+
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (__builtin_expect (chunksize_nomask (nextchunk) <= CHUNK_HDR_SZ, 0)
+ || __builtin_expect (nextsize >= av->system_mem, 0))
+ malloc_printerr ("free(): invalid next size (normal)");
+
+ free_perturb (chunk2mem(p), size - CHUNK_HDR_SZ);
- /* consolidate backward */
- if (!prev_inuse(p)) {
- prevsize = prev_size (p);
+ /* Consolidate backward. */
+ if (!prev_inuse(p))
+ {
+ INTERNAL_SIZE_T prevsize = prev_size (p);
size += prevsize;
p = chunk_at_offset(p, -((long) prevsize));
if (__glibc_unlikely (chunksize(p) != prevsize))
@@ -4669,9 +4695,25 @@ _int_free (mstate av, mchunkptr p, int have_lock)
unlink_chunk (av, p);
}
- if (nextchunk != av->top) {
+ /* Write the chunk header, maybe after merging with the following chunk. */
+ size = _int_free_create_chunk (av, p, size, nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, size);
+}
+
+/* Create a chunk at P of SIZE bytes, with SIZE potentially increased
+ to cover the immediately following chunk NEXTCHUNK of NEXTSIZE
+ bytes (if NEXTCHUNK is unused). The chunk at P is not actually
+ read and does not have to be initialized. After creation, it is
+ placed on the appropriate bin list. The function returns the size
+ of the new chunk. */
+static INTERNAL_SIZE_T
+_int_free_create_chunk (mstate av, mchunkptr p, INTERNAL_SIZE_T size,
+ mchunkptr nextchunk, INTERNAL_SIZE_T nextsize)
+{
+ if (nextchunk != av->top)
+ {
/* get and clear inuse bit */
- nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
+ bool nextinuse = inuse_bit_at_offset (nextchunk, nextsize);
/* consolidate forward */
if (!nextinuse) {
@@ -4686,8 +4728,8 @@ _int_free (mstate av, mchunkptr p, int have_lock)
been given one chance to be used in malloc.
*/
- bck = unsorted_chunks(av);
- fwd = bck->fd;
+ mchunkptr bck = unsorted_chunks (av);
+ mchunkptr fwd = bck->fd;
if (__glibc_unlikely (fwd->bk != bck))
malloc_printerr ("free(): corrupted unsorted chunks");
p->fd = fwd;
@@ -4706,61 +4748,52 @@ _int_free (mstate av, mchunkptr p, int have_lock)
check_free_chunk(av, p);
}
- /*
- If the chunk borders the current high end of memory,
- consolidate into top
- */
-
- else {
+ else
+ {
+ /* If the chunk borders the current high end of memory,
+ consolidate into top. */
size += nextsize;
set_head(p, size | PREV_INUSE);
av->top = p;
check_chunk(av, p);
}
- /*
- If freeing a large space, consolidate possibly-surrounding
- chunks. Then, if the total unused topmost memory exceeds trim
- threshold, ask malloc_trim to reduce top.
-
- Unless max_fast is 0, we don't know if there are fastbins
- bordering top, so we cannot tell for sure whether threshold
- has been reached unless fastbins are consolidated. But we
- don't want to consolidate on each free. As a compromise,
- consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD
- is reached.
- */
+ return size;
+}
- if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) {
+/* If freeing a large space, consolidate possibly-surrounding
+ chunks. Then, if the total unused topmost memory exceeds trim
+ threshold, ask malloc_trim to reduce top. */
+static void
+_int_free_maybe_consolidate (mstate av, INTERNAL_SIZE_T size)
+{
+ /* Unless max_fast is 0, we don't know if there are fastbins
+ bordering top, so we cannot tell for sure whether threshold has
+ been reached unless fastbins are consolidated. But we don't want
+ to consolidate on each free. As a compromise, consolidation is
+ performed if FASTBIN_CONSOLIDATION_THRESHOLD is reached. */
+ if (size >= FASTBIN_CONSOLIDATION_THRESHOLD)
+ {
if (atomic_load_relaxed (&av->have_fastchunks))
malloc_consolidate(av);
- if (av == &main_arena) {
+ if (av == &main_arena)
+ {
#ifndef MORECORE_CANNOT_TRIM
- if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ if (chunksize (av->top) >= mp_.trim_threshold)
+ systrim (mp_.top_pad, av);
#endif
- } else {
- /* Always try heap_trim(), even if the top chunk is not
- large, because the corresponding heap might go away. */
- heap_info *heap = heap_for_ptr(top(av));
+ }
+ else
+ {
+ /* Always try heap_trim, even if the top chunk is not large,
+ because the corresponding heap might go away. */
+ heap_info *heap = heap_for_ptr (top (av));
- assert(heap->ar_ptr == av);
- heap_trim(heap, mp_.top_pad);
- }
+ assert (heap->ar_ptr == av);
+ heap_trim (heap, mp_.top_pad);
+ }
}
-
- if (!have_lock)
- __libc_lock_unlock (av->mutex);
- }
- /*
- If the chunk was allocated via mmap, release via munmap().
- */
-
- else {
- munmap_chunk (p);
- }
}
/*
@@ -5221,7 +5254,7 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
(av != &main_arena ? NON_MAIN_ARENA : 0));
set_inuse_bit_at_offset (newp, newsize);
set_head_size (p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0));
- _int_free (av, p, 1);
+ _int_free_merge_chunk (av, p, leadsize);
p = newp;
assert (newsize >= nb &&
@@ -5232,15 +5265,27 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
if (!chunk_is_mmapped (p))
{
size = chunksize (p);
- if ((unsigned long) (size) > (unsigned long) (nb + MINSIZE))
+ mchunkptr nextchunk = chunk_at_offset(p, size);
+ INTERNAL_SIZE_T nextsize = chunksize(nextchunk);
+ if (size > nb)
{
remainder_size = size - nb;
- remainder = chunk_at_offset (p, nb);
- set_head (remainder, remainder_size | PREV_INUSE |
- (av != &main_arena ? NON_MAIN_ARENA : 0));
- set_head_size (p, nb);
- _int_free (av, remainder, 1);
- }
+ if (remainder_size >= MINSIZE
+ || nextchunk == av->top
+ || !inuse_bit_at_offset (nextchunk, nextsize))
+ {
+ /* We can only give back the tail if it is larger than
+ MINSIZE, or if the following chunk is unused (top
+ chunk or unused in-heap chunk). Otherwise we would
+ create a chunk that is smaller than MINSIZE. */
+ remainder = chunk_at_offset (p, nb);
+ set_head_size (p, nb);
+ remainder_size = _int_free_create_chunk (av, remainder,
+ remainder_size,
+ nextchunk, nextsize);
+ _int_free_maybe_consolidate (av, remainder_size);
+ }
+ }
}
check_inuse_chunk (av, p);

View File

@ -0,0 +1,249 @@
commit 0dc7fc1cf094406a138e4d1bcf9553e59edcf89d
Author: Florian Weimer <fweimer@redhat.com>
Date: Thu Aug 10 19:36:56 2023 +0200
malloc: Remove bin scanning from memalign (bug 30723)
On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%). The tcache
scanning has about 50% success rate, so keep that.
Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests. Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.
Remove leftover variables from _int_free from refactoring in the
same commit.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 948f9759af..d0bbbf3710 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4488,12 +4488,6 @@ _int_free (mstate av, mchunkptr p, int have_lock)
{
INTERNAL_SIZE_T size; /* its size */
mfastbinptr *fb; /* associated fastbin */
- mchunkptr nextchunk; /* next contiguous chunk */
- INTERNAL_SIZE_T nextsize; /* its size */
- int nextinuse; /* true if nextchunk is used */
- INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr fwd; /* misc temp for linking */
size = chunksize (p);
@@ -5032,42 +5026,6 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
------------------------------ memalign ------------------------------
*/
-/* Returns 0 if the chunk is not and does not contain the requested
- aligned sub-chunk, else returns the amount of "waste" from
- trimming. NB is the *chunk* byte size, not the user byte
- size. */
-static size_t
-chunk_ok_for_memalign (mchunkptr p, size_t alignment, size_t nb)
-{
- void *m = chunk2mem (p);
- INTERNAL_SIZE_T size = chunksize (p);
- void *aligned_m = m;
-
- if (__glibc_unlikely (misaligned_chunk (p)))
- malloc_printerr ("_int_memalign(): unaligned chunk detected");
-
- aligned_m = PTR_ALIGN_UP (m, alignment);
-
- INTERNAL_SIZE_T front_extra = (intptr_t) aligned_m - (intptr_t) m;
-
- /* We can't trim off the front as it's too small. */
- if (front_extra > 0 && front_extra < MINSIZE)
- return 0;
-
- /* If it's a perfect fit, it's an exception to the return value rule
- (we would return zero waste, which looks like "not usable"), so
- handle it here by returning a small non-zero value instead. */
- if (size == nb && front_extra == 0)
- return 1;
-
- /* If the block we need fits in the chunk, calculate total waste. */
- if (size > nb + front_extra)
- return size - nb;
-
- /* Can't use this chunk. */
- return 0;
-}
-
/* BYTES is user requested bytes, not requested chunksize bytes. */
static void *
_int_memalign (mstate av, size_t alignment, size_t bytes)
@@ -5082,7 +5040,6 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
INTERNAL_SIZE_T size;
- mchunkptr victim;
nb = checked_request2size (bytes);
if (nb == 0)
@@ -5101,129 +5058,13 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
we don't find anything in those bins, the common malloc code will
scan starting at 2x. */
- /* This will be set if we found a candidate chunk. */
- victim = NULL;
-
- /* Fast bins are singly-linked, hard to remove a chunk from the middle
- and unlikely to meet our alignment requirements. We have not done
- any experimentation with searching for aligned fastbins. */
-
- if (av != NULL)
- {
- int first_bin_index;
- int first_largebin_index;
- int last_bin_index;
-
- if (in_smallbin_range (nb))
- first_bin_index = smallbin_index (nb);
- else
- first_bin_index = largebin_index (nb);
-
- if (in_smallbin_range (nb * 2))
- last_bin_index = smallbin_index (nb * 2);
- else
- last_bin_index = largebin_index (nb * 2);
-
- first_largebin_index = largebin_index (MIN_LARGE_SIZE);
-
- int victim_index; /* its bin index */
-
- for (victim_index = first_bin_index;
- victim_index < last_bin_index;
- victim_index ++)
- {
- victim = NULL;
-
- if (victim_index < first_largebin_index)
- {
- /* Check small bins. Small bin chunks are doubly-linked despite
- being the same size. */
-
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
- while (fwd != bck)
- {
- if (chunk_ok_for_memalign (fwd, alignment, nb) > 0)
- {
- victim = fwd;
-
- /* Unlink it */
- victim->fd->bk = victim->bk;
- victim->bk->fd = victim->fd;
- break;
- }
-
- fwd = fwd->fd;
- }
- }
- else
- {
- /* Check large bins. */
- mchunkptr fwd; /* misc temp for linking */
- mchunkptr bck; /* misc temp for linking */
- mchunkptr best = NULL;
- size_t best_size = 0;
-
- bck = bin_at (av, victim_index);
- fwd = bck->fd;
+ /* Call malloc with worst case padding to hit alignment. */
+ m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
- while (fwd != bck)
- {
- int extra;
-
- if (chunksize (fwd) < nb)
- break;
- extra = chunk_ok_for_memalign (fwd, alignment, nb);
- if (extra > 0
- && (extra <= best_size || best == NULL))
- {
- best = fwd;
- best_size = extra;
- }
+ if (m == 0)
+ return 0; /* propagate failure */
- fwd = fwd->fd;
- }
- victim = best;
-
- if (victim != NULL)
- {
- unlink_chunk (av, victim);
- break;
- }
- }
-
- if (victim != NULL)
- break;
- }
- }
-
- /* Strategy: find a spot within that chunk that meets the alignment
- request, and then possibly free the leading and trailing space.
- This strategy is incredibly costly and can lead to external
- fragmentation if header and footer chunks are unused. */
-
- if (victim != NULL)
- {
- p = victim;
- m = chunk2mem (p);
- set_inuse (p);
- if (av != &main_arena)
- set_non_main_arena (p);
- }
- else
- {
- /* Call malloc with worst case padding to hit alignment. */
-
- m = (char *) (_int_malloc (av, nb + alignment + MINSIZE));
-
- if (m == 0)
- return 0; /* propagate failure */
-
- p = mem2chunk (m);
- }
+ p = mem2chunk (m);
if ((((unsigned long) (m)) % alignment) != 0) /* misaligned */
{
diff --git a/malloc/tst-memalign-2.c b/malloc/tst-memalign-2.c
index f229283dbf..ecd6fa249e 100644
--- a/malloc/tst-memalign-2.c
+++ b/malloc/tst-memalign-2.c
@@ -86,7 +86,8 @@ do_test (void)
TEST_VERIFY (tcache_allocs[i].ptr1 == tcache_allocs[i].ptr2);
}
- /* Test for non-head tcache hits. */
+ /* Test for non-head tcache hits. This exercises the memalign
+ scanning code to find matching allocations. */
for (i = 0; i < array_length (ptr); ++ i)
{
if (i == 4)
@@ -113,7 +114,9 @@ do_test (void)
free (p);
TEST_VERIFY (count > 0);
- /* Large bins test. */
+ /* Large bins test. This verifies that the over-allocated parts
+ that memalign releases for future allocations can be reused by
+ memalign itself at least in some cases. */
for (i = 0; i < LN; ++ i)
{

View File

@ -1,145 +1,28 @@
From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 29 Apr 2022 16:37:51 +0200
Subject: [PATCH] Do not use --hash-style=both for building glibc shared
objects
From 31915e55f9c34f6137ab1c5ac002375a2d5d4589 Mon Sep 17 00:00:00 2001
From: Frederik Schwan <frederik.schwan@linux.com>
Date: Fri, 4 Aug 2023 15:19:57 +0200
Subject: [PATCH] force --hash-style=both to keep compatibility with old niche
software
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
---
Makeconfig | 9 +++++++++
Makerules | 7 +++++++
config.make.in | 1 +
configure | 28 ++++++++++++++++++++++++++++
configure.ac | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
Makeconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git b/Makeconfig a/Makeconfig
index 760f14e92f..0aa5fb0099 100644
--- b/Makeconfig
+++ a/Makeconfig
@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
diff --git a/Makeconfig b/Makeconfig
index 77d7fd14df..2ae67c4beb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -378,6 +378,10 @@ relro-LDFLAGS = -Wl,-z,relro
LDFLAGS.so += $(relro-LDFLAGS)
LDFLAGS-rtld += $(relro-LDFLAGS)
+ifeq (yes,$(have-hash-style))
+# For the time being we unconditionally use 'both'. At some time we
+# should declare statically linked code as 'out of luck' and compile
+# with --hash-style=gnu only.
+hashstyle-LDFLAGS = -Wl,--hash-style=both
+LDFLAGS.so += $(hashstyle-LDFLAGS)
+LDFLAGS-rtld += $(hashstyle-LDFLAGS)
+endif
+
ifeq (no,$(build-pie-default))
pie-default = $(no-pie-ccflag)
else # build-pie-default
diff --git b/Makerules a/Makerules
index 354528b8c7..428464f092 100644
--- b/Makerules
+++ a/Makerules
@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
-Wl,--verbose 2>/dev/null | \
sed > $@T \
-e '/^=========/,/^=========/!d;/^=========/d' \
+ $(if $(filter yes,$(have-hash-style)), \
+ -e 's/^.*\.gnu\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ -e '/^[ ]*\.hash[ ]*:.*$$/{h;d;}' \
+ -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+ , \
+ -e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+ ) \
-e 's/^.*\*(\.dynbss).*$$/& \
PROVIDE(__start___libc_freeres_ptrs = .); \
*(__libc_freeres_ptrs) \
diff --git b/config.make.in a/config.make.in
index fff4c78dd0..bf728c71c0 100644
--- b/config.make.in
+++ a/config.make.in
@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
+have-hash-style = @libc_cv_hashstyle@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
have-loop-to-function = @libc_cv_cc_loop_to_function@
diff --git b/configure a/configure
index 716dc041b6..5a730dc5fc 100755
--- b/configure
+++ a/configure
@@ -622,6 +622,7 @@ libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
fno_unit_at_a_time
libc_cv_has_glob_dat
+libc_cv_hashstyle
libc_cv_fpie
libc_cv_z_execstack
ASFLAGS_config
@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
+$as_echo_n "checking for --hash-style option... " >&6; }
+if ${libc_cv_hashstyle+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
+$as_echo "$libc_cv_hashstyle" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
$as_echo_n "checking for GLOB_DAT reloc... " >&6; }
if ${libc_cv_has_glob_dat+:} false; then :
diff --git b/configure.ac a/configure.ac
index d08ad4d64e..a045f6608e 100644
--- b/configure.ac
+++ a/configure.ac
@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for --hash-style option,
+ libc_cv_hashstyle, [dnl
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+ -fPIC -shared -o conftest.so conftest.c
+ -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
+then
+ libc_cv_hashstyle=yes
+else
+ libc_cv_hashstyle=no
+fi
+rm -f conftest*])
+AC_SUBST(libc_cv_hashstyle)
+
AC_CACHE_CHECK(for GLOB_DAT reloc,
libc_cv_has_glob_dat, [dnl
cat > conftest.c <<EOF
# Linker options to enable and disable DT_RELR.
ifeq ($(have-dt-relr),yes)
dt-relr-ldflag = -Wl,-z,pack-relative-relocs
--
2.37.1
2.41.0

View File

@ -10,7 +10,7 @@
_target=riscv64-unknown-linux-gnu
pkgname=${_target}-libxcrypt
pkgver=4.4.36
pkgrel=1
pkgrel=1.1
pkgdesc='Modern library for one-way hashing of passwords'
arch=(any)
url='https://github.com/besser82/libxcrypt'
@ -34,7 +34,7 @@ build() {
cd "${srcdir}/build-libxcrypt/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
@ -46,7 +46,7 @@ build() {
cd "${srcdir}/build-libxcrypt-compat/"
"${srcdir}/libxcrypt-${pkgver}"/configure \
--prefix=/usr/${_target} \
--prefix=/usr \
--with-sysroot=/usr/${_target} \
--disable-static \
--enable-hashes=strong,glibc \
@ -59,8 +59,8 @@ build() {
package() {
cd ${srcdir}/build-libxcrypt/
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}/usr/${_target}/" install
cd ${srcdir}/build-libxcrypt-compat/
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}/usr/${_target}/" install
}

View File

@ -10,13 +10,13 @@ _target_arch=riscv64
_target=${_target_arch}-unknown-linux-gnu
pkgname=${_target}-linux-api-headers
pkgver=6.4
pkgrel=1
pkgrel=2
pkgdesc="Kernel headers sanitized for use in userspace (${_target})"
arch=(any)
url='http://www.gnu.org/software/libc'
license=(GPL2)
makedepends=(rsync make)
source=(https://www.kernel.org/pub/linux/kernel/v5.x/linux-${pkgver}.tar.xz)
source=(https://www.kernel.org/pub/linux/kernel/v6.x/linux-${pkgver}.tar.xz)
sha256sums=('8fa0588f0c2ceca44cac77a0e39ba48c9f00a6b9dc69761c02a5d3efac8da7f3')
validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E') # Greg Kroah-Hartman
@ -29,10 +29,10 @@ build() {
package() {
cd linux-${pkgver}
make INSTALL_HDR_PATH="$pkgdir/usr/$_target" ARCH=riscv headers_install
make INSTALL_HDR_PATH="$pkgdir/usr/$_target/usr" ARCH=riscv headers_install
# use headers from libdrm
rm -rf "$pkgdir/usr/$_target/include/drm"
rm -rf "$pkgdir/usr/$_target/usr/include/drm"
# clean-up unnecessary files generated during install
find ${pkgdir} \( -name .install -o -name ..install.cmd \) -delete

View File

@ -0,0 +1,58 @@
# Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
_arch=riscv64
_target=${_arch}-unknown-linux-gnu
pkgname=${_target}-pacman
pkgver=2023.09
pkgrel=1
pkgdesc="Pacman configurations for ${_target} to install dependencies for cross-compilation"
arch=(any)
url="https://archlinuxpower.org"
depends=(
${_target}-gcc
${_target}-glibc
)
source=(pacman-arch.sh
pacman.conf
fakebase.desc)
backup=(etc/pacman-${_arch}.conf)
sha256sums=('5fd18c74198312560579d900af2b0e52b757b47fb70e4f78e995b29cf0b5ee7a'
'6be22d041e30ca7475d7700ff35b4ca34ad62f3ad415b8f429edbbc03c295d0e'
'c7d16160e0d91becce572abee7954e61411c729eec7a367a96335fba6bc470f1')
prepare() {
if [ -d /usr/${_target}/var/lib/pacman ]; then
echo "Remove existing synced dbs etc from /usr/${_target}/var/lib/pacman/ and try again"
exit 1
fi
}
build() {
sed "s/@@CARCH@@/${_arch}/g" -i pacman-arch.sh
sed "s/@@CHOST_PREFIX@@/\/usr\/${_target}\//g" -i pacman.conf
sed "s/@@TIMESTAMP@@/$(date "+%s")/g" -i fakebase.desc
sed "s/@@FAKEBASE_VERSION@@/${pkgver}-${pkgrel}/g" -i fakebase.desc
}
package() {
install -d -m755 ${pkgdir}/usr/bin
install -m755 ${srcdir}/pacman-arch.sh ${pkgdir}/usr/bin/pacman-${_arch}
install -d -m 755 ${pkgdir}/etc
install -m644 ${srcdir}/pacman.conf ${pkgdir}/etc/pacman-${_arch}.conf
# fake that we install a few basic packages via pacman
install -d -m 755 ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}
pushd /usr/${_target}/
shopt -s dotglob globstar
printf '%s\0' **/* | LANG=C bsdtar -cnf - --format=mtree --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' --null --files-from - --exclude .MTREE | gzip -c -f -n > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/mtree
shopt -u dotglob globstar
echo '%FILES%' > ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
find | sed 's@^./@@g' | grep -v '^\.$' | grep -v '.*mtree$' >> ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/files
echo 9 > ${pkgdir}/usr/${_target}/var/lib/pacman/local/ALPM_DB_VERSION
install -m644 ${srcdir}/fakebase.desc ${pkgdir}/usr/${_target}/var/lib/pacman/local/fakebase-${pkgver}-${pkgrel}/desc
popd
}

View File

@ -0,0 +1,42 @@
%NAME%
fakebase
%VERSION%
@@FAKEBASE_VERSION@@
%DESC%
Masking that some packages from crosscompilers on the host
%URL%
https://archlinuxpower.org
%ARCH%
any
%BUILDDATE%
@@TIMESTAMP@@
%INSTALLDATE%
@@TIMESTAMP@@
%PACKAGER%
Alexander Baldeck <alex.bldck@gmail.com>
%SIZE%
10
%LICENSE%
GPL
%VALIDATION%
sha256
%PROVIDES%
binutils
filesystem
gcc
gcc-libs
glibc
libxcrypt
linux-api-headers
zlib

View File

@ -0,0 +1,141 @@
%FILES%
bin
boot/
dev/
etc/
etc/arch-release
etc/crypttab
etc/fstab
etc/group
etc/gshadow
etc/host.conf
etc/hosts
etc/issue
etc/ld.so.conf
etc/ld.so.conf.d/
etc/mtab
etc/nsswitch.conf
etc/passwd
etc/profile
etc/profile.d/
etc/profile.d/locale.sh
etc/resolv.conf
etc/securetty
etc/shadow
etc/shells
etc/skel/
etc/subgid
etc/subuid
home/
lib
lib64
mnt/
opt/
proc/
root/
run/
sbin
srv/
srv/ftp/
srv/http/
sys/
tmp/
usr/
usr/bin/
usr/include/
usr/lib/
usr/lib/os-release
usr/lib/sysctl.d/
usr/lib/sysctl.d/10-arch.conf
usr/lib/systemd/
usr/lib/systemd/system-environment-generators/
usr/lib/systemd/system-environment-generators/10-arch
usr/lib/sysusers.d/
usr/lib/sysusers.d/arch.conf
usr/lib/tmpfiles.d/
usr/lib/tmpfiles.d/arch.conf
usr/lib64
usr/local/
usr/local/bin/
usr/local/etc/
usr/local/games/
usr/local/include/
usr/local/lib/
usr/local/man/
usr/local/sbin/
usr/local/share/
usr/local/share/man
usr/local/src/
usr/sbin
usr/share/
usr/share/factory/
usr/share/factory/etc/
usr/share/factory/etc/crypttab
usr/share/factory/etc/fstab
usr/share/factory/etc/group
usr/share/factory/etc/gshadow
usr/share/factory/etc/host.conf
usr/share/factory/etc/hosts
usr/share/factory/etc/issue
usr/share/factory/etc/ld.so.conf
usr/share/factory/etc/nsswitch.conf
usr/share/factory/etc/passwd
usr/share/factory/etc/profile
usr/share/factory/etc/resolv.conf
usr/share/factory/etc/securetty
usr/share/factory/etc/shadow
usr/share/factory/etc/shells
usr/share/factory/etc/subgid
usr/share/factory/etc/subuid
usr/share/man/
usr/share/man/man1/
usr/share/man/man2/
usr/share/man/man3/
usr/share/man/man4/
usr/share/man/man5/
usr/share/man/man6/
usr/share/man/man7/
usr/share/man/man8/
usr/share/misc/
usr/share/pixmaps/
usr/share/pixmaps/archlinux-logo-text-dark.svg
usr/share/pixmaps/archlinux-logo-text.svg
usr/share/pixmaps/archlinux-logo.png
usr/share/pixmaps/archlinux-logo.svg
usr/src/
var/
var/cache/
var/empty/
var/games/
var/lib/
var/lib/misc/
var/local/
var/lock
var/log/
var/log/old/
var/mail
var/opt/
var/run
var/spool/
var/spool/mail/
var/tmp/
%BACKUP%
etc/crypttab 5fa6674df7645d7f5895f2d12b4ef4e9
etc/fstab e33f6dfdd61978fcb3ddf1431286e05a
etc/group 7fed1e1fb855e41a6d64d41f8521d69a
etc/gshadow 1c1e3b08acfa286f4b417c49de3e4366
etc/host.conf 7d119a9cce152aa182fb3392ddeecea7
etc/hosts a1315ea3e2b64d197b6efaf9c14ff778
etc/issue f36195a7ed232b8520a68a867f166a3b
etc/ld.so.conf 5deb9f890a4d08a245e9752ede77271e
etc/nsswitch.conf a3de66d416718325442f739d6c1d4e50
etc/passwd 5182ac38a0de85da8ade93ef71975ca4
etc/profile 448fe7cbcb566e8d318dc0db0c9cb710
etc/resolv.conf 0ee015fad07732676d9488ae498eed41
etc/securetty f04bcb2803afc4dcb95670fe87343b4d
etc/shadow 815652599be54fd3607cf276e89a0a19
etc/shells 8fe5095f1116c2c61b4608c4840063a2
etc/subuid d41d8cd98f00b204e9800998ecf8427e
etc/subgid d41d8cd98f00b204e9800998ecf8427e

View File

@ -0,0 +1,3 @@
#!/bin/sh
pacman --config /etc/pacman-@@CARCH@@.conf $@

View File

@ -0,0 +1,96 @@
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
RootDir = @@CHOST_PREFIX@@
DBPath = @@CHOST_PREFIX@@/var/lib/pacman/
CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
#GPGDir = /etc/pacman.d/gnupg/
#HookDir = /etc/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = powerpc
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =
#NoUpgrade =
#NoExtract =
# Misc options
#UseSyslog
#Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
#ParallelDownloads = 5
# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required
# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#
# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.
[repo-local-any]
SigLevel = Never
Server = http://172.23.23.10/repo/any
[repo-local]
SigLevel = Never
Server = http://172.23.23.10/repo/$arch
[testing-any]
Server = https://repo.archlinuxpower.org/testing/any
[testing]
Server = https://repo.archlinuxpower.org/testing/$arch
[base-any]
Server = https://repo.archlinuxpower.org/base/any
[base]
Server = https://repo.archlinuxpower.org/base/$arch
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs