|
13 | 13 | /// so only name priority is accounted for, unless we fail to find
|
14 | 14 | /// anything at all in the prefix.
|
15 | 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 | + |
16 | 21 | /// Symlink clang to a new dir which will be its
|
17 | 22 | /// "program path" for these tests
|
18 | 23 | // RUN: rm -rf %t && mkdir -p %t
|
|
21 | 26 | /// No gccs at all, nothing is found
|
22 | 27 | // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
23 | 28 | // RUN: FileCheck --check-prefix=NO_NOTREAL_GCC %s
|
24 |
| -// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc |
25 |
| -// NO_NOTREAL_GCC-NOT: /gcc |
| 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[^/]*"}} |
26 | 35 |
|
27 | 36 | /// <triple>-gcc in program path is found
|
28 | 37 | // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
|
29 | 38 | // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
30 | 39 | // RUN: FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
|
31 |
| -// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc |
| 40 | +// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc" |
32 | 41 |
|
33 | 42 | /// <triple>-gcc on the PATH is found
|
34 | 43 | // RUN: mkdir -p %t/env
|
35 | 44 | // RUN: rm %t/notreal-none-elf-gcc
|
36 | 45 | // RUN: touch %t/env/notreal-none-elf-gcc && chmod +x %t/env/notreal-none-elf-gcc
|
37 | 46 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
38 | 47 | // RUN: FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
|
39 |
| -// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc |
| 48 | +// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc" |
40 | 49 |
|
41 | 50 | /// <triple>-gcc in program path is preferred to one on the PATH
|
42 | 51 | // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
|
43 | 52 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
44 | 53 | // RUN: FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
|
45 |
| -// BOTH_NOTREAL_GCC: notreal-none-elf-gcc |
46 |
| -// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc |
| 54 | +// BOTH_NOTREAL_GCC: notreal-none-elf-gcc" |
| 55 | +// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc" |
47 | 56 |
|
48 | 57 | /// On program path, <triple>-gcc is preferred to plain gcc
|
49 | 58 | // RUN: touch %t/gcc && chmod +x %t/gcc
|
50 | 59 | // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
51 | 60 | // RUN: FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
|
52 |
| -// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc |
53 |
| -// NOTREAL_GCC_PREFERRED-NOT: /gcc |
| 61 | +// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc" |
| 62 | +// NOTREAL_GCC_PREFERRED-NOT: /gcc" |
54 | 63 |
|
55 | 64 | /// <triple>-gcc on the PATH is preferred to gcc in program path
|
56 | 65 | // RUN: rm %t/notreal-none-elf-gcc
|
57 | 66 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
58 | 67 | // RUN: FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
|
59 |
| -// NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc |
60 |
| -// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc |
| 68 | +// NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc" |
| 69 | +// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc" |
61 | 70 |
|
62 | 71 | /// <triple>-gcc on the PATH is preferred to gcc on the PATH
|
63 | 72 | // RUN: rm %t/gcc
|
64 | 73 | // RUN: touch %t/env/gcc && chmod +x %t/env/gcc
|
65 | 74 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
66 | 75 | // RUN: FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
|
67 |
| -// NOTREAL_PATH_OVER_GCC_PATH: env/notreal-none-elf-gcc |
68 |
| -// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc |
| 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. |
69 | 88 |
|
70 | 89 | /// <default-triple>-gcc has lowest priority so <triple>-gcc
|
71 | 90 | /// on PATH beats default triple in program path
|
72 |
| -/// Darwin triples have a version appended to them, even if set via |
73 |
| -/// LLVM_DEFAULT_TARGET_TRIPLE. So the only way to know for sure is to ask clang. |
74 | 91 | // RUN: DEFAULT_TRIPLE=`%t/clang --version | grep "Target:" | cut -d ' ' -f2`
|
75 | 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 |
76 | 94 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
77 | 95 | // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
|
78 |
| -// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc |
| 96 | +// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc" |
79 | 97 |
|
80 | 98 | /// plain gcc on PATH beats default triple in program path
|
81 | 99 | // RUN: rm %t/env/notreal-none-elf-gcc
|
82 | 100 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
83 | 101 | // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
|
84 |
| -// DEFAULT_TRIPLE_NO_NOTREAL: env/gcc |
85 |
| -// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc |
| 102 | +// DEFAULT_TRIPLE_NO_NOTREAL: env/gcc" |
| 103 | +// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc" |
86 | 104 |
|
87 | 105 | /// default triple only chosen when no others are present
|
88 | 106 | // RUN: rm %t/env/gcc
|
89 | 107 | // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
|
90 | 108 | // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
|
91 |
| -// DEFAULT_TRIPLE_NO_OTHERS: -gcc |
92 |
| -// DEFAULT_TRIPLE_NO_OTHERS-NOT: notreal-none-elf-gcc |
93 |
| -// DEFAULT_TRIPLE_NO_OTHERS-NOT: /gcc |
| 109 | +// DEFAULT_TRIPLE_NO_OTHERS: -gcc" |
| 110 | +// DEFAULT_TRIPLE_NO_OTHERS-NOT: notreal-none-elf-gcc" |
| 111 | +// DEFAULT_TRIPLE_NO_OTHERS-NOT: /gcc" |
94 | 112 |
|
95 | 113 | /// -B paths are searched separately so default triple will win
|
96 | 114 | /// if put in one of those even if other paths have higher priority names
|
97 | 115 | // RUN: mkdir -p %t/prefix
|
98 |
| -// RUN: mv %t/$DEFAULT_TRIPLE-gcc %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 |
99 | 121 | // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
|
100 | 122 | // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s -B %t/prefix 2>&1 | \
|
101 | 123 | // RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_IN_PREFIX %s
|
102 |
| -// DEFAULT_TRIPLE_IN_PREFIX: prefix/{{.*}}-gcc |
103 |
| -// DEFAULT_TRIPLE_IN_PREFIX-NOT: notreal-none-elf-gcc |
| 124 | +// DEFAULT_TRIPLE_IN_PREFIX: prefix/{{.*}}-gcc" |
| 125 | +// DEFAULT_TRIPLE_IN_PREFIX-NOT: notreal-none-elf-gcc" |
104 | 126 |
|
105 | 127 | /// Only if there is nothing in the prefix will we search other paths
|
106 |
| -// RUN: rm %t/prefix/$DEFAULT_TRIPLE-gcc |
| 128 | +/// -f in case $DEFAULT_TRIPLE == %target_triple |
| 129 | +// RUN: rm -f %t/prefix/$DEFAULT_TRIPLE-gcc |
| 130 | +// RUN: rm -f %t/prefix/%target_triple-gcc |
107 | 131 | // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s -B %t/prefix 2>&1 | \
|
108 | 132 | // RUN: FileCheck --check-prefix=EMPTY_PREFIX_DIR %s
|
109 |
| -// EMPTY_PREFIX_DIR: notreal-none-elf-gcc |
| 133 | +// EMPTY_PREFIX_DIR: notreal-none-elf-gcc" |
0 commit comments