@@ -1552,14 +1552,40 @@ package body Gnatcheck.Compiler is
15521552 -- ------------------------------
15531553
15541554 function Should_Use_Codepeer_Target return Boolean is
1555- Regular_Gnatls : String_Access := Locate_Exec_On_Path (" gnatls" );
15561555 begin
1556+ -- If an explicit toolchain has been provided to the tool (through the
1557+ -- CLI, the project file of the config file), we need to never fallback
1558+ -- to the codepeer target.
1559+ if Gnatcheck_Prj.Tree.Is_Defined
1560+ and then Gnatcheck_Prj.Tree.Has_Explicit_Target
1561+ then
1562+ return Ada.Strings.Unbounded." =" (Target, " codepeer" ) or else
1563+ Ada.Strings.Unbounded." =" (Target, " gnatsas" );
1564+ end if ;
1565+
15571566 -- If we could find a regular gnatls, it means there is a native
15581567 -- toolchain, that takes precedence over a potential codepeer toolchain.
1559- if Regular_Gnatls /= null then
1560- Free (Regular_Gnatls);
1561- return False;
1562- end if ;
1568+ declare
1569+ Regular_Gnatls : String_Access := Locate_Exec_On_Path (" gnatls" );
1570+ begin
1571+ if Regular_Gnatls /= null then
1572+ Free (Regular_Gnatls);
1573+ return False;
1574+ else
1575+ declare
1576+ Regular_Gprbuild : String_Access :=
1577+ Locate_Exec_On_Path (" gprbuild" );
1578+ begin
1579+ -- If we could find a regular "gprbuild", it means there is a
1580+ -- cross toolchain available, thus we don't want to fallback on
1581+ -- the codepeer target
1582+ if Regular_Gprbuild /= null then
1583+ Free (Regular_Gprbuild);
1584+ return False;
1585+ end if ;
1586+ end ;
1587+ end if ;
1588+ end ;
15631589
15641590 -- If we couldn't, look for a codepeer toolchain.
15651591 declare
@@ -1688,7 +1714,7 @@ package body Gnatcheck.Compiler is
16881714 Args (Num_Args) := new String'(" --target=" & To_String (Target));
16891715 elsif Should_Use_Codepeer_Target then
16901716 Num_Args := @ + 1 ;
1691- Args (Num_Args) := new String'(" --target=codepeer " );
1717+ Args (Num_Args) := new String'(" --target=gnatsas " );
16921718 end if ;
16931719 else
16941720 -- Target and runtime will be taken from config project anyway
@@ -1833,9 +1859,12 @@ package body Gnatcheck.Compiler is
18331859 Args (8 ) := new String'(" --restricted-to-languages=ada" );
18341860 Num_Args := 8 ;
18351861
1862+ Num_Args := @ + 1 ;
18361863 if Should_Use_Codepeer_Target then
1837- Num_Args := @ + 1 ;
1838- Args (Num_Args) := new String'(" --target=codepeer" );
1864+ Args (Num_Args) := new String'(" --target=gnatsas" );
1865+ else
1866+ Args (Num_Args) :=
1867+ new String'(" --target=" & Ada.Strings.Unbounded.To_String (Target));
18391868 end if ;
18401869
18411870 if Arg.Jobs.Get > 1 then
0 commit comments