Index: include/clang/Driver/ToolChain.h =================================================================== --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -108,6 +108,10 @@ static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path); + static void + addSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + const Twine &Path); static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path); Index: lib/Driver/ToolChain.cpp =================================================================== --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -585,6 +585,14 @@ CC1Args.push_back(DriverArgs.MakeArgString(Path)); } +void ToolChain::addSystemIncludeIfExists(const ArgList &DriverArgs, + ArgStringList &CC1Args, + const Twine &Path) { + if (llvm::sys::fs::exists(Path)) + addSystemInclude(DriverArgs, CC1Args, Path); +} + + /// \brief Utility function to add a system include directory with extern "C" /// semantics to CC1 arguments. /// Index: lib/Driver/ToolChains.h =================================================================== --- lib/Driver/ToolChains.h +++ lib/Driver/ToolChains.h @@ -78,6 +78,7 @@ class GCCInstallationDetector { bool IsValid; llvm::Triple GCCTriple; + llvm::Triple TargetTriple; const Driver &D; // FIXME: These might be better as path objects. @@ -99,6 +100,9 @@ /// The set of multilibs that the detected installation supports. MultilibSet Multilibs; + /// Optional lib subdirectories for SubArchTypes. + SmallVector CandidateSubLibDirs; + public: explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, @@ -110,12 +114,18 @@ /// \brief Get the GCC triple for the detected install. const llvm::Triple &getTriple() const { return GCCTriple; } + /// \brief Get the GCC target triple for this compilation. + const llvm::Triple &getTargetTriple() const { return TargetTriple; } + /// \brief Get the detected GCC installation path. StringRef getInstallPath() const { return GCCInstallPath; } /// \brief Get the detected GCC parent lib path. StringRef getParentLibPath() const { return GCCParentLibPath; } + /// \brief Get the SubArchType subdirectories under lib. + const SmallVectorImpl &getSubLibs() { return CandidateSubLibDirs; } + /// \brief Get the detected Multilib const Multilib &getMultilib() const { return SelectedMultilib; } @@ -134,9 +144,16 @@ private: static void + CollectSubLibDirs(const llvm::Triple &Triple, + const llvm::opt::ArgList &Args, + SmallVectorImpl &SubLibDirs); + + static void CollectLibDirsAndTriples(const llvm::Triple &TargetTriple, const llvm::Triple &BiarchTriple, + const llvm::opt::ArgList &Args, SmallVectorImpl &LibDirs, + SmallVectorImpl &SubLibDirs, SmallVectorImpl &TripleAliases, SmallVectorImpl &BiarchLibDirs, SmallVectorImpl &BiarchTripleAliases); @@ -223,7 +240,13 @@ /// \brief Check whether the target triple's architecture is 32-bits. bool isTarget32Bit() const { return getTriple().isArch32Bit(); } + void addSystemIncludeWithSubArchDir(StringRef SubArchDir, + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Twine Path) const; + bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix, StringRef GCCTriple, + StringRef SubArchDir, StringRef GCCMultiarchTriple, StringRef TargetMultiarchTriple, Twine IncludeSuffix, @@ -815,6 +838,8 @@ void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + StringRef GetClangCXXStdlibSubArchIncludeDir( + const llvm::opt::ArgList &DriverArgs) const; void AddClangCXXStdlibIncludeArgs( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; Index: lib/Driver/ToolChains.cpp =================================================================== --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -1378,6 +1378,7 @@ void Generic_GCC::GCCInstallationDetector::init( const llvm::Triple &TargetTriple, const ArgList &Args, ArrayRef ExtraTripleAliases) { + this->TargetTriple = TargetTriple; llvm::Triple BiarchVariantTriple = TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant() : TargetTriple.get32BitArchVariant(); @@ -1386,7 +1387,8 @@ // The compatible GCC triples for this particular architecture. SmallVector CandidateTripleAliases; SmallVector CandidateBiarchTripleAliases; - CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs, + CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, Args, + CandidateLibDirs, CandidateSubLibDirs, CandidateTripleAliases, CandidateBiarchLibDirs, CandidateBiarchTripleAliases); @@ -1471,9 +1473,52 @@ return false; } +/*static*/ void Generic_GCC::GCCInstallationDetector::CollectSubLibDirs( + const llvm::Triple &Triple, const ArgList &Args, + SmallVectorImpl &SubLibDirs) { + // Recognize only thumb and armv7 types for now. + static const char *const ARMThumbLibDirs[] = {"/thumb"}; + static const char *const ARMV7aLibDirs[] = {"/armv7-a"}; + static const char *const ARMV7aThumbLibDirs[] = { + "/armv7-a/thumb", "/armv7-a"}; + using std::begin; + using std::end; + llvm::StringRef Arch = Args.getLastArgValue(options::OPT_march_EQ); + switch (Triple.getArch()) { + case llvm::Triple::thumb: + if (llvm::ARM::parseArchVersion(Arch) == 7) + SubLibDirs.append(begin(ARMV7aThumbLibDirs), end(ARMV7aThumbLibDirs)); + else + SubLibDirs.append(begin(ARMThumbLibDirs), end(ARMThumbLibDirs)); + break; + case llvm::Triple::arm: + { + bool Thumb = + Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, false) + || llvm::ARM::parseArchISA(Arch) == llvm::ARM::IK_THUMB; + if (llvm::ARM::parseArchVersion(Arch) == 7 || + (Triple.getSubArch() == llvm::Triple::ARMSubArch_v7 && Arch == "")) { + if (Thumb) + SubLibDirs.append(begin(ARMV7aThumbLibDirs), end(ARMV7aThumbLibDirs)); + else + SubLibDirs.append(begin(ARMV7aLibDirs), end(ARMV7aLibDirs)); + } else { + if (Thumb) + SubLibDirs.append(begin(ARMThumbLibDirs), end(ARMThumbLibDirs)); + } + } + break; + default: + break; + } +} + /*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples( - const llvm::Triple &TargetTriple, const llvm::Triple &BiarchTriple, + const llvm::Triple &TargetTriple, + const llvm::Triple &BiarchTriple, + const ArgList &Args, SmallVectorImpl &LibDirs, + SmallVectorImpl &SubLibDirs, SmallVectorImpl &TripleAliases, SmallVectorImpl &BiarchLibDirs, SmallVectorImpl &BiarchTripleAliases) { @@ -1587,6 +1632,7 @@ break; case llvm::Triple::arm: case llvm::Triple::thumb: + CollectSubLibDirs(TargetTriple, Args, SubLibDirs); LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); @@ -2543,9 +2589,19 @@ } } +/// \brief Helper to add system include path with subarch directory suffix. +void Generic_GCC::addSystemIncludeWithSubArchDir( + StringRef SubArchDir, const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, Twine Path) const { + if (SubArchDir != "") + addSystemIncludeIfExists(DriverArgs, CC1Args, Path + "/" + SubArchDir); + addSystemInclude(DriverArgs, CC1Args, Path); +} + /// \brief Helper to add the variant paths of a libstdc++ installation. bool Generic_GCC::addLibStdCXXIncludePaths( - Twine Base, Twine Suffix, StringRef GCCTriple, StringRef GCCMultiarchTriple, + Twine Base, Twine Suffix, StringRef GCCTriple, + StringRef SubArchDir, StringRef GCCMultiarchTriple, StringRef TargetMultiarchTriple, Twine IncludeSuffix, const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (!getVFS().exists(Base + Suffix)) @@ -2558,18 +2614,19 @@ // this vanilla search path. if ((GCCMultiarchTriple.empty() && TargetMultiarchTriple.empty()) || getVFS().exists(Base + Suffix + "/" + GCCTriple + IncludeSuffix)) { - addSystemInclude(DriverArgs, CC1Args, - Base + Suffix + "/" + GCCTriple + IncludeSuffix); + addSystemIncludeWithSubArchDir( + SubArchDir, DriverArgs, CC1Args, + Base + Suffix + "/" + GCCTriple + IncludeSuffix); } else { // Otherwise try to use multiarch naming schemes which have normalized the // triples and put the triple before the suffix. // // GCC surprisingly uses *both* the GCC triple with a multilib suffix and // the target triple, so we support that here. - addSystemInclude(DriverArgs, CC1Args, - Base + "/" + GCCMultiarchTriple + Suffix + IncludeSuffix); - addSystemInclude(DriverArgs, CC1Args, - Base + "/" + TargetMultiarchTriple + Suffix); + addSystemIncludeWithSubArchDir(SubArchDir, DriverArgs, CC1Args, + Base + "/" + GCCMultiarchTriple + Suffix + IncludeSuffix); + addSystemIncludeWithSubArchDir(SubArchDir, DriverArgs, CC1Args, + Base + "/" + TargetMultiarchTriple + Suffix); } addSystemInclude(DriverArgs, CC1Args, Base + Suffix + "/backward"); @@ -3464,6 +3521,14 @@ Paths.push_back(Path.str()); } +static void addPathIfExists(const Driver &D, const Twine &Path, + const SmallVectorImpl &SubDirs, + ToolChain::path_list &Paths) { + for (const auto &Suffix : SubDirs) + addPathIfExists(D, Path + Suffix, Paths); + addPathIfExists(D, Path, Paths); +} + /// Solaris - Solaris tool chain which can call as(1) and ld(1) directly. Solaris::Solaris(const Driver &D, const llvm::Triple &Triple, @@ -3898,7 +3963,7 @@ // Sourcery CodeBench MIPS toolchain holds some libraries under // a biarch-like suffix of the GCC installation. addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), - Paths); + GCCInstallation.getSubLibs(), Paths); // GCC cross compiling toolchains will install target libraries which ship // as part of the toolchain under // rather than as @@ -3920,7 +3985,7 @@ // Clang diverges from GCC's behavior. addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + OSLibDir + Multilib.osSuffix(), - Paths); + GCCInstallation.getSubLibs(), Paths); // If the GCC installation we found is inside of the sysroot, we want to // prefer libraries installed in the parent prefix of the GCC installation. @@ -4323,6 +4388,29 @@ return MaxVersion ? (base + "/" + MaxVersionString).str() : ""; } +StringRef Linux::GetClangCXXStdlibSubArchIncludeDir( + const ArgList &DriverArgs) const { + // Only recognize thumb, armv7-a and armv7-a/thumb for now. + const llvm::Triple &Triple = GCCInstallation.getTargetTriple(); + llvm::StringRef Arch = DriverArgs.getLastArgValue(options::OPT_march_EQ); + switch (Triple.getArch()) { + case llvm::Triple::thumb: + return (llvm::ARM::parseArchVersion(Arch) == 7) ? "armv7-a/thumb" : "thumb"; + case llvm::Triple::arm: + { + bool Thumb = DriverArgs.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, false) + || llvm::ARM::parseArchISA(Arch) == llvm::ARM::IK_THUMB; + if (llvm::ARM::parseArchVersion(Arch) == 7 || + (Triple.getSubArch() == llvm::Triple::ARMSubArch_v7 && Arch == "")) + return Thumb ? "armv7-a/thumb" : "armv7-a"; + else + return Thumb ? "thumb" : ""; + } + default: + return ""; + } +} + void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (DriverArgs.hasArg(options::OPT_nostdlibinc) || @@ -4359,6 +4447,7 @@ StringRef LibDir = GCCInstallation.getParentLibPath(); StringRef InstallDir = GCCInstallation.getInstallPath(); StringRef TripleStr = GCCInstallation.getTriple().str(); + StringRef SubArchDir = GetClangCXXStdlibSubArchIncludeDir(DriverArgs); const Multilib &Multilib = GCCInstallation.getMultilib(); const std::string GCCMultiarchTriple = getMultiarchTriple( getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot); @@ -4368,7 +4457,7 @@ // The primary search for libstdc++ supports multiarch variants. if (addLibStdCXXIncludePaths(LibDir.str() + "/../include", - "/c++/" + Version.Text, TripleStr, + "/c++/" + Version.Text, TripleStr, SubArchDir, GCCMultiarchTriple, TargetMultiarchTriple, Multilib.includeSuffix(), DriverArgs, CC1Args)) return; @@ -4391,6 +4480,7 @@ for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr, + /*SubArchDir*/ "", /*GCCMultiarchTriple*/ "", /*TargetMultiarchTriple*/ "", Multilib.includeSuffix(), DriverArgs, CC1Args)) @@ -4702,7 +4792,7 @@ addLibStdCXXIncludePaths( LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, - "", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); + "", TripleStr, "", "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); } // MyriadToolChain handles several triples: Index: test/Driver/android-ndk-standalone.cpp =================================================================== --- test/Driver/android-ndk-standalone.cpp +++ test/Driver/android-ndk-standalone.cpp @@ -0,0 +1,235 @@ +// Test header and library paths when Clang is used with Android standalone +// toolchain. +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck %s +// CHECK: {{.*}}clang{{.*}}" "-cc1" +// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb" +// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a" +// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb" +// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi" +// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include" +// CHECK: "-internal-isystem" "{{.*}}/lib/clang/{{[^/]*}}/include" +// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb" +// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a" +// CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb" +// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/arm-linux-androideabi/lib" +// CHECK: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target armv7a-none-linux-androideabi -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7 %s +// CHECK-ARMV7: {{.*}}clang{{.*}}" "-cc1" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a" +// CHECK-ARMV7-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/sysroot/usr/local/include" +// CHECK-ARMV7: "-internal-isystem" "{{.*}}/lib/clang/{{[^/]*}}/include" +// CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-ARMV7: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ARMV7: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a" +// CHECK-ARMV7: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9" +// CHECK-ARMV7: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a" +// CHECK-ARMV7-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb" +// CHECK-ARMV7: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib" +// CHECK-ARMV7: "-L{{.*}}/sysroot/usr/lib" +// +// Other flags that can trigger armv7 mode. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -march=armv7 \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7 %s +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -march=armv7a \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7 %s +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -march=armv7-a \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7 %s +// +// ARM thumb mode. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-THUMB %s +// CHECK-THUMB: {{.*}}clang{{.*}}" "-cc1" +// CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-THUMB-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7 +// CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb" +// CHECK-THUMB-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7 +// CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi" +// CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include" +// CHECK-THUMB: "-internal-isystem" "{{.*}}/lib/clang/{{[^/]*}}/include" +// CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb" +// CHECK-THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9" +// CHECK-THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7 +// CHECK-THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb" +// CHECK-THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7 +// CHECK-THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib" +// CHECK-THUMB: "-L{{.*}}/sysroot/usr/lib" +// +// ARM V7 thumb mode. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \ +// RUN: -march=armv7-a -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7THUMB %s +// CHECK-ARMV7THUMB: {{.*}}clang{{.*}}" "-cc1" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-ARMV7THUMB-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb" +// CHECK-ARMV7THUMB-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include" +// CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/lib/clang/{{[^/]*}}/include" +// CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-ARMV7THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a" +// CHECK-ARMV7THUMB: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib" +// CHECK-ARMV7THUMB: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target armv7a-none-linux-androideabi -stdlib=libstdc++ \ +// RUN: -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARMV7THUMB %s +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target aarch64-linux-android -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-AARCH64 %s +// CHECK-AARCH64: {{.*}}clang{{.*}}" "-cc1" +// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9/aarch64-linux-android" +// CHECK-AARCH64: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-AARCH64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-AARCH64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9" +// CHECK-AARCH64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/lib" +// CHECK-AARCH64: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm64-linux-android -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ARM64 %s +// CHECK-ARM64: {{.*}}clang{{.*}}" "-cc1" +// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9/aarch64-linux-android" +// CHECK-ARM64: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-ARM64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ARM64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9" +// CHECK-ARM64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/lib" +// CHECK-ARM64: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mipsel-linux-android \ +// RUN: -mips32 -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS %s +// CHECK-MIPS: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MIPS: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-MIPS: "-internal-isystem" "{{.*}}/include/c++/4.9/mipsel-linux-android" +// CHECK-MIPS: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-MIPS: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-MIPS: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-MIPS: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-MIPS: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9" +// CHECK-MIPS: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9/../../../../mipsel-linux-android/lib" +// CHECK-MIPS: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mipsel-linux-android \ +// RUN: -march=mips32 -mips32r2 -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSR2 %s +// CHECK-MIPSR2: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MIPSR2: "-internal-isystem" "{{.*}}/include/c++/4.9" +// NOT-YET-CHECK-MIPSR2: "-internal-isystem" "{{.*}}/include/c++/4.9/mipsel-linux-android/mips-r2" +// CHECK-MIPSR2: "-internal-isystem" "{{.*}}/include/c++/4.9/mipsel-linux-android" +// CHECK-MIPSR2: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-MIPSR2: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-MIPSR2: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-MIPSR2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-MIPSR2: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9/mips-r2" +// CHECK-MIPSR2: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9/../../../../mipsel-linux-android/lib" +// CHECK-MIPSR2: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mipsel-linux-android \ +// RUN: -mips32r6 -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-MIPSR6 %s +// CHECK-MIPSR6: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MIPSR6: "-internal-isystem" "{{.*}}/include/c++/4.9" +// NOT-YET-CHECK-MIPSR6: "-internal-isystem" "{{.*}}/include/c++/4.9/mipsel-linux-android/mips-r6" +// CHECK-MIPSR6: "-internal-isystem" "{{.*}}/include/c++/4.9/mipsel-linux-android" +// CHECK-MIPSR6: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-MIPSR6: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-MIPSR6: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-MIPSR6: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-MIPSR6: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9/mips-r6" +// CHECK-MIPSR6: "-L{{.*}}/lib/gcc/mipsel-linux-android/4.9/../../../../mipsel-linux-android/lib" +// CHECK-MIPSR6: "-L{{.*}}/sysroot/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i686-linux-android \ +// RUN: -stdlib=libstdc++ \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-I686 %s +// CHECK-I686: {{.*}}clang{{.*}}" "-cc1" +// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9" +// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9/i686-linux-android" +// CHECK-I686: "-internal-isystem" "{{.*}}/include/c++/4.9/backward" +// CHECK-I686: "-internal-externc-isystem" "{{.*}}/sysroot/include" +// CHECK-I686: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include" +// CHECK-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-I686: "-L{{.*}}/lib/gcc/i686-linux-android/4.9" +// CHECK-I686: "-L{{.*}}/lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/lib" +// CHECK-I686: "-L{{.*}}/sysroot/usr/lib"