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

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 17 19:01:56 PDT 2024


petrhosek wrote:

> More general thought: Could we implement this mechanism through aliases instead: https://godbolt.org/z/E5oKj9hfe? I think that might make `__is_function_overriden` a bit more lean and avoid having to put the functions into a separate section. That probably also doesn't work everywhere, but that doesn't seem like a huge problem to me.

I looked into it and try to implement this approach in libc++, but then realized that this approach has a serious downside in that both the original function and the one that overrides it would be kept in the binary even though the original is only used for the address comparison. This may not be a big deal on other systems but it's a concern for baremetal uses where every byte matters and don't want to ship any dead code.

With the existing implementation, that is also the case, but if you use a custom linker script you can manually discard it although that would effectively disable `__is_function_overriden` same as this change does but is more involved. Using that approach would likely result in embedded developers cargo culting the same snippet into every linker script which I think is undesirable.

Therefore, I'd would like to merge this change as is. I can try to finish and upload the implementation based on aliases for ELF as a follow up PR, but for baremetal we always want to disable this regardless of the implementation.

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


More information about the libcxx-commits mailing list