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