[libcxx-commits] [libcxx] [libcxx] Option to disable overridden function detection (PR #108734)

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 16 10:58:51 PDT 2024


petrhosek wrote:

> > I'm iffy about adding an option just to disable that -- that feels like a hack. There might be a more general configuration option trying to emerge here. What do these linker scripts do that is special and breaks how this detection work?
> 
> Just my guess: Linker scripts usually define where the sections go explicitly. Since our section isn't part of one of the standard sections it's not picked the linker script wildcards it simply discards it.

That's precisely the reason. See for example the [Raspberry Pi Pico linker script in Pico SDK](https://github.com/raspberrypi/pico-sdk/blob/efe2103f9b28458a1615ff096054479743ade236/src/rp2_common/pico_crt0/rp2040/memmap_default.ld) which is one of the projects where this issue came up. Since the linker script doesn't place the `__lcxx_override` section explicitly, the linker places it arbitrarily. On this particular target, the section is placed somewhere that breaks assumptions the boot ROM makes about code locations (between `.boot2` and `.text`). Since `operator new` is in `__lcxx_override`, any call to `new` breaks the system.

I'd also point out that Pico SDK was using libc++ without any issues. They started reporting breakages after upgrading their toolchain to a version that included https://github.com/llvm/llvm-project/commit/314526557ec66ee627ae8a1c03f6ccc610668fdb. Whether intentional or not, for embedded users that change is a breaking change and I think we should have an opt-out mechanism because updating all affected linker scripts to take `__lcxx_override` into account will take some time.

https://github.com/llvm/llvm-project/pull/108734


More information about the libcxx-commits mailing list