[llvm] [Support] Revert "Reimplement getMainExecutable() using sysctl on NetBSD"

This apparently does not work reliably after all (non-reentrant?)
and causes test failures such as:

http://lab.llvm.org:8011/builders/netbsd-amd64/builds/19254/steps/run%20unit%20tests/logs/FAIL%3A%20libc%2B%2B%3A%3Asize.pass.cpp

llvm-svn: 355302
This commit is contained in:
Michal Gorny 2019-03-04 04:53:50 +00:00
parent 85cfb00565
commit 9b56e2e249

View File

@ -90,11 +90,6 @@
#define STATVFS_F_FLAG(vfs) (vfs).f_flags
#endif
#if defined(__NetBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
using namespace llvm;
namespace llvm {
@ -103,7 +98,7 @@ namespace fs {
const file_t kInvalidFile = -1;
#if defined(__FreeBSD__) || defined(__OpenBSD__) || \
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) || \
defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || defined(__GNU__)
static int
@ -174,18 +169,7 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
if (realpath(exe_path, link_path))
return link_path;
}
#elif defined(__NetBSD__)
// NB: sysctl() solution can't be used on FreeBSD since it may return
// a wrong path when a file is hardlinked in multiple locations.
// See r303285 for an earlier revert.
char exe_path[PATH_MAX];
int mib[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME};
size_t len = sizeof(exe_path);
if (sysctl(mib, 4, exe_path, &len, nullptr, 0) == 0)
return exe_path;
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || \
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__minix) || defined(__DragonFly__) || \
defined(__FreeBSD_kernel__) || defined(_AIX)
char exe_path[PATH_MAX];