@@ -62,22 +62,16 @@ static DEFAULT_PATTERNS: LazyLock<Vec<(CompilerType, Regex)>> = LazyLock::new(||
6262 Regex :: new ( & full_pattern) . unwrap_or_else ( |_| panic ! ( "Invalid regex pattern: {}" , full_pattern) )
6363 }
6464 vec ! [
65- // simple cc pattern: matches cc
66- ( CompilerType :: Gcc , create_compiler_regex( r"(?:[^/]*-)?cc " , false ) ) ,
67- // GCC pattern: matches cc, c++ and gcc cross compilation variants and versioned variants
68- ( CompilerType :: Gcc , create_compiler_regex( r"(?:[^/]*-)?(?:gcc|g\+\+|c\+\+ )" , true ) ) ,
65+ // simple cc and c++ (no version support)
66+ ( CompilerType :: Gcc , create_compiler_regex( r"(?:[^/]*-)?(?:cc|c\+\+) " , false ) ) ,
67+ // GCC pattern
68+ ( CompilerType :: Gcc , create_compiler_regex( r"(?:[^/]*-)?(?:gcc|g\+\+|gfortran|egfortran|f95 )" , true ) ) ,
6969 // GCC internal executables pattern: matches GCC's internal compiler phases
70- // These are implementation details of GCC's compilation process that should be
71- // routed to GccInterpreter for proper handling (typically to be ignored).
72- // Examples: cc1, cc1plus, cc1obj, cc1objplus, collect2, lto1
73- ( CompilerType :: Gcc , create_compiler_regex( r"(?:cc1(?:plus|obj|objplus)?|collect2|lto1)" , false ) ) ,
70+ ( CompilerType :: Gcc , create_compiler_regex( r"(?:cc1(?:plus|obj|objplus)?|f951|collect2|lto1)" , false ) ) ,
7471 // Clang pattern: matches clang, clang++, cross-compilation variants, and versioned variants
7572 ( CompilerType :: Clang , create_compiler_regex( r"(?:[^/]*-)?clang(?:\+\+)?" , true ) ) ,
76- // Fortran pattern: matches gfortran, flang, f77, f90, f95, f03, f08, cross-compilation variants, and versioned variants
77- (
78- CompilerType :: Flang ,
79- create_compiler_regex( r"(?:[^/]*-)?(?:gfortran|flang|f77|f90|f95|f03|f08)" , true ) ,
80- ) ,
73+ // Fortran pattern: matches flang, cross-compilation variants, and versioned variants
74+ ( CompilerType :: Flang , create_compiler_regex( r"(?:[^/]*-)?(?:flang|flang-new)" , true ) ) ,
8175 // Intel Fortran pattern: matches ifort, ifx, and versioned variants
8276 ( CompilerType :: IntelFortran , create_compiler_regex( r"(?:ifort|ifx)" , true ) ) ,
8377 // Cray Fortran pattern: matches crayftn, ftn
@@ -343,10 +337,9 @@ mod tests {
343337 assert_eq ! ( recognizer. recognize( path( "clang-15.exe" ) ) , Some ( CompilerType :: Clang ) ) ;
344338
345339 // Fortran with .exe extensions
346- assert_eq ! ( recognizer. recognize( path( "gfortran.exe" ) ) , Some ( CompilerType :: Flang ) ) ;
340+ assert_eq ! ( recognizer. recognize( path( "gfortran.exe" ) ) , Some ( CompilerType :: Gcc ) ) ;
347341 assert_eq ! ( recognizer. recognize( path( "flang.exe" ) ) , Some ( CompilerType :: Flang ) ) ;
348- assert_eq ! ( recognizer. recognize( path( "f77.exe" ) ) , Some ( CompilerType :: Flang ) ) ;
349- assert_eq ! ( recognizer. recognize( path( "f90.exe" ) ) , Some ( CompilerType :: Flang ) ) ;
342+ assert_eq ! ( recognizer. recognize( path( "f95.exe" ) ) , Some ( CompilerType :: Gcc ) ) ;
350343
351344 // Intel Fortran with .exe extensions
352345 assert_eq ! ( recognizer. recognize( path( "ifort.exe" ) ) , Some ( CompilerType :: IntelFortran ) ) ;
@@ -379,21 +372,18 @@ mod tests {
379372 let recognizer = CompilerRecognizer :: new ( ) ;
380373
381374 // Basic Fortran names
382- assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Flang ) ) ;
375+ assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Gcc ) ) ;
376+ assert_eq ! ( recognizer. recognize( path( "f95" ) ) , Some ( CompilerType :: Gcc ) ) ;
383377 assert_eq ! ( recognizer. recognize( path( "flang" ) ) , Some ( CompilerType :: Flang ) ) ;
384- assert_eq ! ( recognizer. recognize( path( "f77" ) ) , Some ( CompilerType :: Flang ) ) ;
385- assert_eq ! ( recognizer. recognize( path( "f90" ) ) , Some ( CompilerType :: Flang ) ) ;
386- assert_eq ! ( recognizer. recognize( path( "f95" ) ) , Some ( CompilerType :: Flang ) ) ;
387- assert_eq ! ( recognizer. recognize( path( "f03" ) ) , Some ( CompilerType :: Flang ) ) ;
388- assert_eq ! ( recognizer. recognize( path( "f08" ) ) , Some ( CompilerType :: Flang ) ) ;
378+ assert_eq ! ( recognizer. recognize( path( "flang-new" ) ) , Some ( CompilerType :: Flang ) ) ;
389379
390380 // Cross-compilation variants
391- assert_eq ! ( recognizer. recognize( path( "arm-linux-gnueabi-gfortran" ) ) , Some ( CompilerType :: Flang ) ) ;
381+ assert_eq ! ( recognizer. recognize( path( "arm-linux-gnueabi-gfortran" ) ) , Some ( CompilerType :: Gcc ) ) ;
392382
393383 // Versioned variants
394- assert_eq ! ( recognizer. recognize( path( "gfortran-11" ) ) , Some ( CompilerType :: Flang ) ) ;
395- assert_eq ! ( recognizer. recognize( path( "gfortran11" ) ) , Some ( CompilerType :: Flang ) ) ;
396- assert_eq ! ( recognizer. recognize( path( "f90 -4.8" ) ) , Some ( CompilerType :: Flang ) ) ;
384+ assert_eq ! ( recognizer. recognize( path( "gfortran-11" ) ) , Some ( CompilerType :: Gcc ) ) ;
385+ assert_eq ! ( recognizer. recognize( path( "gfortran11" ) ) , Some ( CompilerType :: Gcc ) ) ;
386+ assert_eq ! ( recognizer. recognize( path( "f95 -4.8" ) ) , Some ( CompilerType :: Gcc ) ) ;
397387 }
398388
399389 #[ test]
@@ -512,6 +502,7 @@ mod tests {
512502 assert_eq ! ( recognizer. recognize( path( "cc1obj" ) ) , Some ( CompilerType :: Gcc ) ) ;
513503 assert_eq ! ( recognizer. recognize( path( "cc1objplus" ) ) , Some ( CompilerType :: Gcc ) ) ;
514504 assert_eq ! ( recognizer. recognize( path( "collect2" ) ) , Some ( CompilerType :: Gcc ) ) ;
505+ assert_eq ! ( recognizer. recognize( path( "f951" ) ) , Some ( CompilerType :: Gcc ) ) ;
515506 assert_eq ! ( recognizer. recognize( path( "lto1" ) ) , Some ( CompilerType :: Gcc ) ) ;
516507
517508 // Test with full paths
@@ -566,7 +557,7 @@ mod tests {
566557 ) ;
567558
568559 // Test Fortran pattern matching when 'as' is None
569- assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Flang ) ) ;
560+ assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Gcc ) ) ;
570561 }
571562
572563 #[ test]
@@ -618,7 +609,7 @@ mod tests {
618609 assert_eq ! ( recognizer. recognize( path( "g++-9.3.0" ) ) , Some ( CompilerType :: Gcc ) ) ;
619610 assert_eq ! ( recognizer. recognize( path( "clang-15" ) ) , Some ( CompilerType :: Clang ) ) ;
620611 assert_eq ! ( recognizer. recognize( path( "clang-12.1" ) ) , Some ( CompilerType :: Clang ) ) ;
621- assert_eq ! ( recognizer. recognize( path( "gfortran-12" ) ) , Some ( CompilerType :: Flang ) ) ;
612+ assert_eq ! ( recognizer. recognize( path( "gfortran-12" ) ) , Some ( CompilerType :: Gcc ) ) ;
622613 assert_eq ! ( recognizer. recognize( path( "ifort-2023" ) ) , Some ( CompilerType :: IntelFortran ) ) ;
623614 assert_eq ! ( recognizer. recognize( path( "nvcc-11.8" ) ) , Some ( CompilerType :: Cuda ) ) ;
624615
@@ -629,7 +620,7 @@ mod tests {
629620 // Test that non-versioned compilers still work
630621 assert_eq ! ( recognizer. recognize( path( "gcc" ) ) , Some ( CompilerType :: Gcc ) ) ;
631622 assert_eq ! ( recognizer. recognize( path( "clang" ) ) , Some ( CompilerType :: Clang ) ) ;
632- assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Flang ) ) ;
623+ assert_eq ! ( recognizer. recognize( path( "gfortran" ) ) , Some ( CompilerType :: Gcc ) ) ;
633624
634625 // Test that wrapper executables don't have version patterns (as expected)
635626 assert_eq ! ( recognizer. recognize( path( "ccache" ) ) , Some ( CompilerType :: Wrapper ) ) ;
0 commit comments