[libc-commits] [libc] [libc] Add program_invocation(_short)_name and tweak err.h functions (PR #212448)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Mon Aug 3 07:42:17 PDT 2026
================
@@ -23,21 +23,23 @@
#include "src/__support/printf_core/printf_main.h"
#include "src/__support/printf_core/writer.h"
-#ifdef __linux__
+#ifdef LIBC_FULL_BUILD
----------------
labath wrote:
That would need a separate ifdef block for the `extern "C"` declaration (or `errno.h` inclusion), which doesn't make a good tradeoff IMO. It would make it possible to add more complex logic for getting the name, if some systems needed it, but I think that can be easily done at that point.
The non-glibc case can be handled by a `#define PROGRAM_INVOCATION_SHORT_NAME ""` as well, but I'm not particularly enthusiastic about "handling" it this way. These functions are documented to output "the last component of the program name". "" is probably *not* it. So, while it would make the code run, it wouldn't actually conform to the "spec". I think it's better to get a build error if trying to use this on an unsupported system, and then whoeever runs into that can come in and decide how they want to support it.
That said, this is getting slightly outside of the scope of this patch, so if you feel strongly about this, I can put that back.
https://github.com/llvm/llvm-project/pull/212448
More information about the libc-commits
mailing list