From 511cfbbc9d09e4755dee749770fdf16a94127fd5 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Tue, 25 Oct 2016 15:33:32 +0000 Subject: [PATCH] [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older Disable the OpenSUSE rules for OpenSUSE versions older than 11 as they are incompatible with the old binutils on that distribution. Differential Revision: https://reviews.llvm.org/D24954 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285076 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index f04c443a88..509f6d9535 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -3968,8 +3968,25 @@ static Distro DetectDistro(vfs::FileSystem &VFS) { .Default(UnknownDistro); } - if (VFS.exists("/etc/SuSE-release")) - return OpenSUSE; + File = VFS.getBufferForFile("/etc/SuSE-release"); + if (File) { + StringRef Data = File.get()->getBuffer(); + SmallVector Lines; + Data.split(Lines, "\n"); + for (const StringRef& Line : Lines) { + if (!Line.trim().startswith("VERSION")) + continue; + std::pair SplitLine = Line.split('='); + int Version; + // OpenSUSE/SLES 10 and older are not supported and not compatible + // with our rules, so just treat them as UnknownDistro. + if (!SplitLine.second.trim().getAsInteger(10, Version) && + Version > 10) + return OpenSUSE; + return UnknownDistro; + } + return UnknownDistro; + } if (VFS.exists("/etc/exherbo-release")) return Exherbo; -- 2.50.1