]> granicus.if.org Git - clang/commitdiff
Reintroduce r148981 with significantly improved regression test. Now it
authorChandler Carruth <chandlerc@gmail.com>
Thu, 26 Jan 2012 01:35:15 +0000 (01:35 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 26 Jan 2012 01:35:15 +0000 (01:35 +0000)
both actually tests what it wants to, doesn't have bogus and broken
assertions in it, and is also formatted much more cleanly and
consistently. Probably still some more that can be improved here, but
its much better.

Original commit message:
----
Try to unbreak the FreeBSD toolchain's detection of 32-bit targets
inside a 64-bit freebsd machine with the 32-bit compatibility layer
installed. The FreeBSD image always has the /usr/lib32 directory, so
test for the more concrete existence of crt1.o. Also enhance the tests
for freebsd to clarify what these trees look like and exercise the new
code.

Thanks to all the FreeBSD folks for helping me understand what caused
the failure and how we might fix it. =] That helps a lot. Also, yay
build bots.

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

lib/Driver/ToolChains.cpp
test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o [new file with mode: 0644]
test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o [new file with mode: 0644]
test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep [new file with mode: 0644]
test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep [new file with mode: 0644]
test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep [new file with mode: 0644]
test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o [new file with mode: 0644]
test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep [new file with mode: 0644]
test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o [new file with mode: 0644]
test/Driver/freebsd.c

index 44f51e4c5d5ae1deba3b7a1ae61d765a9c65ecf9..c39d6243465b24f93fb325986b5a0b9f6bea5248 100644 (file)
@@ -1627,11 +1627,11 @@ Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA,
 FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
   : Generic_ELF(D, Triple) {
 
-  // When targeting 32-bit platforms, look for '/usr/lib32' first and fall back
-  // to '/usr/lib' for the remaining cases.
+  // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
+  // back to '/usr/lib' if it doesn't exist.
   if ((Triple.getArch() == llvm::Triple::x86 ||
        Triple.getArch() == llvm::Triple::ppc) &&
-      llvm::sys::fs::exists(getDriver().SysRoot + "/usr/lib32"))
+      llvm::sys::fs::exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
     getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
   else
     getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
diff --git a/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o b/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep b/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o
new file mode 100644 (file)
index 0000000..e69de29
index a25d6e0de423575c2fa591a82cbf38fb5bc7ef62..e0224647902bf13cc155cafd3067ac150f05d3ad 100644 (file)
@@ -1,20 +1,27 @@
-// RUN: %clang -no-canonical-prefixes --sysroot=%S/Inputs/basic_freebsd_tree -ccc-clang-archs "" -target powerpc64-pc-freebsd8 %s -### 2> %t
-// RUN: FileCheck --check-prefix=CHECK-PPC < %t %s
-//
-// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// RUN: %clang -no-canonical-prefixes -target powerpc-pc-freebsd8 %s \
+// RUN:   --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC %s
+// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc-pc-freebsd8"
 // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
-
-
-// Check that -m32 properly adjusts the toolchain flags.
 //
-// RUN: %clang -no-canonical-prefixes --sysroot=%S/Inputs/basic_freebsd64_tree -target x86_64-pc-freebsd8 -m32 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-LIB32 < %t %s
+// RUN: %clang -no-canonical-prefixes -target powerpc64-pc-freebsd8 %s \
+// RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
 //
+// Check that -m32 properly adjusts the toolchain flags.
+//
+// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
+// RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIB32 %s
 // CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8"
 // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
 //
-// RUN: %clang --sysroot=%S/Inputs/basic_freebsd64_tree -target x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t
-// RUN: FileCheck --check-prefix=CHECK-LIB32PATHS < %t %s
-//
+// RUN: %clang -target x86_64-pc-freebsd8 -m32 %s 2>&1 \
+// RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32