[libcxx-commits] [libcxx] [libc++][hardening] Add an experimental function to log hardening errors (PR #149452)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 24 18:12:50 PDT 2025
zeroomega wrote:
> > I am not very familiar with libcxx but simple mitigation would be just avoiding building this file when the target triple is a baremetal target like armv6m-none-eabi, riscv32-unknown-elf.
>
> Libc++ cannot properly build in an environment that doesn't provide a reasonably complete C library, not without a lot of workarounds. I need to understand how this issue is currently mitigated in other places where it should show up, such as for `verbose_abort.cpp`. Can you point me to the relevant build files? I don't think omitting this file from the build would work because we'll likely end up with a linker error instead.
I dig into how we build the baremetal targets and found out the mitigation in https://github.com/llvm/llvm-project/blob/51994891e3a28a999e30a915d9ac5c2102073576/clang/cmake/caches/Fuchsia-stage2.cmake#L343 . I don't have much context information on how that was decided. But I guess the issue is that we build those baremetal targets using llvm-libc. And due to obvious reasons that microcontroller baremetal targets don't have FILE support at all, any C functions that accept a FILE type parameters do not exist. The workaround basically replaces those to the non FILE functions, which redirect output to default hardware serial interface. I am testing a patch to replace fputs to puts with the same method to see if it clears the build error.
https://github.com/llvm/llvm-project/pull/149452
More information about the libcxx-commits
mailing list