[all-commits] [llvm/llvm-project] 8d4043: [libc][realpath] Follow symlinks (#212164)

Jackson Stogel via All-commits all-commits at lists.llvm.org
Wed Jul 29 11:07:25 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d404384dd842d43362732a11b233ee3d6ead023
      https://github.com/llvm/llvm-project/commit/8d404384dd842d43362732a11b233ee3d6ead023
  Author: Jackson Stogel <jtstogel at gmail.com>
  Date:   2026-07-29 (Wed, 29 Jul 2026)

  Changed paths:
    M libc/src/__support/CPP/CMakeLists.txt
    M libc/src/__support/CPP/string.h
    M libc/src/stdlib/linux/CMakeLists.txt
    M libc/src/stdlib/linux/realpath.cpp
    M libc/test/src/__support/CPP/string_test.cpp
    M libc/test/src/stdlib/CMakeLists.txt
    M libc/test/src/stdlib/realpath_test.cpp
    M utils/bazel/llvm-project-overlay/libc/BUILD.bazel

  Log Message:
  -----------
  [libc][realpath] Follow symlinks (#212164)

This commit updates realpath to call `readlinkat` on symlinks during
path resolution.

Some notes on implementation:
- `PendingPath` uses a `cpp::string` to store unprocessed path
components. This could be more efficient by using a `PATH_MAX` buffer
and storing the path at the end of the buffer, which would allow for
easy prepending. However, using a `cpp::string` avoids the pointer
arithmetic and memory management that would involve.
- This PR implements `cpp::string::replace` to avoid pointer arithmetic
inside `realpath`. This should hopefully not be too inefficient, since
`prepend` reuses space from processed path components there's enough
room, there certainly exist some bad inputs that would cause many
`memmove` operations.



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