Recognize the UNAME_RELEASE environment variable to match Darwin's uname.
authorBob Wilson <bob.wilson@apple.com>
Tue, 9 Aug 2011 05:13:36 +0000 (05:13 +0000)
committerBob Wilson <bob.wilson@apple.com>
Tue, 9 Aug 2011 05:13:36 +0000 (05:13 +0000)
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

lib/Support/Unix/Host.inc

index 5fd0e5e0790b2745fec51c35ab060c0f83bb673f..0f3e31a41b92acd3b5f0e5496fbfad07c532b21d 100644 (file)
 #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 "";