@@ -191,6 +191,7 @@ impl EarlyProps {
191
191
return true;
192
192
}
193
193
if let Some(ref actual_version) = config.llvm_version {
194
+ let actual_version = version_to_int(actual_version);
194
195
if line.starts_with("min-llvm-version") {
195
196
let min_version = line
196
197
.trim_end()
@@ -199,7 +200,7 @@ impl EarlyProps {
199
200
.expect("Malformed llvm version directive");
200
201
// Ignore if actual version is smaller the minimum required
201
202
// version
202
- & actual_version[..] < min_version
203
+ actual_version < version_to_int( min_version)
203
204
} else if line.starts_with("min-system-llvm-version") {
204
205
let min_version = line
205
206
.trim_end()
@@ -208,7 +209,7 @@ impl EarlyProps {
208
209
.expect("Malformed llvm version directive");
209
210
// Ignore if using system LLVM and actual version
210
211
// is smaller the minimum required version
211
- config.system_llvm && & actual_version[..] < min_version
212
+ config.system_llvm && actual_version < version_to_int( min_version)
212
213
} else if line.starts_with("ignore-llvm-version") {
213
214
// Syntax is: "ignore-llvm-version <version1> [- <version2>]"
214
215
let range_components = line
@@ -219,15 +220,15 @@ impl EarlyProps {
219
220
.take(3) // 3 or more = invalid, so take at most 3.
220
221
.collect::<Vec<&str>>();
221
222
match range_components.len() {
222
- 1 => & actual_version[..] == range_components[0],
223
+ 1 => actual_version == version_to_int( range_components[0]) ,
223
224
2 => {
224
- let v_min = range_components[0];
225
- let v_max = range_components[1];
225
+ let v_min = version_to_int( range_components[0]) ;
226
+ let v_max = version_to_int( range_components[1]) ;
226
227
if v_max < v_min {
227
228
panic!("Malformed LLVM version range: max < min")
228
229
}
229
230
// Ignore if version lies inside of range.
230
- & actual_version[..] >= v_min && & actual_version[..] <= v_max
231
+ actual_version >= v_min && actual_version <= v_max
231
232
}
232
233
_ => panic!("Malformed LLVM version directive"),
233
234
}
@@ -238,6 +239,20 @@ impl EarlyProps {
238
239
false
239
240
}
240
241
}
242
+
243
+ fn version_to_int(version: &str) -> u32 {
244
+ let version_without_suffix = version.split('-').next().unwrap();
245
+ let components: Vec<u32> = version_without_suffix
246
+ .split('.')
247
+ .map(|s| s.parse().expect("Malformed version component"))
248
+ .collect();
249
+ match components.len() {
250
+ 1 => components[0] * 10000,
251
+ 2 => components[0] * 10000 + components[1] * 100,
252
+ 3 => components[0] * 10000 + components[1] * 100 + components[2],
253
+ _ => panic!("Malformed version"),
254
+ }
255
+ }
241
256
}
242
257
}
243
258
0 commit comments