@@ -99,54 +99,82 @@ def getBOLTCmakeBuildFactory(
99
99
# Individual markers to skip either in-tree or out-of-tree tests.
100
100
skipInTree = ".llvm-bolt.skip.in-tree"
101
101
skipOutOfTree = ".llvm-bolt.skip.out-of-tree"
102
+ boltNew = "bin/llvm-bolt.new"
103
+ boltOld = "bin/llvm-bolt.old"
102
104
103
105
f .addSteps ([
106
+ # Cleanup binaries and markers from previous NFC-mode runs.
107
+ ShellCommand (
108
+ name = 'clean-nfc-check' ,
109
+ command = (
110
+ f"rm -f { boltNew } { boltOld } { hasSrcChanges } { skipInTree } { skipOutOfTree } ; "
111
+ ),
112
+ description = ('Cleanup for NFC-Mode testing' ),
113
+ descriptionDone = ["NFC-Mode cleanup" ],
114
+ haltOnFailure = False ,
115
+ flunkOnFailure = False ,
116
+ env = env ),
117
+ # Build the current and previous revision of llvm-bolt.
104
118
ShellCommand (
105
119
name = 'nfc-check-setup' ,
106
120
command = [
107
- f"../{ f .monorepo_dir } /bolt/utils/nfc-check-setup.py" ,
121
+ f"../{ f .monorepo_dir } /bolt/utils/nfc-check-setup.py" ,
108
122
"--switch-back" ,
109
123
"--check-bolt-sources"
110
124
],
111
125
description = ('Setup NFC testing' ),
112
126
descriptionDone = ["NFC-Mode setup" ],
113
127
warnOnFailure = True ,
128
+ warnOnWarnings = True ,
129
+ decodeRC = {0 : SUCCESS , 1 : WARNINGS },
114
130
haltOnFailure = False ,
115
131
flunkOnFailure = False ,
116
132
env = env ),
133
+ # Validate that NFC-mode comparison is meaningful by checking:
134
+ # - the old and new binaries exist
135
+ # - no unique IDs are embedded in the binaries
136
+ # Warns but does not fail when validation fails.
117
137
ShellCommand (
118
138
name = 'nfc-check-validation' ,
119
139
command = (
120
- "info=$(bin/llvm-bolt.new --version | grep 'BOLT revision' "
140
+ f"( ! [ -f { boltNew } ] || ! [ -f { boltOld } ] ) && "
141
+ "{ printf 'NFC-Mode WARNING: old/new files not present. Tests will run.'; return 2; }; "
142
+ f"uids=$({ boltNew } --version | grep 'BOLT revision' "
121
143
"| grep -q '<unknown>' || echo 'bolt-revision'); "
122
- "info=$info $(readelf --notes bin/llvm-bolt.new "
144
+ f"uids=$uids $(readelf --notes { boltNew } "
123
145
"| grep -q 'Build ID:' && echo ' GNU-build-id'); "
124
- "info=$(echo \" $info\" | sed 's/^ //'); "
125
- "[ ! -z \" $info\" ] || return 0 && "
126
- "(printf \" NFC-Mode WARNING: unique IDs found in binaries ($info)"
127
- ". This means tests will run at all times.\" ; return 2)"
146
+ "uids=$(echo \" $uids\" | sed 's/^ //'); "
147
+ f"[ $(readelf --note { boltNew } { boltOld } | grep 'Build ID' | uniq -c | wc -l) -eq 1 ] "
148
+ "&& extra='Identical build-ids.' || extra='Tests will run.'; "
149
+ "[ ! -z \" $uids\" ] || return 0 && "
150
+ "{ printf \" NFC-Mode WARNING: unique IDs found in binaries ($uids). $extra\" ; return 2; }"
128
151
),
129
152
description = ('Check that nfc-mode works as intended when '
130
153
'comparing with the previous commit.' ),
131
154
haltOnFailure = False ,
132
155
warnOnFailure = True ,
133
156
warnOnWarnings = True ,
134
157
decodeRC = {0 : SUCCESS , 1 : FAILURE , 2 : WARNINGS },
135
- descriptionDone = ["NFC-Mode unique IDs in binaries " ],
158
+ descriptionDone = ["NFC-Mode Validation " ],
136
159
env = env ),
160
+ # Compare the current and previous llvm-bolt binaries. If they are
161
+ # identical, skip the following tests. If relevant source code
162
+ # changes are detected, still run the in-tree tests.
137
163
ShellCommand (
138
164
name = 'nfc-check-bolt-different' ,
139
165
command = (
140
- f'rm -f { skipInTree } { skipOutOfTree } ; '
141
- f'cmp -s bin/llvm-bolt.old bin/llvm-bolt.new && ('
166
+ f'cmp -s { boltNew } { boltOld } && ('
142
167
f'touch { skipInTree } ; touch { skipOutOfTree } ); '
143
- f'[ -f { hasSrcChanges } ] && rm -f { skipInTree } ;'
144
- f'rm -f { hasSrcChanges } ; '
168
+ f'[ -f { hasSrcChanges } ] && rm -f { skipInTree } ; '
169
+ f'return 0 '
145
170
),
146
171
description = ('Check if llvm-bolt binaries are different and '
147
172
'skip the following nfc-check steps' ),
173
+ decodeRC = {0 : SUCCESS , 1 : WARNINGS },
148
174
haltOnFailure = False ,
149
175
env = env ),
176
+ # Run in-tree tests if the llvm-bolt binary has changed, or if
177
+ # relevant source code changes are detected.
150
178
LitTestCommand (
151
179
name = 'nfc-check-bolt' ,
152
180
command = ["ninja" , "check-bolt" ],
@@ -157,6 +185,7 @@ def getBOLTCmakeBuildFactory(
157
185
flunkOnFailure = True ,
158
186
doStepIf = FileDoesNotExist (f"build/{ skipInTree } " ),
159
187
env = env ),
188
+ # Run out-of-tree large tests if the llvm-bolt binary has changed.
160
189
LitTestCommand (
161
190
name = 'nfc-check-large-bolt' ,
162
191
command = ['bin/llvm-lit' , '-sv' , '-j2' ,
@@ -171,6 +200,7 @@ def getBOLTCmakeBuildFactory(
171
200
])
172
201
173
202
return f
203
+
174
204
class SkipAwareBuild (Build ):
175
205
"""
176
206
Custom Build class that marks the overall build status as skipped when no
0 commit comments