diff options
author | Bob Wilson <bob.wilson@apple.com> | 2011-08-09 05:13:36 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2011-08-09 05:13:36 +0000 |
commit | de9ec45e5a4cfa78f4123c4c5188a8d3ac2b9e7a (patch) | |
tree | 4d58297dedd093f488dcc9dc60861452850dff95 /llvm/lib/Support/Unix | |
parent | 5c8daf1ee16bca6fe4f7616ea405a79c501652e2 (diff) | |
download | bcm5719-llvm-de9ec45e5a4cfa78f4123c4c5188a8d3ac2b9e7a.tar.gz bcm5719-llvm-de9ec45e5a4cfa78f4123c4c5188a8d3ac2b9e7a.zip |
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>
llvm-svn: 137111
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/Host.inc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Host.inc b/llvm/lib/Support/Unix/Host.inc index 5fd0e5e0790..0f3e31a41b9 100644 --- a/llvm/lib/Support/Unix/Host.inc +++ b/llvm/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 ""; |