llvm::Triple::ArchType Arch = Triple.getArch();
std::string SysRoot = computeSysRoot(Args);
- // OpenSuse stores the linker with the compiler, add that to the search
- // path.
+ // Cross-compiling binutils and GCC installations (vanilla and OpenSuse at
+ // least) put various tools in a triple-prefixed directory off of the parent
+ // of the GCC installation. We use the GCC triple here to ensure that we end
+ // up with tools that support the same amount of cross compiling as the
+ // detected GCC installation. For example, if we find a GCC installation
+ // targeting x86_64, but it is a bi-arch GCC installation, it can also be
+ // used to target i386.
+ // FIXME: This seems unlikely to be Linux-specific.
ToolChain::path_list &PPaths = getProgramPaths();
PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
GCCInstallation.getTriple().str() + "/bin").str());
--- /dev/null
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
+// RUN: --target=i386-unknown-linux-gnu \
+// RUN: | FileCheck --check-prefix=CHECK-I386 %s
+// CHECK-I386: "-cc1" "-triple" "i386-unknown-linux-gnu"
+// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin/as"
+// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin/ld"
+//
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
+// RUN: --target=x86_64-unknown-linux-gnu \
+// RUN: | FileCheck --check-prefix=CHECK-X86-64 %s
+// CHECK-X86-64: "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin/as"
+// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin/ld"
+//
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
+// RUN: --target=x86_64-unknown-linux-gnu -m32 \
+// RUN: | FileCheck --check-prefix=CHECK-I386 %s
+//
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
+// RUN: --target=i386-unknown-linux-gnu -m64 \
+// RUN: | FileCheck --check-prefix=CHECK-X86-64 %s
+//
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/multilib_32bit_linux_tree/usr \
+// RUN: --target=i386-unknown-linux \
+// RUN: | FileCheck --check-prefix=CHECK-MULTI32-I386 %s
+// CHECK-MULTI32-I386: "-cc1" "-triple" "i386-unknown-linux"
+// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin/as"
+// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin/ld"
+//
+// RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
+// RUN: --gcc-toolchain=%S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --target=x86_64-unknown-linux \
+// RUN: | FileCheck --check-prefix=CHECK-MULTI64-X86-64 %s
+// CHECK-MULTI64-X86-64: "-cc1" "-triple" "x86_64-unknown-linux"
+// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin/as"
+// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin/ld"