From 72db2abcc794feccfb482d4ae9e500c91c8bcb45 Mon Sep 17 00:00:00 2001 From: Hubert Tong Date: Wed, 13 Mar 2019 00:12:43 +0000 Subject: Use AIX version detection at LLVM run-time Summary: AIX compilers define macros based on the version of the operating system. This patch implements updating of versionless AIX triples to include the host AIX version. Also, the host triple detection in the build system is adjusted to strip the AIX version information so that the run-time detection is preferred. Reviewers: xingxue, stefanp, nemanjai, jasonliu Reviewed By: xingxue Subscribers: mgorny, kristina, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58798 llvm-svn: 355995 --- llvm/lib/Support/Unix/Host.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/Unix/Host.inc b/llvm/lib/Support/Unix/Host.inc index 4ae261aa8cf..17d78dc18be 100644 --- a/llvm/lib/Support/Unix/Host.inc +++ b/llvm/lib/Support/Unix/Host.inc @@ -49,6 +49,23 @@ static std::string updateTripleOSVersion(std::string TargetTripleString) { TargetTripleString += "-darwin"; TargetTripleString += getOSVersion(); } + // On AIX, the AIX version and release should be that of the current host + // unless if the version has already been specified. + if (Triple(LLVM_HOST_TRIPLE).getOS() == Triple::AIX) { + Triple TT(TargetTripleString); + if (TT.getOS() == Triple::AIX && !TT.getOSMajorVersion()) { + struct utsname name; + if (uname(&name) != -1) { + std::string NewOSName = Triple::getOSTypeName(Triple::AIX); + NewOSName += name.version; + NewOSName += '.'; + NewOSName += name.release; + NewOSName += ".0.0"; + TT.setOSName(NewOSName); + return TT.str(); + } + } + } return TargetTripleString; } -- cgit v1.2.3