Commit 5f01d97
authored
[SingleSource] Avoid race condition in symlink creation for forced opt vectorizer tests (#381)
Commit 6ac4455 added variants of the
vectorizer tests, built from the same source file. But each variant uses
the same reference output (e.g. `early-exit.reference_output`). A
symlink to this file is made in the build directory, and for parallel
builds we can get an error like:
```
CMake Error: failed to create symbolic link '/home/buildbot-worker/bbroot/clang-riscv-gauntlet/llvm-test-suite/build.rva23/SingleSource/UnitTests/Vectorizer/early-exit.reference_output': File exists
```
Essentially the same problem was fixed before in-tree in
a086e60. This patch implements a fix
along the same lines. llvm_singlesource now accepts a `DEST_SUFFIX`
which is plumbed through so that a unique symlink is created per test
variant.
A script like the following will reproduce the issue:
```
targets="
SingleSource/UnitTests/Vectorizer/early-exit
SingleSource/UnitTests/Vectorizer/tf-early-exit
SingleSource/UnitTests/Vectorizer/tfactivelanemask-early-exit
SingleSource/UnitTests/Vectorizer/ftic-early-exit
SingleSource/UnitTests/Vectorizer/tf-ftic-early-exit
SingleSource/UnitTests/Vectorizer/tfactivelanemask-ftic-early-exit
"
for i in $(seq 1 50); do
echo "attempt $i"
rm -f SingleSource/UnitTests/Vectorizer/early-exit.reference_output
ninja -t clean $targets >/dev/null || exit 1
if ! ninja -j32 $targets; then
echo "reproduced: parallel build failed; look above for the create_symlink File exists error"
exit 0
fi
done
echo "did not reproduce"
exit 1
```
I made use of an LLM (GPT 5.4) to debug the failure, find an in-tree
example of the same issue being worked around, and to apply that pattern
here.1 parent 6ac4455 commit 5f01d97
2 files changed
Lines changed: 26 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
15 | | - | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
89 | | - | |
90 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
91 | 101 | | |
92 | 102 | | |
93 | 103 | | |
| |||
135 | 145 | | |
136 | 146 | | |
137 | 147 | | |
138 | | - | |
139 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
0 commit comments