[PATCH] D144889: [C2x] Support <string.h> in freestanding
Ben Craig via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 27 14:12:31 PST 2023
bcraig added a comment.
> 1. A normal operating system target with a "hosted" libc.
> 2. A baremetal target with an "embedded" libc; basically a stripped down libc which only includes stuff that doesn't require an operating system. What exactly this includes varies; may include some form of "malloc", some "POSIX" APIs, semihosting, etc.
> 3. A baremetal target with no libc, using custom implementations for everything. This is what we conventionally referred to as "freestanding", and what -ffreestanding implements. The user provides memcpy/memmove/memset, and uses the compiler-provided "builtins" lib if neceessary, but nothing we would traditionally call "libc".
In my committee work, I'm targeting option 2. I think that's what should be considered when talking about freestanding in a standards context.
Option 3 is valuable and should continue to exist, but it is non-conforming pre-C23 and post-C23. The standards don't have any provision for requiring the user to implement mem* functions that the implementation chooses to invoke without the user ever spelling that function call (perhaps because they did `char buf[256] = {0}` though). Post-C23, it doesn't provide enough. The C library authors will likely need this mode to author the C library itself though. I'll suggest calling this mode something like "nodefaultlibs".
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144889/new/
https://reviews.llvm.org/D144889
More information about the cfe-commits
mailing list