brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · 8e46d23 Raw
106 lines · cpp
1// UNSUPPORTED: system-windows2 3// RUN: rm -rf %t.dir/testroot-gcc4// RUN: mkdir -p %t.dir/testroot-gcc/bin5// RUN: ln -s %clang %t.dir/testroot-gcc/bin/x86_64-w64-mingw32-gcc6// RUN: ln -s %clang %t.dir/testroot-gcc/bin/x86_64-w64-mingw32-clang7// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %t.dir/testroot-gcc/x86_64-w64-mingw328// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/lib %t.dir/testroot-gcc/lib9 10// RUN: rm -rf %t.dir/testroot-clang11// RUN: mkdir -p %t.dir/testroot-clang/bin12// RUN: ln -s %clang %t.dir/testroot-clang/bin/x86_64-w64-mingw32-clang13// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %t.dir/testroot-clang/x86_64-w64-mingw3214// RUN: ln -s %S/Inputs/mingw_arch_tree/usr/i686-w64-mingw32 %t.dir/testroot-clang/i686-w64-mingw3215 16// RUN: rm -rf %t.dir/testroot-clang-native17// RUN: mkdir -p %t.dir/testroot-clang-native/bin18// RUN: ln -s %clang %t.dir/testroot-clang-native/bin/clang19// RUN: mkdir -p %t.dir/testroot-clang-native/include/_mingw.h20// RUN: mkdir -p %t.dir/testroot-clang-native/lib/libkernel32.a21 22// RUN: rm -rf %t.dir/testroot-custom-triple23// RUN: mkdir -p %t.dir/testroot-custom-triple/bin24// RUN: ln -s %clang %t.dir/testroot-custom-triple/bin/clang25// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %t.dir/testroot-custom-triple/x86_64-w64-mingw32foo26 27// If we find a gcc in the path with the right triplet prefix, pick that as28// sysroot:29 30// This test is only executed on non-Windows systems, i.e. only when31// cross compiling. Check that we don't add the tool root's plain include32// directory to the path - this would end up including /usr/include for33// cross toolchains installed in /usr.34 35// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %clang --target=x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s --implicit-check-not="\"{{.*}}/testroot-gcc{{/|\\\\}}include\""36// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE:[^"]+]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++"37// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}x86_64-w64-mingw32"38// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}backward"39// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10.2-posix"40// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10.2"41// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}10.2-posix{{/|\\\\}}include{{/|\\\\}}g++-v10"42// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"43 44 45// If we pass --sysroot explicitly, then we do include <sysroot>/include46// even when cross compiling.47// RUN: %clang --target=x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="%t.dir/testroot-gcc" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC_EXPLICIT %s48 49// CHECK_TESTROOT_GCC_EXPLICIT: "-internal-isystem" "{{[^"]+}}/testroot-gcc{{/|\\\\}}include"50 51 52// If -no-canonical-prefixes and there's a matching sysroot next to the clang binary itself, prefer that53// over a gcc in the path:54 55// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-clang/bin/x86_64-w64-mingw32-clang --target=x86_64-w64-mingw32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC2 %s56// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-clang/bin/x86_64-w64-mingw32-clang --target=x86_64-w64-mingw32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s -no-canonical-prefixes 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG %s57// CHECK_TESTROOT_GCC2: "{{[^"]+}}/testroot-gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"58// CHECK_TESTROOT_CLANG: "{{[^"]+}}/testroot-clang{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"59 60 61// If we pick a root based on a sysroot next to the clang binary, which also62// happens to be in the same directory as gcc, make sure we still can pick up63// the libgcc directory:64 65// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-gcc/bin/x86_64-w64-mingw32-clang --target=x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s66 67 68// If we're executing clang from a directory with what looks like a mingw sysroot,69// with headers in <base>/include and libs in <base>/lib, use that rather than looking70// for another GCC in the path.71//72// Note, this test has a surprising quirk: We're testing with an install directory,73// testroot-clang-native, which lacks the "x86_64-w64-mingw32" subdirectory, it only74// has the include and lib subdirectories without any triple prefix.75//76// Since commit fd15cb935d7aae25ad62bfe06fe9f17cea585978, we avoid using the77// <base>/include and <base>/lib directories when cross compiling. So technically, this78// case testcase only works exactly as expected when running on x86_64 Windows, when79// this target isn't considered cross compiling.80//81// However we do still pass the include directory <base>/x86_64-w64-mingw32/include to82// the -cc1 interface, even if it is missing. Thus, this test looks for this path name,83// that indicates that we did choose the right base, even if this particular directory84// actually doesn't exist here.85 86// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-clang-native/bin/clang -no-canonical-prefixes --target=x86_64-w64-mingw32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG_NATIVE %s87// CHECK_TESTROOT_CLANG_NATIVE: "{{[^"]+}}/testroot-clang-native{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"88 89 90// If the user requests a different arch via the -m32 option, which changes91// x86_64 into i386, check that the driver notices that it can't find a92// sysroot for i386 but there is one for i686, and uses that one.93// (In practice, the real usecase is when using an unprefixed native clang94// that defaults to x86_64 mingw, but it's easier to test this in cross setups95// with symlinks, like the other tests here.)96 97// RUN: env "PATH=%t.dir/testroot-gcc/bin:%PATH%" %t.dir/testroot-clang/bin/x86_64-w64-mingw32-clang -no-canonical-prefixes --target=x86_64-w64-mingw32 -m32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG_I686 %s98// CHECK_TESTROOT_CLANG_I686: "{{[^"]+}}/testroot-clang{{/|\\\\}}i686-w64-mingw32{{/|\\\\}}include"99 100 101// If the user calls clang with a custom literal triple, make sure this maps102// to sysroots with the matching spelling.103 104// RUN: %t.dir/testroot-custom-triple/bin/clang -no-canonical-prefixes --target=x86_64-w64-mingw32foo -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CUSTOM_TRIPLE %s105// CHECK_TESTROOT_CUSTOM_TRIPLE: "{{[^"]+}}/testroot-custom-triple{{/|\\\\}}x86_64-w64-mingw32foo{{/|\\\\}}include"106