@@ -191,6 +191,7 @@ impl EarlyProps {
191191 return true ;
192192 }
193193 if let Some ( ref actual_version) = config. llvm_version {
194+ let actual_version = version_to_int ( actual_version) ;
194195 if line. starts_with ( "min-llvm-version" ) {
195196 let min_version = line
196197 . trim_end ( )
@@ -199,7 +200,7 @@ impl EarlyProps {
199200 . expect ( "Malformed llvm version directive" ) ;
200201 // Ignore if actual version is smaller the minimum required
201202 // version
202- & actual_version[ .. ] < min_version
203+ actual_version < version_to_int ( min_version)
203204 } else if line. starts_with ( "min-system-llvm-version" ) {
204205 let min_version = line
205206 . trim_end ( )
@@ -208,7 +209,7 @@ impl EarlyProps {
208209 . expect ( "Malformed llvm version directive" ) ;
209210 // Ignore if using system LLVM and actual version
210211 // 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)
212213 } else if line. starts_with ( "ignore-llvm-version" ) {
213214 // Syntax is: "ignore-llvm-version <version1> [- <version2>]"
214215 let range_components = line
@@ -219,15 +220,15 @@ impl EarlyProps {
219220 . take ( 3 ) // 3 or more = invalid, so take at most 3.
220221 . collect :: < Vec < & str > > ( ) ;
221222 match range_components. len ( ) {
222- 1 => & actual_version[ .. ] == range_components[ 0 ] ,
223+ 1 => actual_version == version_to_int ( range_components[ 0 ] ) ,
223224 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 ] ) ;
226227 if v_max < v_min {
227228 panic ! ( "Malformed LLVM version range: max < min" )
228229 }
229230 // 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
231232 }
232233 _ => panic ! ( "Malformed LLVM version directive" ) ,
233234 }
@@ -238,6 +239,20 @@ impl EarlyProps {
238239 false
239240 }
240241 }
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+ }
241256 }
242257}
243258
0 commit comments