]> granicus.if.org Git - clang/commitdiff
Teach Clang to cope with GCC installations that have unusual patch
authorChandler Carruth <chandlerc@gmail.com>
Wed, 5 Oct 2011 03:09:51 +0000 (03:09 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 5 Oct 2011 03:09:51 +0000 (03:09 +0000)
"versions". Currently, these are just dropped on the floor, A concrete
version number will always win out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141159 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o [new file with mode: 0644]
test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o [new file with mode: 0644]
test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o [new file with mode: 0644]
test/Driver/linux-ld.c

index 33b1916d6a59a477a8b3b0ffabf2c9795b389e6b..0e9dcd14dccdbe9ecf3f3e1b4eb4f14cac3be70f 100644 (file)
@@ -1508,9 +1508,11 @@ class GCCInstallationDetector {
         return BadVersion;
       if (Second.first.getAsInteger(10, GoodVersion.Minor))
         return BadVersion;
-      if (!Second.first.empty())
-        if (Second.first.getAsInteger(10, GoodVersion.Patch))
-          return BadVersion;
+      // We accept a number, or a string for the patch version, in case there
+      // is a strang suffix, or other mangling: '4.1.x', '4.1.2-rc3'. When it
+      // isn't a number, we just use '0' as the number but accept it.
+      if (Second.first.getAsInteger(10, GoodVersion.Patch))
+        GoodVersion.Patch = 0;
       return GoodVersion;
     }
 
diff --git a/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o b/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o b/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o b/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o
new file mode 100644 (file)
index 0000000..e69de29
index cd89c798097d32fc0ac665d69a20b48c92842423..a9671830bbee5c19f4d3a36f5a81351cc54001cc 100644 (file)
 // CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
 // CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+//
+// Check that we support unusual patch version formats, including missing that
+// component.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -ccc-host-triple i386-unknown-linux -m32 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing1 \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s
+// CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
+// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -ccc-host-triple i386-unknown-linux -m32 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing2 \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s
+// CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
+// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -ccc-host-triple i386-unknown-linux -m32 \
+// RUN:     -ccc-install-dir %S/Inputs/gcc_version_parsing3 \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s
+// CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
+// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5"