llvm.org GIT mirror llvm / 2ea701e
Canonicalise Windows target triple spellings Construct a uniform Windows target triple nomenclature which is congruent to the Linux counterpart. The old triples are normalised to the new canonical form. This cleans up the long-standing issue of odd naming for various Windows environments. There are four different environments on Windows: MSVC: The MS ABI, MSVCRT environment as defined by Microsoft GNU: The MinGW32/MinGW32-W64 environment which uses MSVCRT and auxiliary libraries Itanium: The MSVCRT environment + libc++ built with Itanium ABI Cygnus: The Cygwin environment which uses custom libraries for everything The following spellings are now written as: i686-pc-win32 => i686-pc-windows-msvc i686-pc-mingw32 => i686-pc-windows-gnu i686-pc-cygwin => i686-pc-windows-cygnus This should be sufficiently flexible to allow us to target other windows environments in the future as necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204977 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
7 changed file(s) with 94 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
124124 EABI,
125125 EABIHF,
126126 Android,
127
128 MSVC,
129 Itanium,
130 Cygnus,
127131 };
128132 enum ObjectFormatType {
129133 UnknownObjectFormat,
327331 return isMacOSX() || isiOS();
328332 }
329333
334 bool isWindowsMSVCEnvironment() const {
335 return getOS() == Triple::Win32 &&
336 (getEnvironment() == Triple::UnknownEnvironment ||
337 getEnvironment() == Triple::MSVC);
338 }
339
340 bool isKnownWindowsMSVCEnvironment() const {
341 return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
342 }
343
344 bool isWindowsCygwinEnvironment() const {
345 return getOS() == Triple::Cygwin ||
346 (getOS() == Triple::Win32 && getEnvironment() == Triple::Cygnus);
347 }
348
349 bool isWindowsGNUEnvironment() const {
350 return getOS() == Triple::MinGW32 ||
351 (getOS() == Triple::Win32 && getEnvironment() == Triple::GNU);
352 }
353
330354 /// \brief Tests for either Cygwin or MinGW OS
331355 bool isOSCygMing() const {
332 return getOS() == Triple::Cygwin || getOS() == Triple::MinGW32;
356 return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
333357 }
334358
335359 /// \brief Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
222222 }
223223
224224 if (MAI->doesSupportDebugInformation()) {
225 if (Triple(TM.getTargetTriple()).getOS() == Triple::Win32) {
225 if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) {
226226 Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this),
227227 DbgTimerName,
228228 CodeViewLineTablesGroupName));
565565 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
566566 COFF::IMAGE_SCN_MEM_READ,
567567 SectionKind::getReadOnly());
568 if (T.getOS() == Triple::Win32) {
568 if (T.isKnownWindowsMSVCEnvironment()) {
569569 StaticCtorSection =
570570 Ctx->getCOFFSection(".CRT$XCU",
571571 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
581581 }
582582
583583
584 if (T.getOS() == Triple::Win32) {
584 if (T.isKnownWindowsMSVCEnvironment()) {
585585 StaticDtorSection =
586586 Ctx->getCOFFSection(".CRT$XTX",
587587 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
128128 case NetBSD: return "netbsd";
129129 case OpenBSD: return "openbsd";
130130 case Solaris: return "solaris";
131 case Win32: return "win32";
131 case Win32: return "windows";
132132 case Haiku: return "haiku";
133133 case Minix: return "minix";
134134 case RTEMS: return "rtems";
154154 case EABI: return "eabi";
155155 case EABIHF: return "eabihf";
156156 case Android: return "android";
157 case MSVC: return "msvc";
158 case Itanium: return "itanium";
159 case Cygnus: return "cygnus";
157160 }
158161
159162 llvm_unreachable("Invalid EnvironmentType!");
286289 .StartsWith("openbsd", Triple::OpenBSD)
287290 .StartsWith("solaris", Triple::Solaris)
288291 .StartsWith("win32", Triple::Win32)
292 .StartsWith("windows", Triple::Win32)
289293 .StartsWith("haiku", Triple::Haiku)
290294 .StartsWith("minix", Triple::Minix)
291295 .StartsWith("rtems", Triple::RTEMS)
308312 .StartsWith("code16", Triple::CODE16)
309313 .StartsWith("gnu", Triple::GNU)
310314 .StartsWith("android", Triple::Android)
315 .StartsWith("msvc", Triple::MSVC)
316 .StartsWith("itanium", Triple::Itanium)
317 .StartsWith("cygnus", Triple::Cygnus)
311318 .Default(Triple::UnknownEnvironment);
312319 }
313320
515522 // Special case logic goes here. At this point Arch, Vendor and OS have the
516523 // correct values for the computed components.
517524
525 if (OS == Triple::Win32) {
526 Components.resize(4);
527 Components[2] = "windows";
528 if (Environment == UnknownEnvironment && ObjectFormat == UnknownObjectFormat)
529 Components[3] = "msvc";
530 } else if (OS == Triple::MinGW32) {
531 Components.resize(4);
532 Components[2] = "windows";
533 Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
534 } else if (OS == Triple::Cygwin) {
535 Components.resize(4);
536 Components[2] = "windows";
537 Components[3] = "cygnus";
538 }
539
518540 // Stick the corrected components back together to form the normalized string.
519541 std::string Normalized;
520542 for (unsigned i = 0, e = Components.size(); i != e; ++i) {
416416 TLI.setUnavailable(LibFunc::fiprintf);
417417 }
418418
419 if (T.getOS() == Triple::Win32) {
419 if (T.isKnownWindowsMSVCEnvironment()) {
420420 // Win32 does not support long double
421421 TLI.setUnavailable(LibFunc::acosl);
422422 TLI.setUnavailable(LibFunc::asinl);
342342 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
343343 bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
344344 bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
345 bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
346 bool isTargetMingw() const { return TargetTriple.getOS() == Triple::MinGW32; }
347 bool isTargetCygwin() const { return TargetTriple.getOS() == Triple::Cygwin; }
345 bool isTargetWindows() const {
346 return TargetTriple.isOSWindows() &&
347 !TargetTriple.isWindowsGNUEnvironment();
348 }
349 bool isTargetMingw() const { return TargetTriple.isWindowsGNUEnvironment(); }
350 bool isTargetCygwin() const {
351 return TargetTriple.isWindowsCygwinEnvironment();
352 }
348353 bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); }
349354
350355 bool isOSWindows() const { return TargetTriple.isOSWindows(); }
189189 ++Vendor) {
190190 C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
191191 for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) {
192 if (OS == Triple::Cygwin || OS == Triple::MinGW32 || OS == Triple::Win32)
193 continue;
194
192195 C[2] = Triple::getOSTypeName(Triple::OSType(OS));
193196
194197 std::string E = Join(C[0], C[1], C[2]);
237240
238241 // Various real-world funky triples. The value returned by GCC's config.sub
239242 // is given in the comment.
240 EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
243 EXPECT_EQ("i386--windows-gnu", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
241244 EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
242245 EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
243246 EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
514517 EXPECT_EQ(Triple::ELF, T.getObjectFormat());
515518 }
516519
517 }
520 TEST(TripleTest, NormalizeWindows) {
521 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-win32"));
522 EXPECT_EQ("i686--windows-msvc", Triple::normalize("i686-win32"));
523 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32"));
524 EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32"));
525 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-mingw32-w64"));
526 EXPECT_EQ("i686--windows-gnu", Triple::normalize("i686-mingw32-w64"));
527 EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin"));
528 EXPECT_EQ("i686--windows-cygnus", Triple::normalize("i686-cygwin"));
529
530 EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32"));
531 EXPECT_EQ("x86_64--windows-msvc", Triple::normalize("x86_64-win32"));
532 EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32"));
533 EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32"));
534 EXPECT_EQ("x86_64-pc-windows-gnu", Triple::normalize("x86_64-pc-mingw32-w64"));
535 EXPECT_EQ("x86_64--windows-gnu", Triple::normalize("x86_64-mingw32-w64"));
536
537 EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf"));
538 EXPECT_EQ("i686--windows-elf", Triple::normalize("i686-win32-elf"));
539 EXPECT_EQ("i686-pc-windows-macho", Triple::normalize("i686-pc-win32-macho"));
540 EXPECT_EQ("i686--windows-macho", Triple::normalize("i686-win32-macho"));
541
542 EXPECT_EQ("x86_64-pc-windows-elf", Triple::normalize("x86_64-pc-win32-elf"));
543 EXPECT_EQ("x86_64--windows-elf", Triple::normalize("x86_64-win32-elf"));
544 EXPECT_EQ("x86_64-pc-windows-macho", Triple::normalize("x86_64-pc-win32-macho"));
545 EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
546
547 EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
548 }
549 }