1 /// Don't create symlinks on Windows 2 // UNSUPPORTED: system-windows 3 4 /// Check the priority used when searching for tools 5 /// Names and locations are usually in this order: 6 /// <triple>-tool, tool, program path, PATH 7 /// (from highest to lowest priority) 8 /// A higher priority name found in a lower priority 9 /// location will win over a lower priority name in a 10 /// higher priority location. 11 /// Prefix dirs (added with -B) override the location, 12 /// so only name priority is accounted for, unless we fail to find 13 /// anything at all in the prefix. 14 15 /// Note: All matches are expected to be at the end of file paths. 16 /// So we match " on the end to account for build systems that 17 /// put the name of the compiler in the build path. 18 /// E.g. /build/gcc_X.Y.Z/0/... 19 20 /// Symlink clang to a new dir which will be its 21 /// "program path" for these tests 22 // RUN: rm -rf %t && mkdir -p %t 23 // RUN: ln -s %clang %t/clang 24 25 /// No gccs at all, nothing is found 26 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 27 // RUN: FileCheck --check-prefix=NO_NOTREAL_GCC %s 28 // NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc" 29 /// Some systems will have "gcc-x.y.z" so for this first check 30 /// make sure we don't find "gcc" or "gcc-x.y.z". If we do find either 31 /// then there is no point continuing as this copy of clang is not 32 /// isolated as we expected. 33 // NO_NOTREAL_GCC-NOT: {{/gcc[^/]*"}} 34 35 /// <triple>-gcc in program path is found 36 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc 37 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 38 // RUN: FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s 39 // PROG_PATH_NOTREAL_GCC: notreal-none-unknown-elf 40 41 /// <triple>-gcc on the PATH is found 42 // RUN: mkdir -p %t/env 43 // RUN: rm %t/notreal-none-elf-gcc 44 // RUN: touch %t/env/notreal-none-elf-gcc && chmod +x %t/env/notreal-none-elf-gcc 45 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 46 // RUN: FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s 47 // ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc" 48 49 /// <triple>-gcc in program path is preferred to one on the PATH 50 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc 51 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 52 // RUN: FileCheck --check-prefix=BOTH_NOTREAL_GCC %s 53 // BOTH_NOTREAL_GCC: notreal-none-elf-gcc" 54 // BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc" 55 56 /// On program path, <triple>-gcc is preferred to plain gcc 57 // RUN: touch %t/gcc && chmod +x %t/gcc 58 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 59 // RUN: FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s 60 // NOTREAL_GCC_PREFERRED: notreal-none-unknown-elf" 61 // NOTREAL_GCC_PREFERRED-NOT: /gcc" 62 63 /// <triple>-gcc on the PATH is preferred to gcc in program path 64 // RUN: rm %t/notreal-none-elf-gcc 65 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 66 // RUN: FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s 67 // NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc" 68 // NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc" 69 70 /// <triple>-gcc on the PATH is preferred to gcc on the PATH 71 // RUN: rm %t/gcc 72 // RUN: touch %t/env/gcc && chmod +x %t/env/gcc 73 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 74 // RUN: FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s 75 // NOTREAL_PATH_OVER_GCC_PATH: env/notreal-none-elf-gcc" 76 // NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc" 77 78 /// We cannot trust clang --version, or cmake's LLVM_DEFAULT_TARGET_TRIPLE 79 /// to give us the one and only default triple. 80 /// Can't trust cmake because on Darwin, triples have a verison appended to them. 81 /// (and clang uses the versioned string to search) 82 /// Can't trust --version because it will pad 3 item triples to 4 e.g. 83 /// powerpc64le-linux-gnu -> powerpc64le-unknown-linux-gnu 84 /// (and clang uses the former to search) 85 /// So we write to both names which is a bit odd but still proves that the 86 /// lookup is working. 87 88 /// <default-triple>-gcc has lowest priority so <triple>-gcc 89 /// on PATH beats default triple in program path 90 // RUN: DEFAULT_TRIPLE=`%t/clang --version | grep "Target:" | cut -d ' ' -f2` 91 // RUN: touch %t/$DEFAULT_TRIPLE-gcc && chmod +x %t/$DEFAULT_TRIPLE-gcc 92 // RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc 93 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 94 // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s 95 // DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc" 96 97 /// plain gcc on PATH beats default triple in program path 98 // RUN: rm %t/env/notreal-none-elf-gcc 99 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 100 // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s 101 // DEFAULT_TRIPLE_NO_NOTREAL: env/gcc" 102 // DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc" 103 104 /// Pick "gcc" as a fallback. Don't pick $DEFAULT_TRIPLE-gcc. 105 // RUN: rm %t/env/gcc 106 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ 107 // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s 108 // DEFAULT_TRIPLE_NO_OTHERS: "gcc" 109 110 /// -B paths are searched separately so default triple will win 111 /// if put in one of those even if other paths have higher priority names 112 // RUN: mkdir -p %t/prefix 113 /// One of these will fail when $DEFAULT_TRIPLE == %target_triple 114 // RUN: test -f %t/$DEFAULT_TRIPLE-gcc && \ 115 // RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix || true 116 // RUN: test -f %t/%target_triple-gcc && \ 117 // RUN: mv %t/%target_triple-gcc %t/prefix || true 118 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc 119 // RUN: touch %t/prefix/gcc && chmod +x %t/prefix/gcc 120 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s -B %t/prefix 2>&1 | \ 121 // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_IN_PREFIX %s 122 // DEFAULT_TRIPLE_IN_PREFIX: prefix/gcc" 123 // DEFAULT_TRIPLE_IN_PREFIX-NOT: notreal-none-elf-gcc" 124 125 /// Only if there is nothing in the prefix will we search other paths 126 /// -f in case $DEFAULT_TRIPLE == %target_triple 127 // RUN: rm -f %t/prefix/$DEFAULT_TRIPLE-gcc %t/prefix/%target_triple-gcc %t/prefix/gcc 128 // RUN: env "PATH=" %t/clang -### -canonical-prefixes --target=notreal-none-elf %s -B %t/prefix 2>&1 | \ 129 // RUN: FileCheck --check-prefix=EMPTY_PREFIX_DIR1 %s 130 // EMPTY_PREFIX_DIR1: gcc" 131 // RUN: env "PATH=" %t/clang -### -no-canonical-prefixes --target=notreal-none-elf %s -B %t/prefix 2>&1 | \ 132 // RUN: FileCheck --check-prefix=EMPTY_PREFIX_DIR2 %s 133 // EMPTY_PREFIX_DIR2: notreal-none-elf-gcc" 134