[llvm] [Support] Reimplement getMainExecutable() using sysctl on NetBSD
authorMichal Gorny <mgorny@gentoo.org>
Sun, 3 Mar 2019 10:06:40 +0000 (10:06 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Sun, 3 Mar 2019 10:06:40 +0000 (10:06 +0000)
commit8f04766d133440bc5d6f8241395c44f0eb2b0b74
tree3bcec4055b831adabc2a3528ea3f708b4908fa37
parentd3516b51cae6f3ec38be2db718534f0446057b77
[llvm] [Support] Reimplement getMainExecutable() using sysctl on NetBSD

Use sysctl() to implement getMainExecutable() on NetBSD, rather than
trying to guess the correct path from argv[0].  This is one
of the fixes to recent clang-check-mac-libcxx-fixed-compilation-db.cpp
test failure on NetBSD.

This has been historically done on both FreeBSD and NetBSD in r303015,
and reverted in r303285 due to buggy implementation on FreeBSD.
However, FWIK the NetBSD implementation does not suffer from the same
bugs and is more reliable than playing with argv[0].

Differential Revision: https://reviews.llvm.org/D56975

llvm-svn: 355283
llvm/lib/Support/Unix/Path.inc