package updates
This commit is contained in:
parent
5255e41186
commit
6b9168b68a
24 changed files with 1642 additions and 58 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
*tar*
|
*tar.*
|
||||||
pkg
|
pkg
|
||||||
src
|
src
|
||||||
readline*
|
readline*
|
||||||
|
*.tgz
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
||||||
|
|
||||||
pkgname=argp-standalone
|
pkgname=argp-standalone
|
||||||
pkgver=1.5.0
|
pkgver=1.6.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Standalone version of Glibc's ARGP"
|
pkgdesc="Standalone version of Glibc's ARGP"
|
||||||
arch=("x86_64")
|
arch=("x86_64")
|
||||||
url="https://github.com/argp-standalone/argp-standalone"
|
url="https://code.relms.dev/Ikeda/argp-standalone"
|
||||||
license=("LGPL-2.1-or-later")
|
license=("LGPL-2.1-or-later")
|
||||||
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz")
|
source=("$pkgname-$pkgver.tar.gz::https://code.relms.dev/Ikeda/argp-standalone/archive/$pkgver.tar.gz")
|
||||||
sha256sums=("c29eae929dfebd575c38174f2c8c315766092cec99a8f987569d0cad3c6d64f6")
|
sha256sums=("ccf6880276f8c6fc4e895f4cac04ebfba4b59908f36255335812b74fcb90196f")
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
autoreconf -fi
|
autoreconf -fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
|
|
||||||
CFLAGS+=" -fPIC" ./configure --prefix=/usr
|
./configure --prefix=/usr
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
|
|
||||||
install -D -m644 argp.h $pkgdir/usr/include/argp.h
|
install -D -m644 argp.h $pkgdir/usr/include/argp.h
|
||||||
install -D -m644 libargp.a $pkgdir/usr/lib/libargp.a
|
install -D -m644 libargp.a $pkgdir/usr/lib/libargp.a
|
||||||
|
|
|
@ -10,8 +10,8 @@ depends=(
|
||||||
# very very base
|
# very very base
|
||||||
"filesystem"
|
"filesystem"
|
||||||
|
|
||||||
# libc & runtimes
|
# libc & runtime
|
||||||
"musl" "argp-standalone" "musl-fts" "musl-obstack" "llvm-runtimes"
|
"musl" "llvm-runtimes"
|
||||||
|
|
||||||
# POSIX tools
|
# POSIX tools
|
||||||
"busybox" "file" "findutils" "gawk" "grep" "procps-ng" "libarchive" "bash"
|
"busybox" "file" "findutils" "gawk" "grep" "procps-ng" "libarchive" "bash"
|
||||||
|
|
|
@ -13,22 +13,23 @@ source=(
|
||||||
)
|
)
|
||||||
sha256sums=(
|
sha256sums=(
|
||||||
"b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314"
|
"b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314"
|
||||||
"3bce5753ac5953b40c5c13a5028436e7a82f2feebf6604a74aaba9e15e40c068"
|
"035fb8b3a475a9264a4c443ab83f123a40d758ae7d969e59523985a4f9070376"
|
||||||
)
|
)
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname-$pkgver
|
||||||
|
|
||||||
cp $srcdir/config .config
|
cp $srcdir/config .config
|
||||||
|
|
||||||
# reproducible build
|
# reproducible build
|
||||||
export KCONFIG_NOTIMESTAMP=1
|
export KCONFIG_NOTIMESTAMP=1
|
||||||
make
|
make CC=cc HOSTCC=cc
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname-$pkgver
|
||||||
|
|
||||||
make install
|
make CC=cc HOSTCC=cc install
|
||||||
|
|
||||||
# Move all applets into /usr/bin
|
# Move all applets into /usr/bin
|
||||||
mv $pkgdir/bin/* $pkgdir/usr/bin/
|
mv $pkgdir/bin/* $pkgdir/usr/bin/
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#
|
#
|
||||||
# Automatically generated make config: don't edit
|
# Automatically generated make config: don't edit
|
||||||
# Busybox version: 1.36.1
|
# Busybox version: 1.36.1
|
||||||
# Fri Dec 8 03:19:46 2023
|
|
||||||
#
|
#
|
||||||
CONFIG_HAVE_DOT_CONFIG=y
|
CONFIG_HAVE_DOT_CONFIG=y
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ CONFIG_FEATURE_SYSLOG=y
|
||||||
#
|
#
|
||||||
# Build Options
|
# Build Options
|
||||||
#
|
#
|
||||||
CONFIG_STATIC=y
|
# CONFIG_STATIC is not set
|
||||||
# CONFIG_PIE is not set
|
# CONFIG_PIE is not set
|
||||||
# CONFIG_NOMMU is not set
|
# CONFIG_NOMMU is not set
|
||||||
# CONFIG_BUILD_LIBBUSYBOX is not set
|
# CONFIG_BUILD_LIBBUSYBOX is not set
|
||||||
|
@ -84,7 +83,7 @@ CONFIG_NO_DEBUG_LIB=y
|
||||||
#
|
#
|
||||||
# Library Tuning
|
# Library Tuning
|
||||||
#
|
#
|
||||||
# CONFIG_FEATURE_USE_BSS_TAIL is not set
|
CONFIG_FEATURE_USE_BSS_TAIL=y
|
||||||
CONFIG_FLOAT_DURATION=y
|
CONFIG_FLOAT_DURATION=y
|
||||||
CONFIG_FEATURE_RTMINMAX=y
|
CONFIG_FEATURE_RTMINMAX=y
|
||||||
CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y
|
CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y
|
||||||
|
|
17
fortify-headers/PKGBUILD
Normal file
17
fortify-headers/PKGBUILD
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
||||||
|
|
||||||
|
_fullcommit=55ae3986e7c54efdbcb4b3d9e5834ed4826d81f7
|
||||||
|
pkgname=fortify-headers
|
||||||
|
pkgver=1.1.1
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Standalone portable header-based implementation of FORTIFY_SOURCE"
|
||||||
|
arch=("any")
|
||||||
|
url="https://github.com/jvoisin/fortify-headers"
|
||||||
|
license=("custom")
|
||||||
|
source=("https://github.com/chimera-linux/fortify-headers/archive/$_fullcommit.tar.gz")
|
||||||
|
sha256sums=('c7eb4e1b442dfcf9f85862851bd5dd3f43b7f879a7755820be4e04560d3ce2c0')
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd $pkgname-$_fullcommit
|
||||||
|
make DESTDIR=$pkgdir PREFIX=/usr install
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
From 3f6f3c4bc59e1b3822ae6b0145ffbe1cb9e80ce1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: q66 <q66@chimera-linux.org>
|
||||||
|
Date: Sat, 4 Nov 2023 09:09:40 +0100
|
||||||
|
Subject: [PATCH 1/6] clang: add fortify include paths for musl triplets +
|
||||||
|
enable fortify
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Linux.cpp | 12 ++++++++----
|
||||||
|
clang/lib/Frontend/InitPreprocessor.cpp | 5 +++++
|
||||||
|
2 files changed, 13 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
index 1ba222bf8..0b236de75 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
@@ -659,10 +659,14 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||||
|
if (getTriple().getOS() == llvm::Triple::RTEMS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- // Add an include of '/include' directly. This isn't provided by default by
|
||||||
|
- // system GCCs, but is often used with cross-compiling GCCs, and harmless to
|
||||||
|
- // add even when Clang is acting as-if it were a system compiler.
|
||||||
|
- addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include"));
|
||||||
|
+ if (getTriple().isMusl()) {
|
||||||
|
+ addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include/fortify"));
|
||||||
|
+ } else {
|
||||||
|
+ // Preserve original clang behavior for non-musl triples, but for musl
|
||||||
|
+ // this just gets in the way and none of our crosstoolchains are ever
|
||||||
|
+ // actually built this way (and we'd have to figure out fortify for it)
|
||||||
|
+ addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/include"));
|
||||||
|
+ }
|
||||||
|
|
||||||
|
addExternCSystemInclude(DriverArgs, CC1Args, concat(SysRoot, "/usr/include"));
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||||
|
index f8fae82fb..316fae2b2 100644
|
||||||
|
--- a/clang/lib/Frontend/InitPreprocessor.cpp
|
||||||
|
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
|
||||||
|
@@ -1329,6 +1329,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
||||||
|
if (TI.getTriple().isOSBinFormatELF())
|
||||||
|
Builder.defineMacro("__ELF__");
|
||||||
|
|
||||||
|
+ // Enable fortify by default on musl when optimizing, but not with asan
|
||||||
|
+ if (TI.getTriple().isMusl() && LangOpts.Optimize &&
|
||||||
|
+ !LangOpts.Sanitize.has(SanitizerKind::Address))
|
||||||
|
+ Builder.defineMacro("_FORTIFY_SOURCE", "2");
|
||||||
|
+
|
||||||
|
// Get other target #defines.
|
||||||
|
TI.getTargetDefines(LangOpts, Builder);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
30
llvm-project/0002-clang-use-as-needed-by-default.patch
Normal file
30
llvm-project/0002-clang-use-as-needed-by-default.patch
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
From cd514294fac574bd445d5c6f06e66568db5da1a5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: q66 <q66@chimera-linux.org>
|
||||||
|
Date: Sat, 4 Nov 2023 09:11:15 +0100
|
||||||
|
Subject: [PATCH 2/6] clang: use --as-needed by default
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Gnu.cpp | 7 +++++++
|
||||||
|
1 file changed, 7 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
index 40038dce4..52bdc89ef 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
@@ -547,6 +547,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
|
||||||
|
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
|
||||||
|
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
|
||||||
|
+
|
||||||
|
+ // Use --as-needed by default for all explicit linker inputs on Linux
|
||||||
|
+ // We don't reset it afterwards because explicit argument does not
|
||||||
|
+ // get reset either (and that is permitted, so it should be fine)
|
||||||
|
+ if (Triple.isOSLinux())
|
||||||
|
+ CmdArgs.push_back("--as-needed");
|
||||||
|
+
|
||||||
|
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
|
||||||
|
|
||||||
|
addHIPRuntimeLibArgs(ToolChain, Args, CmdArgs);
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
31
llvm-project/0003-clang-switch-on-default-now-relro.patch
Normal file
31
llvm-project/0003-clang-switch-on-default-now-relro.patch
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
From 57e4d9ed0d83f2cd128699ccc693ec09854faf65 Mon Sep 17 00:00:00 2001
|
||||||
|
From: q66 <q66@chimera-linux.org>
|
||||||
|
Date: Sat, 4 Nov 2023 09:11:37 +0100
|
||||||
|
Subject: [PATCH 3/6] clang: switch on default now/relro
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Linux.cpp | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
index 0b236de75..abf0de8af 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
|
||||||
|
@@ -222,12 +222,12 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||||
|
|
||||||
|
Distro Distro(D.getVFS(), Triple);
|
||||||
|
|
||||||
|
- if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
|
||||||
|
+ if (Triple.isMusl() || Triple.isAndroid()) {
|
||||||
|
ExtraOpts.push_back("-z");
|
||||||
|
ExtraOpts.push_back("now");
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
|
||||||
|
+ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Triple.isMusl() ||
|
||||||
|
Triple.isAndroid()) {
|
||||||
|
ExtraOpts.push_back("-z");
|
||||||
|
ExtraOpts.push_back("relro");
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
From 8d10380e04a3ba4d9a5c56384503d3f88c273f81 Mon Sep 17 00:00:00 2001
|
||||||
|
From: q66 <q66@chimera-linux.org>
|
||||||
|
Date: Sat, 4 Nov 2023 09:11:58 +0100
|
||||||
|
Subject: [PATCH 4/6] clang: default to -fno-semantic-interposition
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Clang.cpp | 4 +---
|
||||||
|
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
index 37a07b8f2..bd210683b 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
|
||||||
|
@@ -5312,9 +5312,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
// The supported targets need to call AsmPrinter::getSymbolPreferLocal.
|
||||||
|
bool SupportsLocalAlias =
|
||||||
|
Triple.isAArch64() || Triple.isRISCV() || Triple.isX86();
|
||||||
|
- if (!A)
|
||||||
|
- CmdArgs.push_back("-fhalf-no-semantic-interposition");
|
||||||
|
- else if (A->getOption().matches(options::OPT_fsemantic_interposition))
|
||||||
|
+ if (A && A->getOption().matches(options::OPT_fsemantic_interposition))
|
||||||
|
A->render(Args, CmdArgs);
|
||||||
|
else if (!SupportsLocalAlias)
|
||||||
|
CmdArgs.push_back("-fhalf-no-semantic-interposition");
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
From 5ca9d363bd8c3ebae829fa73639116403367b5d4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: q66 <q66@chimera-linux.org>
|
||||||
|
Date: Sat, 4 Nov 2023 09:12:24 +0100
|
||||||
|
Subject: [PATCH 5/6] clang: implicitly link to libatomic on linux targets
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Gnu.cpp | 10 ++++++----
|
||||||
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
index 52bdc89ef..d2e727e2f 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
|
||||||
|
@@ -618,10 +618,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
|
||||||
|
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
|
||||||
|
|
||||||
|
- // LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
|
||||||
|
- // forcibly link with libatomic as a workaround.
|
||||||
|
- // TODO: Issue #41880 and D118021.
|
||||||
|
- if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
|
||||||
|
+ // implicitly link to libatomic, we don't want to bother with manually
|
||||||
|
+ // adding this on platforms where libatomic is explicitly necessary,
|
||||||
|
+ // and the as-needed will ensure it's left out when not needed
|
||||||
|
+ //
|
||||||
|
+ // chimera already ships its own version of libatomic, so it's fine
|
||||||
|
+ if (Triple.isOSLinux()) {
|
||||||
|
CmdArgs.push_back("--push-state");
|
||||||
|
CmdArgs.push_back("--as-needed");
|
||||||
|
CmdArgs.push_back("-latomic");
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
From 2f325a39fef9a95f679a04e5058839bd795c5145 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daniel Kolesa <daniel@octaforge.org>
|
||||||
|
Date: Tue, 2 May 2023 16:23:22 +0200
|
||||||
|
Subject: [PATCH 6/6] clang: use strong stack protector by default
|
||||||
|
|
||||||
|
---
|
||||||
|
clang/lib/Driver/ToolChains/Linux.h | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
|
||||||
|
index 524391743..bfaa3a8a7 100644
|
||||||
|
--- a/clang/lib/Driver/ToolChains/Linux.h
|
||||||
|
+++ b/clang/lib/Driver/ToolChains/Linux.h
|
||||||
|
@@ -65,6 +65,11 @@ public:
|
||||||
|
|
||||||
|
const char *getDefaultLinker() const override;
|
||||||
|
|
||||||
|
+ LangOptions::StackProtectorMode
|
||||||
|
+ GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
|
||||||
|
+ return LangOptions::SSPStrong;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
protected:
|
||||||
|
Tool *buildAssembler() const override;
|
||||||
|
Tool *buildLinker() const override;
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -15,8 +15,35 @@ url="https://llvm.org"
|
||||||
license=("LLVM-exception")
|
license=("LLVM-exception")
|
||||||
depends=("zlib-ng")
|
depends=("zlib-ng")
|
||||||
makedepends=()
|
makedepends=()
|
||||||
source=("https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-project-$pkgver.src.tar.xz")
|
source=(
|
||||||
sha256sums=("58a8818c60e6627064f312dbf46c02d9949956558340938b71cf731ad8bc0813")
|
"https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-project-$pkgver.src.tar.xz"
|
||||||
|
"0001-clang-add-fortify-include-paths-for-musl-triplets-en.patch"
|
||||||
|
"0002-clang-use-as-needed-by-default.patch"
|
||||||
|
"0003-clang-switch-on-default-now-relro.patch"
|
||||||
|
"0004-clang-default-to-fno-semantic-interposition.patch"
|
||||||
|
"0005-clang-implicitly-link-to-libatomic-on-linux-targets.patch"
|
||||||
|
"0006-clang-use-strong-stack-protector-by-default.patch"
|
||||||
|
)
|
||||||
|
sha256sums=(
|
||||||
|
"58a8818c60e6627064f312dbf46c02d9949956558340938b71cf731ad8bc0813"
|
||||||
|
"80023325d9d2d7c168b01efd188dbdb3f012207274aeedc7a3f4824e501b1ea4"
|
||||||
|
"672e4ab48aca039e5c8c50bcd7dd0be93304a3f1cc5d361e1f05b46ad98de1ef"
|
||||||
|
"f6271d753c3e74dab89a7e4111fe67a6c69bd0e2ac1b06336fb9132a69702ef2"
|
||||||
|
"6e6262fce80666a37abd76793a382eb2903d402463dad76afb4d1d408d5b37b0"
|
||||||
|
"296cb85a06e4b179881b3294fc2c0e4b235ced29a7c11b301794c3e96b16f77f"
|
||||||
|
"ec9aeeca5812cd98274035c0b6e79401754d7ed0407e2034ad727704a8c7dedc"
|
||||||
|
)
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd $pkgbase-$pkgver.src
|
||||||
|
|
||||||
|
patch -p1 <$srcdir/0001-clang-add-fortify-include-paths-for-musl-triplets-en.patch
|
||||||
|
patch -p1 <$srcdir/0002-clang-use-as-needed-by-default.patch
|
||||||
|
patch -p1 <$srcdir/0003-clang-switch-on-default-now-relro.patch
|
||||||
|
patch -p1 <$srcdir/0004-clang-default-to-fno-semantic-interposition.patch
|
||||||
|
patch -p1 <$srcdir/0005-clang-implicitly-link-to-libatomic-on-linux-targets.patch
|
||||||
|
patch -p1 <$srcdir/0006-clang-use-strong-stack-protector-by-default.patch
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $pkgbase-$pkgver.src
|
cd $pkgbase-$pkgver.src
|
||||||
|
@ -26,8 +53,6 @@ build() {
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
-DCMAKE_INSTALL_PREFIX=/usr
|
-DCMAKE_INSTALL_PREFIX=/usr
|
||||||
-DCMAKE_INSTALL_LIBDIR=lib
|
-DCMAKE_INSTALL_LIBDIR=lib
|
||||||
-DCMAKE_C_COMPILER=clang
|
|
||||||
-DCMAKE_CXX_COMPILER=clang++
|
|
||||||
-DLLVM_TARGETS_TO_BUILD=X86
|
-DLLVM_TARGETS_TO_BUILD=X86
|
||||||
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl
|
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl
|
||||||
-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl
|
-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl
|
||||||
|
@ -44,7 +69,6 @@ build() {
|
||||||
-DLLVM_ENABLE_LIBXML2=OFF
|
-DLLVM_ENABLE_LIBXML2=OFF
|
||||||
-DLLVM_ENABLE_LIBPFM=OFF
|
-DLLVM_ENABLE_LIBPFM=OFF
|
||||||
-DLLVM_ENABLE_OCAMLDOC=OFF
|
-DLLVM_ENABLE_OCAMLDOC=OFF
|
||||||
-DLLVM_ENABLE_LLD=ON
|
|
||||||
-DLLVM_INSTALL_UTILS=ON
|
-DLLVM_INSTALL_UTILS=ON
|
||||||
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON
|
-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON
|
||||||
-DLLVM_INSTALL_CCTOOLS_SYMLINKS=ON
|
-DLLVM_INSTALL_CCTOOLS_SYMLINKS=ON
|
||||||
|
@ -80,10 +104,11 @@ build() {
|
||||||
-DLIBCXXABI_USE_COMPILER_RT=ON
|
-DLIBCXXABI_USE_COMPILER_RT=ON
|
||||||
-DLIBUNWIND_INSTALL_HEADERS=ON
|
-DLIBUNWIND_INSTALL_HEADERS=ON
|
||||||
-DLIBUNWIND_USE_COMPILER_RT=ON
|
-DLIBUNWIND_USE_COMPILER_RT=ON
|
||||||
|
-DLIBUNWIND_ENABLE_STATIC=ON
|
||||||
-DLLD_VENDOR="Ikeda Linux"
|
-DLLD_VENDOR="Ikeda Linux"
|
||||||
)
|
)
|
||||||
|
|
||||||
cmake -B build-llvm -S llvm "${cmake_args[@]}"
|
cmake -B build-llvm -S llvm --log-level=trace "${cmake_args[@]}"
|
||||||
cmake -B build-llvm-runtimes -S runtimes -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" "${cmake_args[@]}"
|
cmake -B build-llvm-runtimes -S runtimes -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxx;libcxxabi" "${cmake_args[@]}"
|
||||||
cmake -B build-clang -S clang "${cmake_args[@]}"
|
cmake -B build-clang -S clang "${cmake_args[@]}"
|
||||||
cmake -B build-lld -S lld "${cmake_args[@]}"
|
cmake -B build-lld -S lld "${cmake_args[@]}"
|
||||||
|
@ -113,6 +138,7 @@ package_clang() {
|
||||||
|
|
||||||
ln -s clang $pkgdir/usr/bin/cc
|
ln -s clang $pkgdir/usr/bin/cc
|
||||||
ln -s clang++ $pkgdir/usr/bin/cpp
|
ln -s clang++ $pkgdir/usr/bin/cpp
|
||||||
|
ln -s clang++ $pkgdir/usr/bin/c++
|
||||||
}
|
}
|
||||||
|
|
||||||
package_lld() {
|
package_lld() {
|
||||||
|
|
|
@ -4,10 +4,10 @@ pkgname=musl-fts
|
||||||
pkgver=1.2.7
|
pkgver=1.2.7
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Provides the fts(3) functions, which are missing in musl libc"
|
pkgdesc="Provides the fts(3) functions, which are missing in musl libc"
|
||||||
arch=("any")
|
arch=("x86_64")
|
||||||
url="https://github.com/void-linux/musl-fts/"
|
url="https://github.com/void-linux/musl-fts/"
|
||||||
license=("BSD-3-Clause")
|
license=("BSD-3-Clause")
|
||||||
source=("https://github.com/void-linux/musl-fts/archive/refs/tags/v$pkgver.tar.gz")
|
source=("$pkgname-$pkgver.tar.gz::https://github.com/void-linux/musl-fts/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
sha256sums=("49ae567a96dbab22823d045ffebe0d6b14b9b799925e9ca9274d47d26ff482a6")
|
sha256sums=("49ae567a96dbab22823d045ffebe0d6b14b9b799925e9ca9274d47d26ff482a6")
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
||||||
|
|
||||||
pkgname=musl-obstack
|
pkgname=musl-obstack
|
||||||
pkgver=1.2.3
|
pkgver=1.3.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Standalone library to implement GNU libc's obstack"
|
pkgdesc="Standalone library to implement GNU libc's obstack"
|
||||||
arch=("any")
|
arch=("x86_64")
|
||||||
url="https://github.com/void-linux/musl-obstack/"
|
url="https://code.relms.dev/Ikeda/musl-obstack"
|
||||||
license=("BSD-3-Clause")
|
license=("BSD-3-Clause")
|
||||||
source=("https://github.com/void-linux/musl-obstack/archive/refs/tags/v$pkgver.tar.gz")
|
source=("$pkgname-$pkgver.tar.gz::https://code.relms.dev/Ikeda/musl-obstack/archive/$pkgver.tar.gz")
|
||||||
sha256sums=("9ffb3479b15df0170eba4480e51723c3961dbe0b461ec289744622db03a69395")
|
sha256sums=("9a22be0db737ceb79310490e432f0cbeb7726dfe08d98fac3b4c3e21af2dbb08")
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
|
|
||||||
./configure --prefix=/usr
|
./configure --prefix=/usr
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname
|
||||||
|
|
||||||
make DESTDIR=$pkgdir install
|
make DESTDIR=$pkgdir install
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 6be76895f6863100a311d474a42abdbb6466189d Mon Sep 17 00:00:00 2001
|
From 5ff8adc05ce929726c60edc3a5bf9a936a6dfe7c Mon Sep 17 00:00:00 2001
|
||||||
From: Violet Purcell <vimproved@inventati.org>
|
From: Violet Purcell <vimproved@inventati.org>
|
||||||
Date: Sat, 4 Nov 2023 12:09:20 -0400
|
Date: Sat, 4 Nov 2023 12:09:20 -0400
|
||||||
Subject: elf.h: add typedefs for Elf64_Relr and Elf32_Relr
|
Subject: [PATCH 1/4] elf.h: add typedefs for Elf64_Relr and Elf32_Relr
|
||||||
|
|
||||||
These were overlooked when DT_RELR was added in commit
|
These were overlooked when DT_RELR was added in commit
|
||||||
d32dadd60efb9d3b255351a3b532f8e4c3dd0db1, potentially breaking
|
d32dadd60efb9d3b255351a3b532f8e4c3dd0db1, potentially breaking
|
||||||
|
@ -28,5 +28,5 @@ index 23f2c4bc..72d17c3a 100644
|
||||||
#define ELF32_R_TYPE(val) ((val) & 0xff)
|
#define ELF32_R_TYPE(val) ((val) & 0xff)
|
||||||
#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
|
#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
|
||||||
--
|
--
|
||||||
cgit v1.2.1
|
2.43.0
|
||||||
|
|
591
musl/0002-scudo-add-necessary-plumbing.patch
Normal file
591
musl/0002-scudo-add-necessary-plumbing.patch
Normal file
|
@ -0,0 +1,591 @@
|
||||||
|
From e8cb1cb5235c8b928893305fe18e896411f4979b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daryl Ronningen <relms@relms.dev>
|
||||||
|
Date: Fri, 8 Dec 2023 12:31:42 -0800
|
||||||
|
Subject: [PATCH 2/4] scudo: add necessary plumbing
|
||||||
|
|
||||||
|
---
|
||||||
|
Makefile | 31 ++++++++++++++--
|
||||||
|
configure | 72 ++++++++++++++++++++++++++++++++++---
|
||||||
|
src/env/__init_tls.c | 1 +
|
||||||
|
src/include/errno.h | 8 +++++
|
||||||
|
src/include/features.h | 2 ++
|
||||||
|
src/include/pthread.h | 4 +++
|
||||||
|
src/include/sys/stat.h | 2 ++
|
||||||
|
src/include/time.h | 4 +++
|
||||||
|
src/internal/atomic.h | 4 +++
|
||||||
|
src/internal/linux/futex.h | 31 ++++++++++++++++
|
||||||
|
src/internal/pthread_impl.h | 3 ++
|
||||||
|
src/internal/syscall.h | 4 +++
|
||||||
|
src/malloc/calloc.c | 4 +++
|
||||||
|
src/malloc/libc_calloc.c | 4 +++
|
||||||
|
src/thread/pthread_create.c | 6 ++++
|
||||||
|
15 files changed, 174 insertions(+), 6 deletions(-)
|
||||||
|
create mode 100644 src/internal/linux/futex.h
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index e8cc4436..17158106 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -17,16 +17,19 @@ includedir = $(prefix)/include
|
||||||
|
libdir = $(prefix)/lib
|
||||||
|
syslibdir = /lib
|
||||||
|
|
||||||
|
-MALLOC_DIR = mallocng
|
||||||
|
+MALLOC_DIR = scudo
|
||||||
|
SRC_DIRS = $(addprefix $(srcdir)/,src/* src/malloc/$(MALLOC_DIR) crt ldso $(COMPAT_SRC_DIRS))
|
||||||
|
BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS))
|
||||||
|
+CPP_GLOBS = $(addsuffix /*.cpp,$(SRC_DIRS))
|
||||||
|
ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS))
|
||||||
|
BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS)))
|
||||||
|
+CPP_SRCS = $(sort $(wildcard $(CPP_GLOBS)))
|
||||||
|
ARCH_SRCS = $(sort $(wildcard $(ARCH_GLOBS)))
|
||||||
|
BASE_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(BASE_SRCS)))
|
||||||
|
+CPP_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(CPP_SRCS)))
|
||||||
|
ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS)))
|
||||||
|
REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS)))
|
||||||
|
-ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS))))
|
||||||
|
+ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(CPP_OBJS) $(ARCH_OBJS))))
|
||||||
|
|
||||||
|
LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS)) $(filter obj/compat/%,$(ALL_OBJS))
|
||||||
|
LDSO_OBJS = $(filter obj/ldso/%,$(ALL_OBJS:%.o=%.lo))
|
||||||
|
@@ -45,10 +48,18 @@ CPPFLAGS =
|
||||||
|
CFLAGS =
|
||||||
|
CFLAGS_AUTO = -Os -pipe
|
||||||
|
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
|
||||||
|
+CXXFLAGS =
|
||||||
|
+CXXFLAGS_AUTO = -Os -pipe
|
||||||
|
+CXXFLAGS_FSE = -std=c++17 -ffreestanding -nostdinc -nostdinc++ -fno-exceptions -fno-rtti -fvisibility=hidden
|
||||||
|
|
||||||
|
CFLAGS_ALL = $(CFLAGS_C99FSE)
|
||||||
|
CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
|
||||||
|
+
|
||||||
|
+CXXFLAGS_ALL = $(CXXFLAGS_FSE)
|
||||||
|
+CXXFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
|
||||||
|
+
|
||||||
|
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
|
||||||
|
+CXXFLAGS_ALL += $(CPPFLAGS) $(CXXFLAGS_AUTO) $(CXXFLAGS)
|
||||||
|
|
||||||
|
LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
|
||||||
|
|
||||||
|
@@ -117,6 +128,7 @@ obj/crt/Scrt1.o obj/crt/rcrt1.o: CFLAGS_ALL += -fPIC
|
||||||
|
|
||||||
|
OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(srcdir)/src/%))
|
||||||
|
$(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.lo): CFLAGS += -O3
|
||||||
|
+$(OPTIMIZE_SRCS:$(srcdir)/%.cpp=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.cpp=obj/%.lo): CXXFLAGS += -O3
|
||||||
|
|
||||||
|
MEMOPS_OBJS = $(filter %/memcpy.o %/memmove.o %/memcmp.o %/memset.o, $(LIBC_OBJS))
|
||||||
|
$(MEMOPS_OBJS) $(MEMOPS_OBJS:%.o=%.lo): CFLAGS_ALL += $(CFLAGS_MEMOPS)
|
||||||
|
@@ -130,8 +142,17 @@ $(NOSSP_OBJS) $(NOSSP_OBJS:%.o=%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP)
|
||||||
|
$(CRT_OBJS): CFLAGS_ALL += -DCRT
|
||||||
|
|
||||||
|
$(LOBJS) $(LDSO_OBJS): CFLAGS_ALL += -fPIC
|
||||||
|
+$(LOBJS) $(LDSO_OBJS): CXXFLAGS_ALL += -fPIC
|
||||||
|
+
|
||||||
|
+obj/src/malloc/scudo/crc32_hw.lo: CXXFLAGS_ALL += $(CXXFLAGS_CRC)
|
||||||
|
+
|
||||||
|
+ifeq (scudo,$(MALLOC_DIR))
|
||||||
|
+obj/src/malloc/calloc.lo: CFLAGS_ALL += -DLIBC_CALLOC_EXTERNAL
|
||||||
|
+obj/src/malloc/libc_calloc.lo: CFLAGS_ALL += -DLIBC_CALLOC_EXTERNAL
|
||||||
|
+endif
|
||||||
|
|
||||||
|
CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $<
|
||||||
|
+CXX_CMD = $(CXX) $(CXXFLAGS_ALL) -c -o $@ $<
|
||||||
|
|
||||||
|
# Choose invocation of assembler to be used
|
||||||
|
ifeq ($(ADD_CFI),yes)
|
||||||
|
@@ -149,6 +170,9 @@ obj/%.o: $(srcdir)/%.S
|
||||||
|
obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH)
|
||||||
|
$(CC_CMD)
|
||||||
|
|
||||||
|
+obj/%.o: $(srcdir)/%.cpp $(GENH) $(IMPH)
|
||||||
|
+ $(CXX_CMD)
|
||||||
|
+
|
||||||
|
obj/%.lo: $(srcdir)/%.s
|
||||||
|
$(AS_CMD)
|
||||||
|
|
||||||
|
@@ -158,6 +182,9 @@ obj/%.lo: $(srcdir)/%.S
|
||||||
|
obj/%.lo: $(srcdir)/%.c $(GENH) $(IMPH)
|
||||||
|
$(CC_CMD)
|
||||||
|
|
||||||
|
+obj/%.lo: $(srcdir)/%.cpp $(GENH) $(IMPH)
|
||||||
|
+ $(CXX_CMD)
|
||||||
|
+
|
||||||
|
lib/libc.so: $(LOBJS) $(LDSO_OBJS)
|
||||||
|
$(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -nostdlib -shared \
|
||||||
|
-Wl,-e,_dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC)
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 853bf05e..2a0632fa 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -63,6 +63,7 @@ fail () { echo "$*" ; exit 1 ; }
|
||||||
|
fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; }
|
||||||
|
cmdexists () { type "$1" >/dev/null 2>&1 ; }
|
||||||
|
trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
|
||||||
|
+trycxx () { test -z "$CXX" && cmdexists "$1" && CXX=$1 ; }
|
||||||
|
|
||||||
|
stripdir () {
|
||||||
|
while eval "fnmatch '*/' \"\${$1}\"" ; do eval "$1=\${$1%/}" ; done
|
||||||
|
@@ -97,6 +98,20 @@ return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
+tryxflag () {
|
||||||
|
+printf "checking whether C++ compiler accepts %s... " "$2"
|
||||||
|
+echo "typedef int x;" > "$tmpc"
|
||||||
|
+if $CXX $CXXFLAGS_TRY $2 -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
|
||||||
|
+printf "yes\n"
|
||||||
|
+eval "$1=\"\${$1} \$2\""
|
||||||
|
+eval "$1=\${$1# }"
|
||||||
|
+return 0
|
||||||
|
+else
|
||||||
|
+printf "no\n"
|
||||||
|
+return 1
|
||||||
|
+fi
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
tryldflag () {
|
||||||
|
printf "checking whether linker accepts %s... " "$2"
|
||||||
|
echo "typedef int x;" > "$tmpc"
|
||||||
|
@@ -120,6 +135,10 @@ CFLAGS_AUTO=
|
||||||
|
CFLAGS_MEMOPS=
|
||||||
|
CFLAGS_NOSSP=
|
||||||
|
CFLAGS_TRY=
|
||||||
|
+CXXFLAGS_FSE=
|
||||||
|
+CXXFLAGS_AUTO=
|
||||||
|
+CXXFLAGS_CRC=
|
||||||
|
+CXXFLAGS_TRY=
|
||||||
|
LDFLAGS_AUTO=
|
||||||
|
LDFLAGS_TRY=
|
||||||
|
OPTIMIZE_GLOBS=
|
||||||
|
@@ -142,7 +161,7 @@ static=yes
|
||||||
|
wrapper=auto
|
||||||
|
gcc_wrapper=no
|
||||||
|
clang_wrapper=no
|
||||||
|
-malloc_dir=mallocng
|
||||||
|
+malloc_dir=scudo
|
||||||
|
|
||||||
|
for arg ; do
|
||||||
|
case "$arg" in
|
||||||
|
@@ -180,7 +199,9 @@ case "$arg" in
|
||||||
|
AR=*) AR=${arg#*=} ;;
|
||||||
|
RANLIB=*) RANLIB=${arg#*=} ;;
|
||||||
|
CC=*) CC=${arg#*=} ;;
|
||||||
|
+CXX=*) CXX=${arg#*=} ;;
|
||||||
|
CFLAGS=*) CFLAGS=${arg#*=} ;;
|
||||||
|
+CXXFLAGS=*) CXXFLAGS=${arg#*=} ;;
|
||||||
|
CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
|
||||||
|
LDFLAGS=*) LDFLAGS=${arg#*=} ;;
|
||||||
|
CROSS_COMPILE=*) CROSS_COMPILE=${arg#*=} ;;
|
||||||
|
@@ -253,6 +274,21 @@ printf "no; compiler output follows:\n%s\n" "$output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
+printf "checking for C++ compiler... "
|
||||||
|
+trycxx ${CROSS_COMPILE}g++
|
||||||
|
+trycxx ${CROSS_COMPILE}c++
|
||||||
|
+printf "%s\n" "$CXX"
|
||||||
|
+test -n "$CXX" || { echo "$0: cannot find a C++ compiler" ; exit 1 ; }
|
||||||
|
+
|
||||||
|
+printf "checking whether C++ compiler works... "
|
||||||
|
+echo "typedef int x;" > "$tmpc"
|
||||||
|
+if output=$($CXX $CPPFLAGS $CXXFLAGS -c -o /dev/null "$tmpc" 2>&1) ; then
|
||||||
|
+printf "yes\n"
|
||||||
|
+else
|
||||||
|
+printf "no; compiler output follows:\n%s\n" "$output"
|
||||||
|
+exit 1
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Figure out options to force errors on unknown flags.
|
||||||
|
#
|
||||||
|
@@ -353,6 +389,14 @@ tryflag CFLAGS_C99FSE -fexcess-precision=standard \
|
||||||
|
|| { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; }
|
||||||
|
tryflag CFLAGS_C99FSE -frounding-math
|
||||||
|
|
||||||
|
+tryxflag CXXFLAGS_FSE -std=c++17
|
||||||
|
+tryxflag CXXFLAGS_FSE -nostdinc
|
||||||
|
+tryxflag CXXFLAGS_FSE -nostdinc++
|
||||||
|
+tryxflag CXXFLAGS_FSE -fno-exceptions
|
||||||
|
+tryxflag CXXFLAGS_FSE -fno-rtti
|
||||||
|
+tryxflag CXXFLAGS_FSE -ffreestanding || tryxflag CXXFLAGS_FSE -fno-builtin
|
||||||
|
+tryxflag CXXFLAGS_FSE -fvisibility=internal || tryxflag CXXFLAGS_FSE -fvisibility=hidden
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Semantically we want to insist that our sources follow the
|
||||||
|
# C rules for type-based aliasing, but most if not all real-world
|
||||||
|
@@ -388,6 +432,7 @@ fi
|
||||||
|
# linked with such object files. Fix this.
|
||||||
|
#
|
||||||
|
tryflag CFLAGS_C99FSE -Wa,--noexecstack
|
||||||
|
+tryxflag CXXFLAGS_FSE -Wa,--noexecstack
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for options to disable stack protector, which needs to be
|
||||||
|
@@ -405,10 +450,16 @@ tryflag CFLAGS_NOSSP -fno-stack-protector
|
||||||
|
#
|
||||||
|
tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns
|
||||||
|
|
||||||
|
+# enable the necessary instruction set for hardware crc32
|
||||||
|
+if test "$ARCH" = "x86_64"; then
|
||||||
|
+ tryxflag CXXFLAGS_CRC -mcrc32 || tryxflag CXXFLAGS_CRC -msse4.2
|
||||||
|
+fi
|
||||||
|
+test "$ARCH" = "aarch64" && tryflag CXXFLAGS_CRC -mcrc
|
||||||
|
+
|
||||||
|
#
|
||||||
|
# Enable debugging if requessted.
|
||||||
|
#
|
||||||
|
-test "$debug" = yes && CFLAGS_AUTO=-g
|
||||||
|
+test "$debug" = yes && CFLAGS_AUTO=-g && CXXFLAGS_AUTO=-g
|
||||||
|
|
||||||
|
#
|
||||||
|
# Preprocess asm files to add extra debugging information if debug is
|
||||||
|
@@ -445,7 +496,8 @@ xno|x) printf "disabled\n" ; optimize=no ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
test "$optimize" = no || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2
|
||||||
|
-test "$optimize" = yes && optimize="internal,malloc,string"
|
||||||
|
+test "$optimize" = no || tryflag CXXFLAGS_AUTO -Os || tryflag CXXFLAGS_AUTO -O2
|
||||||
|
+test "$optimize" = yes && optimize="internal,malloc,malloc/scudo,string"
|
||||||
|
|
||||||
|
if fnmatch 'no|size' "$optimize" ; then :
|
||||||
|
else
|
||||||
|
@@ -457,6 +509,7 @@ case "$optimize" in
|
||||||
|
esac
|
||||||
|
printf " $this"
|
||||||
|
case "$this" in
|
||||||
|
+malloc/scudo) this=$this/*.cpp ;;
|
||||||
|
*/*.c) ;;
|
||||||
|
*/*) this=$this*.c ;;
|
||||||
|
*) this=$this/*.c ;;
|
||||||
|
@@ -469,6 +522,7 @@ fi
|
||||||
|
|
||||||
|
# Always try -pipe
|
||||||
|
tryflag CFLAGS_AUTO -pipe
|
||||||
|
+tryxflag CXXFLAGS_AUTO -pipe
|
||||||
|
|
||||||
|
#
|
||||||
|
# If debugging is disabled, omit frame pointer. Modern GCC does this
|
||||||
|
@@ -478,6 +532,7 @@ tryflag CFLAGS_AUTO -pipe
|
||||||
|
if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" ; then :
|
||||||
|
else
|
||||||
|
tryflag CFLAGS_AUTO -fomit-frame-pointer
|
||||||
|
+tryxflag CXXFLAGS_AUTO -fomit-frame-pointer
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
@@ -488,6 +543,8 @@ fi
|
||||||
|
#
|
||||||
|
tryflag CFLAGS_AUTO -fno-unwind-tables
|
||||||
|
tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
|
||||||
|
+tryxflag CXXFLAGS_AUTO -fno-unwind-tables
|
||||||
|
+tryxflag CXXFLAGS_AUTO -fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
|
#
|
||||||
|
# Attempt to put each function and each data object in its own
|
||||||
|
@@ -499,6 +556,8 @@ tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
|
||||||
|
#
|
||||||
|
tryflag CFLAGS_AUTO -ffunction-sections
|
||||||
|
tryflag CFLAGS_AUTO -fdata-sections
|
||||||
|
+tryxflag CXXFLAGS_AUTO -ffunction-sections
|
||||||
|
+tryxflag CXXFLAGS_AUTO -fdata-sections
|
||||||
|
|
||||||
|
#
|
||||||
|
# On x86, make sure we don't have incompatible instruction set
|
||||||
|
@@ -519,7 +578,7 @@ fi
|
||||||
|
# to start from a clean slate. So use -w if building with clang. Also
|
||||||
|
# turn off a common on-by-default cast warning regardless of compiler.
|
||||||
|
#
|
||||||
|
-test "$cc_family" = clang && tryflag CFLAGS_AUTO -w
|
||||||
|
+test "$cc_family" = clang && tryflag CFLAGS_AUTO -w && tryxflag CXXFLAGS_AUTO -w
|
||||||
|
|
||||||
|
tryflag CFLAGS_AUTO -Wno-pointer-to-int-cast
|
||||||
|
|
||||||
|
@@ -787,11 +846,16 @@ libdir = $libdir
|
||||||
|
includedir = $includedir
|
||||||
|
syslibdir = $syslibdir
|
||||||
|
CC = $CC
|
||||||
|
+CXX = $CXX
|
||||||
|
CFLAGS = $CFLAGS
|
||||||
|
CFLAGS_AUTO = $CFLAGS_AUTO
|
||||||
|
CFLAGS_C99FSE = $CFLAGS_C99FSE
|
||||||
|
CFLAGS_MEMOPS = $CFLAGS_MEMOPS
|
||||||
|
CFLAGS_NOSSP = $CFLAGS_NOSSP
|
||||||
|
+CXXFLAGS = $CXXFLAGS
|
||||||
|
+CXXFLAGS_AUTO = $CXXFLAGS_AUTO
|
||||||
|
+CXXFLAGS_FSE = $CXXFLAGS_FSE
|
||||||
|
+CXXFLAGS_CRC = $CXXFLAGS_CRC
|
||||||
|
CPPFLAGS = $CPPFLAGS
|
||||||
|
LDFLAGS = $LDFLAGS
|
||||||
|
LDFLAGS_AUTO = $LDFLAGS_AUTO
|
||||||
|
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
|
||||||
|
index a93141ed..6347577c 100644
|
||||||
|
--- a/src/env/__init_tls.c
|
||||||
|
+++ b/src/env/__init_tls.c
|
||||||
|
@@ -21,6 +21,7 @@ int __init_tp(void *p)
|
||||||
|
td->detach_state = DT_JOINABLE;
|
||||||
|
td->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
|
||||||
|
td->locale = &libc.global_locale;
|
||||||
|
+ td->scudo_tsd = NULL;
|
||||||
|
td->robust_list.head = &td->robust_list.head;
|
||||||
|
td->sysinfo = __sysinfo;
|
||||||
|
td->next = td->prev = td;
|
||||||
|
diff --git a/src/include/errno.h b/src/include/errno.h
|
||||||
|
index 8ec49377..547e2af0 100644
|
||||||
|
--- a/src/include/errno.h
|
||||||
|
+++ b/src/include/errno.h
|
||||||
|
@@ -3,6 +3,10 @@
|
||||||
|
|
||||||
|
#include "../../include/errno.h"
|
||||||
|
|
||||||
|
+#ifdef __cplusplus
|
||||||
|
+extern "C" {
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#ifdef __GNUC__
|
||||||
|
__attribute__((const))
|
||||||
|
#endif
|
||||||
|
@@ -11,4 +15,8 @@ hidden int *___errno_location(void);
|
||||||
|
#undef errno
|
||||||
|
#define errno (*___errno_location())
|
||||||
|
|
||||||
|
+#ifdef __cplusplus
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/src/include/features.h b/src/include/features.h
|
||||||
|
index f17bd151..157f2def 100644
|
||||||
|
--- a/src/include/features.h
|
||||||
|
+++ b/src/include/features.h
|
||||||
|
@@ -3,7 +3,9 @@
|
||||||
|
|
||||||
|
#include "../../include/features.h"
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
#define weak __attribute__((__weak__))
|
||||||
|
+#endif
|
||||||
|
#define hidden __attribute__((__visibility__("hidden")))
|
||||||
|
#define weak_alias(old, new) \
|
||||||
|
extern __typeof(old) new __attribute__((__weak__, __alias__(#old)))
|
||||||
|
diff --git a/src/include/pthread.h b/src/include/pthread.h
|
||||||
|
index 7167d3e1..0107a704 100644
|
||||||
|
--- a/src/include/pthread.h
|
||||||
|
+++ b/src/include/pthread.h
|
||||||
|
@@ -3,6 +3,8 @@
|
||||||
|
|
||||||
|
#include "../../include/pthread.h"
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
+
|
||||||
|
hidden int __pthread_once(pthread_once_t *, void (*)(void));
|
||||||
|
hidden void __pthread_testcancel(void);
|
||||||
|
hidden int __pthread_setcancelstate(int, int *);
|
||||||
|
@@ -26,4 +28,6 @@ hidden int __pthread_rwlock_trywrlock(pthread_rwlock_t *);
|
||||||
|
hidden int __pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict);
|
||||||
|
hidden int __pthread_rwlock_unlock(pthread_rwlock_t *);
|
||||||
|
|
||||||
|
+#endif /* __cplusplus */
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/src/include/sys/stat.h b/src/include/sys/stat.h
|
||||||
|
index 59339bee..cc3af59d 100644
|
||||||
|
--- a/src/include/sys/stat.h
|
||||||
|
+++ b/src/include/sys/stat.h
|
||||||
|
@@ -3,7 +3,9 @@
|
||||||
|
|
||||||
|
#include "../../../include/sys/stat.h"
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
hidden int __fstat(int, struct stat *);
|
||||||
|
hidden int __fstatat(int, const char *restrict, struct stat *restrict, int);
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/src/include/time.h b/src/include/time.h
|
||||||
|
index cbabde47..8eefd311 100644
|
||||||
|
--- a/src/include/time.h
|
||||||
|
+++ b/src/include/time.h
|
||||||
|
@@ -3,6 +3,8 @@
|
||||||
|
|
||||||
|
#include "../../include/time.h"
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
+
|
||||||
|
hidden int __clock_gettime(clockid_t, struct timespec *);
|
||||||
|
hidden int __clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
|
||||||
|
|
||||||
|
@@ -12,4 +14,6 @@ hidden struct tm *__localtime_r(const time_t *restrict, struct tm *restrict);
|
||||||
|
|
||||||
|
hidden size_t __strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
|
||||||
|
|
||||||
|
+#endif /* __cplusplus */
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/src/internal/atomic.h b/src/internal/atomic.h
|
||||||
|
index 96c1552d..9c4e720c 100644
|
||||||
|
--- a/src/internal/atomic.h
|
||||||
|
+++ b/src/internal/atomic.h
|
||||||
|
@@ -3,6 +3,8 @@
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
+
|
||||||
|
#include "atomic_arch.h"
|
||||||
|
|
||||||
|
#ifdef a_ll
|
||||||
|
@@ -330,4 +332,6 @@ static inline int a_clz_32(uint32_t x)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#endif /* __cplusplus */
|
||||||
|
+
|
||||||
|
#endif
|
||||||
|
diff --git a/src/internal/linux/futex.h b/src/internal/linux/futex.h
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..0e216dcc
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/internal/linux/futex.h
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+#ifndef _INTERNAL_LINUX_FUTEX_H
|
||||||
|
+#define _INTERNAL_LINUX_FUTEX_H
|
||||||
|
+
|
||||||
|
+extern "C" {
|
||||||
|
+/* while at it, use the prefixed versions for mmap and so on */
|
||||||
|
+#include <sys/mman.h>
|
||||||
|
+/* must be first, otherwise the below include here would result in the syscall
|
||||||
|
+ * function in unistd being replaced by a macro into what would be invalid code
|
||||||
|
+ */
|
||||||
|
+#include <unistd.h>
|
||||||
|
+/* we include this here, so that linux.cpp in scudo does not use the unistd
|
||||||
|
+ * syscall definition but instead uses the macro that expands to raw calls
|
||||||
|
+ */
|
||||||
|
+#include "syscall.h"
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define mmap __mmap
|
||||||
|
+#define munmap __munmap
|
||||||
|
+#define mremap __mremap
|
||||||
|
+#define madvise __madvise
|
||||||
|
+#define mprotect __mprotect
|
||||||
|
+
|
||||||
|
+#define FUTEX_WAIT 0
|
||||||
|
+#define FUTEX_WAKE 1
|
||||||
|
+
|
||||||
|
+#define FUTEX_PRIVATE_FLAG 128
|
||||||
|
+
|
||||||
|
+#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
|
||||||
|
+#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
|
||||||
|
index de2b9d8b..22b39232 100644
|
||||||
|
--- a/src/internal/pthread_impl.h
|
||||||
|
+++ b/src/internal/pthread_impl.h
|
||||||
|
@@ -56,6 +56,7 @@ struct pthread {
|
||||||
|
volatile int timer_id;
|
||||||
|
locale_t locale;
|
||||||
|
volatile int killlock[1];
|
||||||
|
+ void *scudo_tsd;
|
||||||
|
char *dlerror_buf;
|
||||||
|
void *stdio_locks;
|
||||||
|
|
||||||
|
@@ -187,6 +188,8 @@ hidden void __tl_lock(void);
|
||||||
|
hidden void __tl_unlock(void);
|
||||||
|
hidden void __tl_sync(pthread_t);
|
||||||
|
|
||||||
|
+hidden void __malloc_tsd_teardown(void *p);
|
||||||
|
+
|
||||||
|
extern hidden volatile int __thread_list_lock;
|
||||||
|
|
||||||
|
extern hidden volatile int __abort_lock[1];
|
||||||
|
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
|
||||||
|
index 4a446157..a4ae20b5 100644
|
||||||
|
--- a/src/internal/syscall.h
|
||||||
|
+++ b/src/internal/syscall.h
|
||||||
|
@@ -58,6 +58,7 @@ hidden long __syscall_ret(unsigned long),
|
||||||
|
#define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
|
||||||
|
#define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a, syscall_arg_t b, syscall_arg_t c, syscall_arg_t d, syscall_arg_t e, syscall_arg_t f)
|
||||||
|
{
|
||||||
|
long r;
|
||||||
|
@@ -74,6 +75,7 @@ static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a,
|
||||||
|
__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
|
||||||
|
#define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \
|
||||||
|
__scc(a), __scc(b), __scc(c), __scc(d), __scc(e), __scc(f))
|
||||||
|
+#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* fixup legacy 16-bit junk */
|
||||||
|
|
||||||
|
@@ -391,8 +393,10 @@ static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a,
|
||||||
|
#define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__)
|
||||||
|
#define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__))
|
||||||
|
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned);
|
||||||
|
|
||||||
|
hidden void *__vdsosym(const char *, const char *);
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
diff --git a/src/malloc/calloc.c b/src/malloc/calloc.c
|
||||||
|
index bf6bddca..6aa482c6 100644
|
||||||
|
--- a/src/malloc/calloc.c
|
||||||
|
+++ b/src/malloc/calloc.c
|
||||||
|
@@ -32,6 +32,10 @@ weak_alias(allzerop, __malloc_allzerop);
|
||||||
|
|
||||||
|
void *calloc(size_t m, size_t n)
|
||||||
|
{
|
||||||
|
+#ifdef LIBC_CALLOC_EXTERNAL
|
||||||
|
+ if (!__malloc_replaced)
|
||||||
|
+ return __libc_calloc(m, n);
|
||||||
|
+#endif
|
||||||
|
if (n && m > (size_t)-1/n) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return 0;
|
||||||
|
diff --git a/src/malloc/libc_calloc.c b/src/malloc/libc_calloc.c
|
||||||
|
index d25eabea..3895c8cf 100644
|
||||||
|
--- a/src/malloc/libc_calloc.c
|
||||||
|
+++ b/src/malloc/libc_calloc.c
|
||||||
|
@@ -1,4 +1,8 @@
|
||||||
|
+#ifndef LIBC_CALLOC_EXTERNAL
|
||||||
|
+
|
||||||
|
#define calloc __libc_calloc
|
||||||
|
#define malloc __libc_malloc
|
||||||
|
|
||||||
|
#include "calloc.c"
|
||||||
|
+
|
||||||
|
+#endif
|
||||||
|
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
|
||||||
|
index 087f6206..b1345b34 100644
|
||||||
|
--- a/src/thread/pthread_create.c
|
||||||
|
+++ b/src/thread/pthread_create.c
|
||||||
|
@@ -68,6 +68,7 @@ _Noreturn void __pthread_exit(void *result)
|
||||||
|
}
|
||||||
|
|
||||||
|
__pthread_tsd_run_dtors();
|
||||||
|
+ __malloc_tsd_teardown(&self->scudo_tsd);
|
||||||
|
|
||||||
|
__block_app_sigs(&set);
|
||||||
|
|
||||||
|
@@ -319,6 +320,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
|
||||||
|
new->self = new;
|
||||||
|
new->tsd = (void *)tsd;
|
||||||
|
new->locale = &libc.global_locale;
|
||||||
|
+ new->scudo_tsd = NULL;
|
||||||
|
if (attr._a_detach) {
|
||||||
|
new->detach_state = DT_DETACHED;
|
||||||
|
} else {
|
||||||
|
@@ -395,3 +397,7 @@ fail:
|
||||||
|
|
||||||
|
weak_alias(__pthread_exit, pthread_exit);
|
||||||
|
weak_alias(__pthread_create, pthread_create);
|
||||||
|
+
|
||||||
|
+static void malloc_tsd_teardown(void *p) {}
|
||||||
|
+
|
||||||
|
+weak_alias(malloc_tsd_teardown, __malloc_tsd_teardown);
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
From 2619aa091426b124e91e631e4214f0d3a85bb251 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daniel Kolesa <daniel@octaforge.org>
|
||||||
|
Date: Fri, 9 Dec 2022 00:15:57 +0100
|
||||||
|
Subject: [PATCH 3/4] scudo: clean up lingering weak symbols we don't want
|
||||||
|
|
||||||
|
---
|
||||||
|
src/malloc/scudo/checksum.h | 2 +-
|
||||||
|
src/malloc/scudo/combined.h | 2 +-
|
||||||
|
src/malloc/scudo/crc32_hw.cpp | 4 ++++
|
||||||
|
src/malloc/scudo/linux.cpp | 7 +++++++
|
||||||
|
4 files changed, 13 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/malloc/scudo/checksum.h b/src/malloc/scudo/checksum.h
|
||||||
|
index f8eda81f..d61b6d88 100644
|
||||||
|
--- a/src/malloc/scudo/checksum.h
|
||||||
|
+++ b/src/malloc/scudo/checksum.h
|
||||||
|
@@ -52,7 +52,7 @@ inline u16 computeBSDChecksum(u16 Sum, uptr Data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasHardwareCRC32();
|
||||||
|
-WEAK u32 computeHardwareCRC32(u32 Crc, uptr Data);
|
||||||
|
+u32 computeHardwareCRC32(u32 Crc, uptr Data);
|
||||||
|
|
||||||
|
} // namespace scudo
|
||||||
|
|
||||||
|
diff --git a/src/malloc/scudo/combined.h b/src/malloc/scudo/combined.h
|
||||||
|
index b17acc71..e62c9177 100644
|
||||||
|
--- a/src/malloc/scudo/combined.h
|
||||||
|
+++ b/src/malloc/scudo/combined.h
|
||||||
|
@@ -139,7 +139,7 @@ public:
|
||||||
|
|
||||||
|
// Check if hardware CRC32 is supported in the binary and by the platform,
|
||||||
|
// if so, opt for the CRC32 hardware version of the checksum.
|
||||||
|
- if (&computeHardwareCRC32 && hasHardwareCRC32())
|
||||||
|
+ if (hasHardwareCRC32())
|
||||||
|
HashAlgorithm = Checksum::HardwareCRC32;
|
||||||
|
|
||||||
|
if (UNLIKELY(!getRandom(&Cookie, sizeof(Cookie))))
|
||||||
|
diff --git a/src/malloc/scudo/crc32_hw.cpp b/src/malloc/scudo/crc32_hw.cpp
|
||||||
|
index 73f2ae00..4fe16933 100644
|
||||||
|
--- a/src/malloc/scudo/crc32_hw.cpp
|
||||||
|
+++ b/src/malloc/scudo/crc32_hw.cpp
|
||||||
|
@@ -14,6 +14,10 @@ namespace scudo {
|
||||||
|
u32 computeHardwareCRC32(u32 Crc, uptr Data) {
|
||||||
|
return static_cast<u32>(CRC32_INTRINSIC(Crc, Data));
|
||||||
|
}
|
||||||
|
+#else
|
||||||
|
+u32 computeHardwareCRC32(u32, uptr) {
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
#endif // defined(__CRC32__) || defined(__SSE4_2__) ||
|
||||||
|
// defined(__ARM_FEATURE_CRC32)
|
||||||
|
|
||||||
|
diff --git a/src/malloc/scudo/linux.cpp b/src/malloc/scudo/linux.cpp
|
||||||
|
index e285d8a3..b4603966 100644
|
||||||
|
--- a/src/malloc/scudo/linux.cpp
|
||||||
|
+++ b/src/malloc/scudo/linux.cpp
|
||||||
|
@@ -193,9 +193,11 @@ bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
|
||||||
|
return (ReadBytes == static_cast<ssize_t>(Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if SCUDO_ANDROID
|
||||||
|
// Allocation free syslog-like API.
|
||||||
|
extern "C" WEAK int async_safe_write_log(int pri, const char *tag,
|
||||||
|
const char *msg);
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
static uptr GetRSSFromBuffer(const char *Buf) {
|
||||||
|
// The format of the file is:
|
||||||
|
@@ -230,6 +232,7 @@ uptr GetRSS() {
|
||||||
|
return GetRSSFromBuffer(Buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if SCUDO_ANDROID
|
||||||
|
void outputRaw(const char *Buffer) {
|
||||||
|
if (&async_safe_write_log) {
|
||||||
|
constexpr s32 AndroidLogInfo = 4;
|
||||||
|
@@ -262,6 +265,10 @@ void setAbortMessage(const char *Message) {
|
||||||
|
if (&android_set_abort_message)
|
||||||
|
android_set_abort_message(Message);
|
||||||
|
}
|
||||||
|
+#else
|
||||||
|
+void outputRaw(const char *) {}
|
||||||
|
+void setAbortMessage(const char *) {}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
} // namespace scudo
|
||||||
|
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
106
musl/0004-do-not-rely-on-system-headers-for-cpu-info.patch
Normal file
106
musl/0004-do-not-rely-on-system-headers-for-cpu-info.patch
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
From 78ca6e5e5fe60bff41b5792a4734e2cba1ced8be Mon Sep 17 00:00:00 2001
|
||||||
|
From: Daniel Kolesa <daniel@octaforge.org>
|
||||||
|
Date: Sat, 10 Dec 2022 17:24:17 +0100
|
||||||
|
Subject: [PATCH 4/4] do not rely on system headers for cpu info
|
||||||
|
|
||||||
|
---
|
||||||
|
src/malloc/scudo/checksum.cpp | 32 +++++++++++++++++++++++---------
|
||||||
|
src/malloc/scudo/checksum.h | 26 ++++++++++++++++----------
|
||||||
|
2 files changed, 39 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/malloc/scudo/checksum.cpp b/src/malloc/scudo/checksum.cpp
|
||||||
|
index 2c277391..49270ecb 100644
|
||||||
|
--- a/src/malloc/scudo/checksum.cpp
|
||||||
|
+++ b/src/malloc/scudo/checksum.cpp
|
||||||
|
@@ -10,9 +10,7 @@
|
||||||
|
#include "atomic_helpers.h"
|
||||||
|
#include "chunk.h"
|
||||||
|
|
||||||
|
-#if defined(__x86_64__) || defined(__i386__)
|
||||||
|
-#include <cpuid.h>
|
||||||
|
-#elif defined(__arm__) || defined(__aarch64__)
|
||||||
|
+#if defined(__arm__) || defined(__aarch64__)
|
||||||
|
#if SCUDO_FUCHSIA
|
||||||
|
#include <zircon/features.h>
|
||||||
|
#include <zircon/syscalls.h>
|
||||||
|
@@ -28,16 +26,32 @@ Checksum HashAlgorithm = {Checksum::BSD};
|
||||||
|
#if defined(__x86_64__) || defined(__i386__)
|
||||||
|
// i386 and x86_64 specific code to detect CRC32 hardware support via CPUID.
|
||||||
|
// CRC32 requires the SSE 4.2 instruction set.
|
||||||
|
-#ifndef bit_SSE4_2
|
||||||
|
-#define bit_SSE4_2 bit_SSE42 // clang and gcc have different defines.
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
-#ifndef signature_HYGON_ebx // They are not defined in gcc.
|
||||||
|
-// HYGON: "HygonGenuine".
|
||||||
|
+#define bit_SSE4_2 (1 << 20)
|
||||||
|
+// signatures from cpuid.h
|
||||||
|
+#define signature_AMD_ebx 0x68747541
|
||||||
|
+#define signature_AMD_edx 0x69746e65
|
||||||
|
+#define signature_AMD_ecx 0x444d4163
|
||||||
|
+#define signature_INTEL_ebx 0x756e6547
|
||||||
|
+#define signature_INTEL_edx 0x49656e69
|
||||||
|
+#define signature_INTEL_ecx 0x6c65746e
|
||||||
|
#define signature_HYGON_ebx 0x6f677948
|
||||||
|
#define signature_HYGON_edx 0x6e65476e
|
||||||
|
#define signature_HYGON_ecx 0x656e6975
|
||||||
|
+
|
||||||
|
+inline void __get_cpuid(
|
||||||
|
+ unsigned int leaf, unsigned int *eax, unsigned int *ebx,
|
||||||
|
+ unsigned int *ecx, unsigned int *edx
|
||||||
|
+) {
|
||||||
|
+#if __i386__
|
||||||
|
+ __asm("cpuid" : "=a"(*eax), "=b" (*ebx), "=c"(*ecx), "=d"(*edx) : "0"(leaf));
|
||||||
|
+#else
|
||||||
|
+ __asm(" xchgq %%rbx,%q1\n"
|
||||||
|
+ " cpuid\n"
|
||||||
|
+ " xchgq %%rbx,%q1"
|
||||||
|
+ : "=a"(*eax), "=r" (*ebx), "=c"(*ecx), "=d"(*edx)
|
||||||
|
+ : "0"(leaf));
|
||||||
|
#endif
|
||||||
|
+}
|
||||||
|
|
||||||
|
bool hasHardwareCRC32() {
|
||||||
|
u32 Eax, Ebx = 0, Ecx = 0, Edx = 0;
|
||||||
|
diff --git a/src/malloc/scudo/checksum.h b/src/malloc/scudo/checksum.h
|
||||||
|
index d61b6d88..8e738730 100644
|
||||||
|
--- a/src/malloc/scudo/checksum.h
|
||||||
|
+++ b/src/malloc/scudo/checksum.h
|
||||||
|
@@ -17,18 +17,24 @@
|
||||||
|
// An additional check must be performed at runtime as well to make sure the
|
||||||
|
// emitted instructions are valid on the target host.
|
||||||
|
|
||||||
|
-#if defined(__CRC32__)
|
||||||
|
-// NB: clang has <crc32intrin.h> but GCC does not
|
||||||
|
-#include <smmintrin.h>
|
||||||
|
-#define CRC32_INTRINSIC \
|
||||||
|
- FIRST_32_SECOND_64(__builtin_ia32_crc32si, __builtin_ia32_crc32di)
|
||||||
|
-#elif defined(__SSE4_2__)
|
||||||
|
-#include <smmintrin.h>
|
||||||
|
-#define CRC32_INTRINSIC FIRST_32_SECOND_64(_mm_crc32_u32, _mm_crc32_u64)
|
||||||
|
+#if defined(__CRC32__) || defined(__SSE4_2__)
|
||||||
|
+#ifdef __x86_64__
|
||||||
|
+#define CRC32_INTRINSIC __builtin_ia32_crc32di
|
||||||
|
+#else
|
||||||
|
+#define CRC32_INTRINSIC __builtin_ia32_crc32si
|
||||||
|
#endif
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#ifdef __ARM_FEATURE_CRC32
|
||||||
|
-#include <arm_acle.h>
|
||||||
|
-#define CRC32_INTRINSIC FIRST_32_SECOND_64(__crc32cw, __crc32cd)
|
||||||
|
+#ifndef __aarch64__
|
||||||
|
+#define CRC32_INTRINSIC __builtin_arm_crc32cw
|
||||||
|
+#else
|
||||||
|
+#ifdef __clang__
|
||||||
|
+#define CRC32_INTRINSIC __builtin_arm_crc32cd
|
||||||
|
+#else
|
||||||
|
+#define CRC32_INTRINSIC __builtin_aarch64_crc32cx
|
||||||
|
+#endif
|
||||||
|
+#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace scudo {
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
# Maintainer: Daryl Ronningen <relms@relms.dev>
|
||||||
|
|
||||||
|
_llvmver=17.0.6
|
||||||
pkgname=musl
|
pkgname=musl
|
||||||
pkgver=1.2.4
|
pkgver=1.2.4
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
|
@ -7,24 +8,52 @@ pkgdesc="Lightweight implementation of C standard library"
|
||||||
arch=("x86_64")
|
arch=("x86_64")
|
||||||
url="https://musl.libc.org/"
|
url="https://musl.libc.org/"
|
||||||
license=("MIT")
|
license=("MIT")
|
||||||
|
optdepends=(
|
||||||
|
"argp-standalone: Port of argp from Glibc"
|
||||||
|
"musl-fts: adds fts(3) functions"
|
||||||
|
"musl-obstack: add obstack from Glibc"
|
||||||
|
)
|
||||||
source=(
|
source=(
|
||||||
"https://musl.libc.org/releases/musl-$pkgver.tar.gz"
|
"https://musl.libc.org/releases/musl-$pkgver.tar.gz"
|
||||||
"add-typedefs-for-Elf64_Relr-and-Elf32_Relr.patch"
|
"https://github.com/llvm/llvm-project/releases/download/llvmorg-$_llvmver/compiler-rt-$_llvmver.src.tar.xz"
|
||||||
|
"0001-elf.h-add-typedefs-for-Elf64_Relr-and-Elf32_Relr.patch"
|
||||||
|
"0002-scudo-add-necessary-plumbing.patch"
|
||||||
|
"0003-scudo-clean-up-lingering-weak-symbols-we-don-t-want.patch"
|
||||||
|
"0004-do-not-rely-on-system-headers-for-cpu-info.patch"
|
||||||
|
"wrappers.cpp"
|
||||||
)
|
)
|
||||||
sha256sums=(
|
sha256sums=(
|
||||||
"7a35eae33d5372a7c0da1188de798726f68825513b7ae3ebe97aaaa52114f039"
|
"7a35eae33d5372a7c0da1188de798726f68825513b7ae3ebe97aaaa52114f039"
|
||||||
"d5f639c6f38504805a07a426ccc4fbb0f657205047009143baf972f6687335f4"
|
"11b8d09dcf92a0f91c5c82defb5ad9ff4acf5cf073a80c317204baa922d136b4"
|
||||||
|
"34927e9de1a3e48fa8ccbbe5dbc13b2f4b04c66672f65b2647ab341007c84cf4"
|
||||||
|
"8c15025c99091ab2b903232359093029e15658d05484aae8254005046d86ff3a"
|
||||||
|
"cb3e01d5011c48b86f390246a3b710e02fd2e28278743f65098c4242c3cb3241"
|
||||||
|
"2827fefaf25076d5638d713f4dbd99c44330ca83d28989566cc1c089c66c4613"
|
||||||
|
"55b485a26ec69a4fdb44169b12e09d239ad2eea922a2de8d56caf76fd8355e12"
|
||||||
)
|
)
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname-$pkgver
|
||||||
|
|
||||||
patch -p1 <$srcdir/add-typedefs-for-Elf64_Relr-and-Elf32_Relr.patch
|
# Add scudo
|
||||||
|
mkdir -p src/malloc/scudo/scudo/
|
||||||
|
cp -r $srcdir/compiler-rt-$_llvmver.src/lib/scudo/standalone/*.{cpp,h,inc} src/malloc/scudo/
|
||||||
|
cp -r $srcdir/compiler-rt-$_llvmver.src/lib/scudo/standalone/include/scudo/*.h src/malloc/scudo/scudo/
|
||||||
|
|
||||||
|
# Add wrappers from chimera linux
|
||||||
|
rm src/malloc/scudo/wrappers*
|
||||||
|
cp -r $srcdir/wrappers.cpp src/malloc/scudo/
|
||||||
|
|
||||||
|
patch -p1 <$srcdir/0001-elf.h-add-typedefs-for-Elf64_Relr-and-Elf32_Relr.patch
|
||||||
|
patch -p1 <$srcdir/0002-scudo-add-necessary-plumbing.patch
|
||||||
|
patch -p1 <$srcdir/0003-scudo-clean-up-lingering-weak-symbols-we-don-t-want.patch
|
||||||
|
patch -p1 <$srcdir/0004-do-not-rely-on-system-headers-for-cpu-info.patch
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $pkgname-$pkgver
|
cd $pkgname-$pkgver
|
||||||
./configure --prefix=/usr
|
|
||||||
|
./configure --prefix=/usr --with-malloc=scudo
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +64,7 @@ package() {
|
||||||
mv $pkgdir/lib/* $pkgdir/usr/lib/
|
mv $pkgdir/lib/* $pkgdir/usr/lib/
|
||||||
rm -rf $pkgdir/lib
|
rm -rf $pkgdir/lib
|
||||||
mkdir $pkgdir/usr/bin
|
mkdir $pkgdir/usr/bin
|
||||||
ln -s ../lib/ld-musl-x86_64.so.1 $pkgdir/usr/bin/ldd
|
ln -s ../lib/ld-musl-$CARCH.so.1 $pkgdir/usr/bin/ldd
|
||||||
|
|
||||||
install -Dm0644 README "$pkgdir"/usr/share/doc/musl/README
|
install -Dm0644 README "$pkgdir"/usr/share/doc/musl/README
|
||||||
install -Dm0644 COPYRIGHT "$pkgdir"/usr/share/licenses/musl/COPYRIGHT
|
install -Dm0644 COPYRIGHT "$pkgdir"/usr/share/licenses/musl/COPYRIGHT
|
||||||
|
|
524
musl/wrappers.cpp
Normal file
524
musl/wrappers.cpp
Normal file
|
@ -0,0 +1,524 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "pthread_impl.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "allocator_config.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
|
/* we don't use standard lib so define a placement-new */
|
||||||
|
inline void *operator new (size_t, void *p) { return p; }
|
||||||
|
inline void operator delete (void *, void *) {}
|
||||||
|
|
||||||
|
/* we will request 64k memory at a time
|
||||||
|
*
|
||||||
|
* this may be as little as 1 page on some systems,
|
||||||
|
* and it will hold around 8 TSDs
|
||||||
|
*/
|
||||||
|
#ifndef MUSL_SCUDO_TSD_CHUNK
|
||||||
|
#define MUSL_SCUDO_TSD_CHUNK 65536
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* the secondary cache was not found to be not much of a benefit
|
||||||
|
* (typically higher rss and often worse performance) while also
|
||||||
|
* causing some strange jank on qemu-user/riscv builders, so drop
|
||||||
|
* it at least for now
|
||||||
|
*/
|
||||||
|
#ifndef MUSL_SCUDO_USE_SECONDARY_CACHE
|
||||||
|
#define MUSL_SCUDO_USE_SECONDARY_CACHE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline constexpr size_t size_round(size_t sz, size_t align) {
|
||||||
|
return ((sz + align - 1) / align) * align;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename TM>
|
||||||
|
inline constexpr size_t tsds_in_chunk() {
|
||||||
|
return (MUSL_SCUDO_TSD_CHUNK - sizeof(TM)) / size_round(sizeof(T), alignof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tsd registry implementation specific to musl pthreads
|
||||||
|
*
|
||||||
|
* we need to use a custom one, because the existing exclusive registry
|
||||||
|
* relies on thread_local for its state initialization and the tsd object
|
||||||
|
* itself, which will mess things up for main thread for dynamic executables
|
||||||
|
* loaded through ldso, and also uses pthread keys and stuff, which we do
|
||||||
|
* not like for libc
|
||||||
|
*
|
||||||
|
* so map the tsd object memory manually, and keep track of it using a custom
|
||||||
|
* algorithm, storing only one pointer to the tsd object within the thread
|
||||||
|
* object internally
|
||||||
|
*
|
||||||
|
* we map chunks of MUSL_SCUDO_TSD_CHUNK size, each containing storage for
|
||||||
|
* as many TSD objects as possible (the first chunk is allocated almost
|
||||||
|
* immediately, for the fallback TSD); these are managed like a linked list,
|
||||||
|
* so that when threads exit, their TSDs are given back to the list to be
|
||||||
|
* reused; in case we run out, a new chunk is mapped as needed
|
||||||
|
*
|
||||||
|
* to make sure that we don't just map memory and never release any, the
|
||||||
|
* chunks are freed as necessary; the strategy is that there can only ever
|
||||||
|
* be one chunk that is fully empty - that effectively means an empty chunk
|
||||||
|
* is unmapped when another chunk becomes empty
|
||||||
|
*
|
||||||
|
* the 64k value was chosen for the chunk size as it's the maximum size of
|
||||||
|
* a single page one is generally to encounter, which means on these systems
|
||||||
|
* only a single page will be mapped at a time (on other systems, it will be
|
||||||
|
* multiple pages); regardless of page size, the chunk will be able to fit
|
||||||
|
* several TSDs
|
||||||
|
*/
|
||||||
|
|
||||||
|
template<typename TSD>
|
||||||
|
class TSDAllocator {
|
||||||
|
struct chunk;
|
||||||
|
|
||||||
|
struct tsdata {
|
||||||
|
TSD tsd;
|
||||||
|
tsdata *next;
|
||||||
|
chunk *parent;
|
||||||
|
uint32_t dirty: 1;
|
||||||
|
uint32_t unused: 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct chunk_meta {
|
||||||
|
chunk *below;
|
||||||
|
chunk *above;
|
||||||
|
unsigned short nused;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct chunk {
|
||||||
|
tsdata tsds[tsds_in_chunk<tsdata, chunk_meta>()];
|
||||||
|
chunk_meta m;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(chunk) < MUSL_SCUDO_TSD_CHUNK, "chunk too large");
|
||||||
|
|
||||||
|
void init_chunk(chunk *ch) {
|
||||||
|
ch->m.below = p_chunks;
|
||||||
|
ch->m.above = nullptr;
|
||||||
|
ch->m.nused = 0;
|
||||||
|
if (p_chunks) {
|
||||||
|
p_chunks->m.above = ch;
|
||||||
|
}
|
||||||
|
p_chunks = ch;
|
||||||
|
/* init links */
|
||||||
|
auto tsdn = (sizeof(ch->tsds) / sizeof(tsdata));
|
||||||
|
for (size_t i = 0; i < (tsdn - 1); ++i) {
|
||||||
|
ch->tsds[i].parent = ch;
|
||||||
|
ch->tsds[i].next = &ch->tsds[i + 1];
|
||||||
|
ch->tsds[i].dirty = 0;
|
||||||
|
ch->tsds[i].unused = 1;
|
||||||
|
}
|
||||||
|
ch->tsds[tsdn - 1].parent = ch;
|
||||||
|
ch->tsds[tsdn - 1].next = nullptr;
|
||||||
|
ch->tsds[tsdn - 1].dirty = 0;
|
||||||
|
ch->tsds[tsdn - 1].unused = 1;
|
||||||
|
/* init unused */
|
||||||
|
p_unused = ch->tsds;
|
||||||
|
}
|
||||||
|
|
||||||
|
void release_freechunk() {
|
||||||
|
if (!p_freechunk) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* unmap and unset whatever previous freechunk we may have
|
||||||
|
*
|
||||||
|
* doing this ensures that whenever there may be a newly
|
||||||
|
* gained empty chunk, the previous empty chunk will be
|
||||||
|
* unmapped, so there is always at most one and never more
|
||||||
|
*/
|
||||||
|
auto *ch = p_freechunk;
|
||||||
|
p_freechunk = nullptr;
|
||||||
|
/* update chunks pointer if needed */
|
||||||
|
if (ch == p_chunks) {
|
||||||
|
p_chunks = ch->m.below;
|
||||||
|
}
|
||||||
|
/* first unchain */
|
||||||
|
if (ch->m.below) {
|
||||||
|
ch->m.below->m.above = ch->m.above;
|
||||||
|
}
|
||||||
|
if (ch->m.above) {
|
||||||
|
ch->m.above->m.below = ch->m.below;
|
||||||
|
}
|
||||||
|
/* decide based on where our first pointer was positioned */
|
||||||
|
auto *sp = p_unused;
|
||||||
|
if (sp->parent == ch) {
|
||||||
|
/* we were at the beginning */
|
||||||
|
while (sp->parent == ch) {
|
||||||
|
sp = sp->next;
|
||||||
|
}
|
||||||
|
p_unused = sp;
|
||||||
|
} else {
|
||||||
|
/* we were in the middle or at the end */
|
||||||
|
while (sp->next->parent != ch) {
|
||||||
|
sp = sp->next;
|
||||||
|
}
|
||||||
|
auto *ep = sp->next;
|
||||||
|
while (ep && (ep->parent == ch)) {
|
||||||
|
ep = ep->next;
|
||||||
|
}
|
||||||
|
sp->next = ep;
|
||||||
|
}
|
||||||
|
/* then unmap */
|
||||||
|
scudo::unmap(ch, sizeof(chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdata *p_unused = nullptr;
|
||||||
|
chunk *p_chunks = nullptr;
|
||||||
|
chunk *p_freechunk = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TSD *request() {
|
||||||
|
if (!p_unused) {
|
||||||
|
auto *ch = static_cast<chunk *>(scudo::map(
|
||||||
|
nullptr, sizeof(chunk), "scudo:tsdchunk"
|
||||||
|
));
|
||||||
|
new (ch) chunk{};
|
||||||
|
init_chunk(ch);
|
||||||
|
} else if (p_unused->parent == p_freechunk) {
|
||||||
|
/* chunk will be occupied again */
|
||||||
|
p_freechunk = nullptr;
|
||||||
|
}
|
||||||
|
/* yoink */
|
||||||
|
tsdata *tsd = p_unused;
|
||||||
|
p_unused = p_unused->next;
|
||||||
|
tsd->next = nullptr;
|
||||||
|
tsd->unused = 0;
|
||||||
|
++tsd->parent->m.nused;
|
||||||
|
/* wipe dirty (recycled) tsds first */
|
||||||
|
if (tsd->dirty) {
|
||||||
|
memset(&tsd->tsd, 0, sizeof(tsd->tsd));
|
||||||
|
new (&tsd->tsd) TSD{};
|
||||||
|
}
|
||||||
|
return &tsd->tsd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return it to the allocator; the TSD is destroyed but tsdata is not */
|
||||||
|
void release(TSD *tsd) {
|
||||||
|
tsdata *p;
|
||||||
|
/* get original structure */
|
||||||
|
memcpy(&p, &tsd, sizeof(void *));
|
||||||
|
/* get parent chunk */
|
||||||
|
auto *ch = p->parent;
|
||||||
|
/* empty chunk? */
|
||||||
|
if (!--ch->m.nused) {
|
||||||
|
/* drop the previous freechunk if needed */
|
||||||
|
release_freechunk();
|
||||||
|
/* assign new freechunk once empty */
|
||||||
|
p_freechunk = ch;
|
||||||
|
}
|
||||||
|
/* delay memset until it's actually needed */
|
||||||
|
p->dirty = 1;
|
||||||
|
/* try to locate a unused node */
|
||||||
|
for (size_t i = 0; i < (sizeof(ch->tsds) / sizeof(tsdata)); ++i) {
|
||||||
|
if (ch->tsds[i].unused) {
|
||||||
|
auto *pp = &ch->tsds[i];
|
||||||
|
auto *pn = pp->next;
|
||||||
|
pp->next = p;
|
||||||
|
p->next = pn;
|
||||||
|
p->unused = 1;
|
||||||
|
/* we are done here */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* couldn't locate a unused node, put it in the front */
|
||||||
|
p->unused = 1;
|
||||||
|
p->next = p_unused;
|
||||||
|
p_unused = p;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename A>
|
||||||
|
struct TSDRegistry {
|
||||||
|
using tsd_t = scudo::TSD<A>;
|
||||||
|
|
||||||
|
void enable() {
|
||||||
|
atomic_store(&p_disabled, 0U, scudo::memory_order_release);
|
||||||
|
p_fallback->unlock();
|
||||||
|
p_mtx.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable() {
|
||||||
|
p_mtx.lock();
|
||||||
|
p_fallback->lock();
|
||||||
|
atomic_store(&p_disabled, 1U, scudo::memory_order_release);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this is normally adjustable through setOption, but we do not have
|
||||||
|
* mallopt, which means setOption is never actually called by anything
|
||||||
|
* (and does not exist for this registry) so return the sane default
|
||||||
|
*/
|
||||||
|
bool getDisableMemInit() { return false; }
|
||||||
|
|
||||||
|
void getStats(scudo::ScopedString *str) {
|
||||||
|
str->append("Iterating each TSD is not supported\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void drainCaches(A *inst) {
|
||||||
|
auto *self = get_self();
|
||||||
|
inst->drainCache(static_cast<tsd_t *>(self->scudo_tsd));
|
||||||
|
p_fallback->lock();
|
||||||
|
inst->drainCache(p_fallback);
|
||||||
|
p_fallback->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initOnceMaybe(A *inst) {
|
||||||
|
scudo::ScopedLock L{p_mtx};
|
||||||
|
init_once_maybe(inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void initThreadMaybe(A *inst, bool minimal) {
|
||||||
|
auto *self = get_self();
|
||||||
|
if (LIKELY(self->scudo_tsd)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
init_thread(inst, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE tsd_t *getTSDAndLock(bool *unlock) {
|
||||||
|
auto *self = get_self();
|
||||||
|
if (LIKELY(
|
||||||
|
self->scudo_tsd &&
|
||||||
|
!scudo::atomic_load(&p_disabled, scudo::memory_order_acquire)
|
||||||
|
)) {
|
||||||
|
*unlock = false;
|
||||||
|
return static_cast<tsd_t *>(self->scudo_tsd);
|
||||||
|
}
|
||||||
|
p_fallback->lock();
|
||||||
|
*unlock = true;
|
||||||
|
return p_fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend void ::__malloc_tsd_teardown(void *p);
|
||||||
|
|
||||||
|
/* return it to the allocator */
|
||||||
|
void dispose(A *inst, tsd_t *tsd) {
|
||||||
|
/* commit back and destroy, no need to lock yet */
|
||||||
|
tsd->commitBack(inst);
|
||||||
|
tsd->~tsd_t();
|
||||||
|
{
|
||||||
|
scudo::ScopedLock L{p_mtx};
|
||||||
|
p_talloc.release(tsd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* assumes locked p_mtx */
|
||||||
|
void init_once_maybe(A *inst) {
|
||||||
|
if (LIKELY(p_init)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inst->init();
|
||||||
|
p_fallback = p_talloc.request();
|
||||||
|
p_fallback->init(inst);
|
||||||
|
p_init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_thread(A *inst, struct pthread *self) {
|
||||||
|
tsd_t *tsd;
|
||||||
|
{
|
||||||
|
scudo::ScopedLock L{p_mtx};
|
||||||
|
init_once_maybe(inst);
|
||||||
|
tsd = p_talloc.request();
|
||||||
|
}
|
||||||
|
tsd->init(inst);
|
||||||
|
self->scudo_tsd = tsd;
|
||||||
|
inst->callPostInitCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pthread *get_self() {
|
||||||
|
struct pthread *p;
|
||||||
|
pthread_t s = __pthread_self();
|
||||||
|
memcpy(&p, &s, sizeof(struct pthread *));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p_init = false;
|
||||||
|
scudo::atomic_u8 p_disabled = {};
|
||||||
|
tsd_t *p_fallback = nullptr;
|
||||||
|
TSDAllocator<tsd_t> p_talloc;
|
||||||
|
scudo::HybridMutex p_mtx;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Origin = scudo::Chunk::Origin;
|
||||||
|
|
||||||
|
struct MuslConfig {
|
||||||
|
static const bool MaySupportMemoryTagging = true;
|
||||||
|
|
||||||
|
template<typename A>
|
||||||
|
using TSDRegistryT = TSDRegistry<A>;
|
||||||
|
|
||||||
|
/* we are not actually using primary64 at the moment, as primary32
|
||||||
|
* appears to have similar performance and memory usage even on
|
||||||
|
* 64-bit systems, while mapping far less virtual memory, which
|
||||||
|
* entirely eliminates our qemu performance issues besides other
|
||||||
|
* things; maybe reevaluate another time
|
||||||
|
*/
|
||||||
|
struct Primary {
|
||||||
|
/* use table-driven size classes, found to perform better */
|
||||||
|
using SizeClassMap = scudo::AndroidSizeClassMap;
|
||||||
|
|
||||||
|
#if 0 /*SCUDO_WORDSIZE == 64U*/
|
||||||
|
/* use pointer compacting like android, improves memory use */
|
||||||
|
using CompactPtrT = uint32_t;
|
||||||
|
|
||||||
|
/* too large values result in large mmaps (which will result in terrible
|
||||||
|
* performance in qemu-user, for example), too small values may result
|
||||||
|
* in size class exhaustion; for now use the same value as android
|
||||||
|
*/
|
||||||
|
static const uintptr_t RegionSizeLog = 28U;
|
||||||
|
static const uintptr_t GroupSizeLog = 20U;
|
||||||
|
static const uintptr_t CompactPtrScale = SCUDO_MIN_ALIGNMENT_LOG;
|
||||||
|
static const uintptr_t MapSizeIncrement = 1UL << 18;
|
||||||
|
static const bool EnableRandomOffset = true;
|
||||||
|
#else
|
||||||
|
using CompactPtrT = uintptr_t;
|
||||||
|
|
||||||
|
static const uintptr_t RegionSizeLog = FIRST_32_SECOND_64(18U, 20U);
|
||||||
|
static const uintptr_t GroupSizeLog = FIRST_32_SECOND_64(18U, 20U);
|
||||||
|
#endif
|
||||||
|
static const int32_t MinReleaseToOsIntervalMs = INT32_MIN;
|
||||||
|
static const int32_t MaxReleaseToOsIntervalMs = INT32_MAX;
|
||||||
|
};
|
||||||
|
#if 0 /*SCUDO_WORDSIZE == 64U*/
|
||||||
|
template<typename C> using PrimaryT = scudo::SizeClassAllocator64<C>;
|
||||||
|
#else
|
||||||
|
template<typename C> using PrimaryT = scudo::SizeClassAllocator32<C>;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MUSL_SCUDO_USE_SECONDARY_CACHE
|
||||||
|
struct Secondary {
|
||||||
|
struct Cache {
|
||||||
|
static const uint32_t EntriesArraySize = 32U;
|
||||||
|
static const uint32_t QuarantineSize = 0U;
|
||||||
|
static const uint32_t DefaultMaxEntriesCount = 32U;
|
||||||
|
static const uintptr_t DefaultMaxEntrySize = 1UL << 19;
|
||||||
|
static const int32_t MinReleaseToOsIntervalMs = INT32_MIN;
|
||||||
|
static const int32_t MaxReleaseToOsIntervalMs = INT32_MAX;
|
||||||
|
}
|
||||||
|
template<typename C> using CacheT = scudo::MapAllocatorCache<C>;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
struct Secondary {
|
||||||
|
template<typename C> using CacheT = scudo::MapAllocatorNoCache<C>;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
template<typename C> using SecondaryT = scudo::MapAllocator<C>;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
extern int __malloc_replaced;
|
||||||
|
extern int __aligned_alloc_replaced;
|
||||||
|
|
||||||
|
static void malloc_postinit();
|
||||||
|
|
||||||
|
static SCUDO_REQUIRE_CONSTANT_INITIALIZATION
|
||||||
|
scudo::Allocator<MuslConfig, malloc_postinit> o_alloc;
|
||||||
|
|
||||||
|
#define MALLOC_ALIGN FIRST_32_SECOND_64(8U, 16U)
|
||||||
|
|
||||||
|
static void malloc_postinit() {
|
||||||
|
o_alloc.initGwpAsan();
|
||||||
|
}
|
||||||
|
|
||||||
|
void __malloc_atfork(int who) {
|
||||||
|
if (who < 0) {
|
||||||
|
o_alloc.disable();
|
||||||
|
} else {
|
||||||
|
o_alloc.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __malloc_tsd_teardown(void *p) {
|
||||||
|
using T = scudo::TSD<decltype(o_alloc)>;
|
||||||
|
auto *tsdp = static_cast<T **>(p);
|
||||||
|
auto *tsd = *tsdp;
|
||||||
|
if (!tsd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*tsdp = nullptr;
|
||||||
|
o_alloc.getTSDRegistry()->dispose(&o_alloc, tsd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__libc_calloc(size_t m, size_t n) {
|
||||||
|
if (n && m > (((size_t)-1) / n)) {
|
||||||
|
if (o_alloc.canReturnNull()) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
scudo::reportCallocOverflow(m, n);
|
||||||
|
}
|
||||||
|
auto *ptr = o_alloc.allocate(n * m, Origin::Malloc, MALLOC_ALIGN, true);
|
||||||
|
if (UNLIKELY(!ptr)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __libc_free(void *ptr) {
|
||||||
|
o_alloc.deallocate(ptr, Origin::Malloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__libc_malloc_impl(size_t len) {
|
||||||
|
auto *ptr = o_alloc.allocate(len, Origin::Malloc, MALLOC_ALIGN);
|
||||||
|
if (UNLIKELY(!ptr)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__libc_realloc(void *ptr, size_t len) {
|
||||||
|
if (!ptr) {
|
||||||
|
auto *ptr = o_alloc.allocate(len, Origin::Malloc, MALLOC_ALIGN);
|
||||||
|
if (UNLIKELY(!ptr)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
if (len == 0) {
|
||||||
|
o_alloc.deallocate(ptr, Origin::Malloc);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
ptr = o_alloc.reallocate(ptr, len, MALLOC_ALIGN);
|
||||||
|
if (UNLIKELY(!ptr)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this has loose checking of align like memalign, but this matches musl's
|
||||||
|
* aligned_alloc, which is also used to implement memalign as well as
|
||||||
|
* posix_memalign and it allows for replacement of just aligned_alloc,
|
||||||
|
* so that is our baseline
|
||||||
|
*/
|
||||||
|
INTERFACE void *aligned_alloc(size_t align, size_t len) {
|
||||||
|
if (UNLIKELY(!scudo::isPowerOfTwo(align))) {
|
||||||
|
if (o_alloc.canReturnNull()) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
scudo::reportAlignmentNotPowerOfTwo(align);
|
||||||
|
}
|
||||||
|
if (UNLIKELY(__malloc_replaced && !__aligned_alloc_replaced)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto *ptr = o_alloc.allocate(len, Origin::Malloc, align);
|
||||||
|
if (UNLIKELY(!ptr)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERFACE size_t malloc_usable_size(void *p) {
|
||||||
|
return o_alloc.getUsableSize(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we have no way to implement this AFAICT */
|
||||||
|
void __malloc_donate(char *, char *) {}
|
||||||
|
|
||||||
|
} // extern "C"
|
|
@ -24,7 +24,6 @@ build() {
|
||||||
--with-manpage-format=normal
|
--with-manpage-format=normal
|
||||||
--with-pkg-config-libdir=/usr/lib/pkgconfig
|
--with-pkg-config-libdir=/usr/lib/pkgconfig
|
||||||
--with-shared
|
--with-shared
|
||||||
--with-versioned-syms
|
|
||||||
--with-xterm-kbs=del
|
--with-xterm-kbs=del
|
||||||
--without-ada
|
--without-ada
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,8 +15,8 @@ source=(
|
||||||
)
|
)
|
||||||
sha256sums=(
|
sha256sums=(
|
||||||
"7d8e3e8c5121aec0965df71f59bedf46052c6cf14f96365c4411ec3de0a4c1a5"
|
"7d8e3e8c5121aec0965df71f59bedf46052c6cf14f96365c4411ec3de0a4c1a5"
|
||||||
"a4137a05fbfa4017ce13cfda1fa361f188d3eb7c098e326c498edf458b7af24d"
|
"169638c79e0f53fbfce8e437deb61fe2139271b534b9d2c1d90c378fb02a0095"
|
||||||
"8f5bfb2f9bfbac6af151f1a41c9ce64d1065bd263ad998a80732e884f22a61d7"
|
"ca31972632118b7091698e353444e32b1594a465b8e768f90c5a5a1a1dee76c5"
|
||||||
)
|
)
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#-- The download utilities that makepkg should use to acquire sources
|
#-- The download utilities that makepkg should use to acquire sources
|
||||||
# Format: 'protocol::agent'
|
# Format: 'protocol::agent'
|
||||||
DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
|
DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
|
||||||
'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
||||||
'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||||
'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||||
'rsync::/usr/bin/rsync --no-motd -z %u %o'
|
'rsync::/usr/bin/rsync --no-motd -z %u %o'
|
||||||
'scp::/usr/bin/scp -C %u %o')
|
'scp::/usr/bin/scp -C %u %o')
|
||||||
|
|
||||||
# Other common tools:
|
# Other common tools:
|
||||||
# /usr/bin/snarf
|
# /usr/bin/snarf
|
||||||
|
@ -24,10 +24,10 @@ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
|
||||||
#-- The package required by makepkg to download VCS sources
|
#-- The package required by makepkg to download VCS sources
|
||||||
# Format: 'protocol::package'
|
# Format: 'protocol::package'
|
||||||
VCSCLIENTS=('bzr::breezy'
|
VCSCLIENTS=('bzr::breezy'
|
||||||
'fossil::fossil'
|
'fossil::fossil'
|
||||||
'git::git'
|
'git::git'
|
||||||
'hg::mercurial'
|
'hg::mercurial'
|
||||||
'svn::subversion')
|
'svn::subversion')
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
# ARCHITECTURE, COMPILE FLAGS
|
# ARCHITECTURE, COMPILE FLAGS
|
||||||
|
@ -38,11 +38,9 @@ CHOST="x86_64-pc-linux-musl"
|
||||||
|
|
||||||
#-- Compiler and Linker Flags
|
#-- Compiler and Linker Flags
|
||||||
#CPPFLAGS=""
|
#CPPFLAGS=""
|
||||||
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
|
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
|
||||||
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
|
CXXFLAGS="$CFLAGS"
|
||||||
-fstack-clash-protection -fcf-protection"
|
LDFLAGS=""
|
||||||
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
|
|
||||||
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
|
|
||||||
LTOFLAGS="-flto=auto"
|
LTOFLAGS="-flto=auto"
|
||||||
#RUSTFLAGS="-C opt-level=2"
|
#RUSTFLAGS="-C opt-level=2"
|
||||||
#-- Make Flags: change this for DistCC/SMP systems
|
#-- Make Flags: change this for DistCC/SMP systems
|
||||||
|
|
Loading…
Reference in a new issue