Author: jroelofs Date: Thu May 4 19:18:27 2017 New Revision: 302207 URL: http://llvm.org/viewvc/llvm-project?rev=302207&view=rev Log: Document that Multilib flags must be actual flags
This is because -print-multi-lib depends on them being flags for correctness. Fixes a case of this in the arm-android multilib selection logic. Modified: cfe/trunk/include/clang/Driver/Multilib.h cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/test/Driver/android-ndk-standalone.cpp Modified: cfe/trunk/include/clang/Driver/Multilib.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=302207&r1=302206&r2=302207&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Multilib.h (original) +++ cfe/trunk/include/clang/Driver/Multilib.h Thu May 4 19:18:27 2017 @@ -70,7 +70,14 @@ public: /// All elements begin with either '+' or '-' const flags_list &flags() const { return Flags; } flags_list &flags() { return Flags; } + /// Add a flag to the flags list + /// \p Flag must be a flag accepted by the driver with its leading '-' removed, + /// and replaced with either: + /// '-' which contraindicates using this multilib with that flag + /// or: + /// '+' which promotes using this multilib in the presence of that flag + /// otherwise '-print-multi-lib' will not emit them correctly. Multilib &flag(StringRef F) { assert(F.front() == '+' || F.front() == '-'); Flags.push_back(F); Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=302207&r1=302206&r2=302207&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu May 4 19:18:27 2017 @@ -893,6 +893,8 @@ static bool isSoftFloatABI(const ArgList A->getValue() == StringRef("soft")); } +/// \p Flag must be a flag accepted by the driver with its leading '-' removed, +// otherwise '-print-multi-lib' will not emit them correctly. static void addMultilibFlag(bool Enabled, const char *const Flag, std::vector<std::string> &Flags) { if (Enabled) @@ -1437,17 +1439,17 @@ static void findAndroidArmMultilibs(cons // Find multilibs with subdirectories like armv7-a, thumb, armv7-a/thumb. FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS()); Multilib ArmV7Multilib = makeMultilib("/armv7-a") - .flag("+armv7") - .flag("-thumb"); + .flag("+march=armv7-a") + .flag("-mthumb"); Multilib ThumbMultilib = makeMultilib("/thumb") - .flag("-armv7") - .flag("+thumb"); + .flag("-march=armv7-a") + .flag("+mthumb"); Multilib ArmV7ThumbMultilib = makeMultilib("/armv7-a/thumb") - .flag("+armv7") - .flag("+thumb"); + .flag("+march=armv7-a") + .flag("+mthumb"); Multilib DefaultMultilib = makeMultilib("") - .flag("-armv7") - .flag("-thumb"); + .flag("-march=armv7-a") + .flag("-mthumb"); MultilibSet AndroidArmMultilibs = MultilibSet() .Either(ThumbMultilib, ArmV7Multilib, @@ -1465,8 +1467,8 @@ static void findAndroidArmMultilibs(cons bool IsArmV7Mode = (IsArmArch || IsThumbArch) && (llvm::ARM::parseArchVersion(Arch) == 7 || (IsArmArch && Arch == "" && IsV7SubArch)); - addMultilibFlag(IsArmV7Mode, "armv7", Flags); - addMultilibFlag(IsThumbMode, "thumb", Flags); + addMultilibFlag(IsArmV7Mode, "march=armv7-a", Flags); + addMultilibFlag(IsThumbMode, "mthumb", Flags); if (AndroidArmMultilibs.select(Flags, Result.SelectedMultilib)) Result.Multilibs = AndroidArmMultilibs; Modified: cfe/trunk/test/Driver/android-ndk-standalone.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-ndk-standalone.cpp?rev=302207&r1=302206&r2=302207&view=diff ============================================================================== --- cfe/trunk/test/Driver/android-ndk-standalone.cpp (original) +++ cfe/trunk/test/Driver/android-ndk-standalone.cpp Thu May 4 19:18:27 2017 @@ -172,6 +172,20 @@ // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a" // CHECK-ARMV7THUMB-NOT: "-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 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: -print-multi-lib \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-MULTILIBS %s + +// CHECK-ARM-MULTILIBS: thumb;@mthumb +// CHECK-ARM-MULTILIBS-NEXT: armv7-a;@march=armv7-a +// CHECK-ARM-MULTILIBS-NEXT: armv7-a/thumb;@march=armv7-a@mthumb +// CHECK-ARM-MULTILIBS-NEXT: .; + // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target armv7a-none-linux-androideabi -stdlib=libstdc++ \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits