[PATCH] D45167: Use sys::fs::real_path() instead of realpath() in Symbolize and remove HAVE_REALPATH.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 2 08:47:29 PDT 2018


thakis created this revision.
thakis added a reviewer: samsonov.
Herald added a subscriber: mgorny.

No intended behavior change.


https://reviews.llvm.org/D45167

Files:
  cmake/config-ix.cmake
  include/llvm/Config/config.h.cmake
  lib/DebugInfo/Symbolize/Symbolize.cpp


Index: lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- lib/DebugInfo/Symbolize/Symbolize.cpp
+++ lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -169,13 +169,9 @@
 bool findDebugBinary(const std::string &OrigPath,
                      const std::string &DebuglinkName, uint32_t CRCHash,
                      std::string &Result) {
-  std::string OrigRealPath = OrigPath;
-#if defined(HAVE_REALPATH)
-  if (char *RP = realpath(OrigPath.c_str(), nullptr)) {
-    OrigRealPath = RP;
-    free(RP);
-  }
-#endif
+  SmallString<256> OrigRealPath;
+  if (sys::fs::real_path(OrigPath, OrigRealPath))
+    OrigRealPath = OrigPath;
   SmallString<16> OrigDir(OrigRealPath);
   llvm::sys::path::remove_filename(OrigDir);
   SmallString<16> DebugPath = OrigDir;
Index: include/llvm/Config/config.h.cmake
===================================================================
--- include/llvm/Config/config.h.cmake
+++ include/llvm/Config/config.h.cmake
@@ -161,9 +161,6 @@
 /* Have pthread_rwlock_init */
 #cmakedefine HAVE_PTHREAD_RWLOCK_INIT ${HAVE_PTHREAD_RWLOCK_INIT}
 
-/* Define to 1 if you have the `realpath' function. */
-#cmakedefine HAVE_REALPATH ${HAVE_REALPATH}
-
 /* Define to 1 if you have the `sbrk' function. */
 #cmakedefine HAVE_SBRK ${HAVE_SBRK}
 
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -207,7 +207,6 @@
 check_symbol_exists(getrlimit "sys/types.h;sys/time.h;sys/resource.h" HAVE_GETRLIMIT)
 check_symbol_exists(posix_spawn spawn.h HAVE_POSIX_SPAWN)
 check_symbol_exists(pread unistd.h HAVE_PREAD)
-check_symbol_exists(realpath stdlib.h HAVE_REALPATH)
 check_symbol_exists(sbrk unistd.h HAVE_SBRK)
 check_symbol_exists(strerror string.h HAVE_STRERROR)
 check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45167.140632.patch
Type: text/x-patch
Size: 1886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180402/160efdb2/attachment.bin>


More information about the llvm-commits mailing list