[all-commits] [llvm/llvm-project] 8f53e5: [libc] Add program_invocation(_short)_name and twe...

Pavel Labath via All-commits all-commits at lists.llvm.org
Tue Aug 4 00:04:29 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f53e523b92ccdc5074acc02c1c103149c20530a
      https://github.com/llvm/llvm-project/commit/8f53e523b92ccdc5074acc02c1c103149c20530a
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2026-08-04 (Tue, 04 Aug 2026)

  Changed paths:
    M libc/config/linux/aarch64/entrypoints.txt
    M libc/config/linux/riscv/entrypoints.txt
    M libc/config/linux/x86_64/entrypoints.txt
    M libc/include/errno.yaml
    M libc/src/err/CMakeLists.txt
    M libc/src/err/report.cpp
    M libc/src/errno/CMakeLists.txt
    A libc/src/errno/program_invocation_name.cpp
    A libc/src/errno/program_invocation_name.h
    A libc/src/errno/program_invocation_short_name.cpp
    A libc/src/errno/program_invocation_short_name.h
    M libc/startup/linux/CMakeLists.txt
    M libc/startup/linux/do_start.cpp
    M libc/test/integration/startup/linux/CMakeLists.txt
    A libc/test/integration/startup/linux/invocation_name_test.cpp
    M libc/test/src/err/CMakeLists.txt

  Log Message:
  -----------
  [libc] Add program_invocation(_short)_name and tweak err.h functions (#212448)

These GNU extensions hold the name of the program as invoked (argv[0])
and its short name (the basename after the last slash).

Both variables are initialized in the startup code. As with all of our
other variables, they are only available in full build mode.

The trickiest part of this patch are the error reporting functions from
<err.h>, which access this variable, and they are currently enabled in
overlay mode. To make them work, I add an #ifdef to select the right
version. I considered doing something more elaborate, like we have with
`errno`, but that seemed too heavy for a single occurrence.

I also drop the linux check in this function. The documentation says the
functions should print the "last component of the program name", which
"llvmlibc" is not. If someone wants to enable these functions on
non-linux, they can figure out what they want to print here and how.

Assisted by Gemini.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list