From 537f3d3a7588d226b86590f97c4401107585e1ce Mon Sep 17 00:00:00 2001
From: Jakob Koschel <jakobkoschel@google.com>
Date: Thu, 5 Mar 2026 01:11:44 +0100
Subject: [PATCH] [SafeStack] Fix crashing with scalable TypeSizes (#180547)
On e.g. aarch64 the TypeSize of scalar types can have a size that is not
known at compile time.
Currently when safestack occurs those it simply crashes as described in
https://github.com/llvm/llvm-project/issues/175868.
in clang brought in with the llvm 22 update:
commit 5d0e26e571c08dc4c0b2a25ed6c9f845f054fa76
Author: Koakuma <koachan@protonmail.com>
Date: Tue Apr 29 07:36:32 2025 +0700
[compiler-rt] Make sure __clzdi2 doesn't call itself recursively on sparc64 (#136737)
On 64-bit platforms, libgcc doesn't ship with __clzsi2, so __builtin_clz
gets lowered to __clzdi2. A check already exists for GCC, but as of
commit 8210ca019839fc5430b3a95d7caf5c829df3232a clang also lowers
__builtin_clz to __clzdi2 on sparc64.
Update the check so that building __clzdi2 with clang/sparc64 also
works.
ok tb@, deraadt@
For RETGUARD_LOAD_COOKIE when -fno-pie (as in macppc kernels), change
a relocation in -fno-pie (as in macppc kernels) from unusual S_HIGHA
"__retguard_3671@higha" to usual S_HA "__retguard_3671@ha". This
prevents an error from lld 22,
ld: error: rasops15.o:(function rasops15_init: .text+0x2): unknown \
relocation (111) against symbol __retguard_3671
For RETGUARD_LOAD_PC in PIC code, change an instruction from 'bl .+4'
to 'bcl 20,31,.+4' to fix branch prediction. This follows the same
change in upstream llvm,
https://github.com/llvm/llvm-project/issues/128644
ok jca@ naddy@
Adding -DEBUGGING in CONFIGURE_ARGS activates debug code,
-DEBUGGING=-g passes -g in CFLAGS (only -g is supported),
and -DEBUGGING=both does... both. This is a bit confusing.
IMO DEBUG=-g should only add -g and disable executable stripping, but
not change the code that is built. So use -Doptimize which lets us pass
arbitrary compiler flags (eg -g3), just like DEBUG does in our system
Makefiles.
Hints and ok afresh1@
mktemp(3) type operations, unveil "/" "r" for reading all over the tree,
and pledge "stdio rpath wpath cpath" to permit both unveils subject to
their own limitations.
Upstream libc++ renamed these macros in the following commit:
https://github.com/llvm/llvm-project/commit/d423d80
We had the correct names in the libcxx* makefiles, so no ABI changes are
required.
Reported by c2qd and also provided the __config_site diff. OK robert@
This is documented upstream https://github.com/perl/perl5/issues/23405
A simple trigger is
perl -c -wE 'for my ($x, $y) (Bar->foo) {}'
Suggested by James Cook <falsifian () falsifian ! org>
Tested and OK gkoehler@
we had to add special handling for the __string directory because CVS
cannot handle file to directory transitions so we had to move this
directory to __string.d and copy files over at install time, however
when libcxx19 was imported this directory was actually commited, making
rendering the handling of the special directory obsolete, but it was kept
there and it was installing files to the wrong directory
Reintroduce a tweaked version of the IP-based caching implementation.
Implementing a custom "new" operator has the two following desirable
properties:
- make the code more standalone, not depending on "new" from libcxx.
- teach this allocator to return nullptr on memory shortage ("noexcept")
so it can fail gracefully. If we can't allocate an item, we just don't
cache it.
That should be more resilient to memory shortages and thus more usable
from libexecinfo.
ok rsadowski@ robert@
I've been overzealous when backing out some unrelated changes.
Re-apply requested by robert@
-------------------
Linux still doesn't actually implement IBT for userland. And by the pace
things are going, it will take another decade before it does. But OpenBSD
has it enabled *by default* already.
Drop the #ifdef __linux__. This should hurt other OSes when they finally
catch up with us.
ok robert@, tb@
-------------------
Linux still doesn't actually implement IBT for userland. And by the pace
things are going, it will take another decade before it does. But OpenBSD
has it enabled *by default* already.
Drop the #ifdef __linux__. This should hurt other OSes when they finally
catch up with us.
ok robert@, tb@
-------------------
Initial IP-based caching implementation with O(logn) lookup.
Caching implemented via red-black trees, this can be improved and
further work is on-going to bring it closer to GNU's performance that
uses a LRU-MRU 8-entries based caching algorithm.
Prompted by robert@ who run into a runtime of an executed macro of
5 minutes in libreoffice. With this the execution is reduced to 58 seconds.
C++11 tips from espie@, rsadowski@
Tested by robert@
OK mortimer@, kettenis@.
--------------------
Make the unwind cache tread-safe by declaring it thread_local. Solves
segfaults seen on exception handling. ok kettenis@
--------------------