1 //===- llvm/Support/Unix/Host.inc -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the UNIX Host support.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 //=== WARNING: Implementation here must contain only generic UNIX code that
16 //=== is guaranteed to work on *all* UNIX variants.
17 //===----------------------------------------------------------------------===//
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Config/config.h"
24 #include <sys/utsname.h>
28 static std::string getOSVersion() {
37 std::string sys::getDefaultTargetTriple() {
38 std::string TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE);
40 // On darwin, we want to update the version to match that of the
42 std::string::size_type DarwinDashIdx = TargetTripleString.find("-darwin");
43 if (DarwinDashIdx != std::string::npos) {
44 TargetTripleString.resize(DarwinDashIdx + strlen("-darwin"));
45 TargetTripleString += getOSVersion();
48 return Triple::normalize(TargetTripleString);