summaryrefslogtreecommitdiff
path: root/lib/Support/Unix/Host.inc
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2011-08-09 05:13:36 +0000
committerBob Wilson <bob.wilson@apple.com>2011-08-09 05:13:36 +0000
commitf5b757642d8c51c559c17532d193a13d1f2e3cc0 (patch)
tree28af955361172a61ef2ef1b122906302a6358606 /lib/Support/Unix/Host.inc
parent70d0ca999c7a2ef07ea39d26d67b5df57e6e6496 (diff)
downloadllvm-f5b757642d8c51c559c17532d193a13d1f2e3cc0.tar.gz
llvm-f5b757642d8c51c559c17532d193a13d1f2e3cc0.tar.bz2
llvm-f5b757642d8c51c559c17532d193a13d1f2e3cc0.tar.xz
Recognize the UNAME_RELEASE environment variable to match Darwin's uname.
When this variable is set, "uname -r" will return its value instead of the real OS version. Make this affect LLVM's triple for consistency. <rdar://problem/9919167> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137111 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/Host.inc')
-rw-r--r--lib/Support/Unix/Host.inc6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/Unix/Host.inc b/lib/Support/Unix/Host.inc
index 5fd0e5e079..0f3e31a41b 100644
--- a/lib/Support/Unix/Host.inc
+++ b/lib/Support/Unix/Host.inc
@@ -22,12 +22,18 @@
#include <sys/utsname.h>
#include <cctype>
#include <string>
+#include <cstdlib> // ::getenv
using namespace llvm;
static std::string getOSVersion() {
struct utsname info;
+ // Recognize UNAME_RELEASE environment variable to match Darwin uname.
+ const char *UnameOverride = ::getenv("UNAME_RELEASE");
+ if (UnameOverride && UnameOverride[0] != '\0')
+ return UnameOverride;
+
if (uname(&info))
return "";