Bug#881938: gnat: call gcc/g++ with system_type
Package: src:gcc-7
Version: 7.2.0-16
gnatlink/gnatmake etc programs may call gcc/g++ internally,
while they just call them by the name:
gcc-VERSION
g++-VERSION
which will cause problem for cross toolchains.
--
YunQiang Su
diff --git a/debian/patches/ada-gcc-name.diff b/debian/patches/ada-gcc-name.diff
index ef6c223..970d3bc 100644
--- a/debian/patches/ada-gcc-name.diff
+++ b/debian/patches/ada-gcc-name.diff
@@ -10,29 +10,39 @@ Author: Nicolas Boulenguez <nicolas@debian.org>
--- a/src/gcc/ada/gnatlink.adb
+++ b/src/gcc/ada/gnatlink.adb
-@@ -136,7 +136,8 @@
+@@ -33,6 +33,7 @@ with Namet; use Namet;
+ with Opt;
+ with Osint; use Osint;
+ with Output; use Output;
++with Sdefault;
+ with Snames;
+ with Switch; use Switch;
+ with System; use System;
+@@ -136,7 +137,9 @@ procedure Gnatlink is
-- This table collects the arguments to be passed to compile the binder
-- generated file.
- Gcc : String_Access := Program_Name ("gcc", "gnatlink");
+ Gcc : String_Access
-+ := Program_Name ("gcc-" & Gnatvsn.Library_Version, "gnatlink");
++ := Program_Name (Sdefault.Target_Name.all & "-gcc-" &
++ Gnatvsn.Library_Version, "gnatlink");
Read_Mode : constant String := "r" & ASCII.NUL;
-@@ -1414,7 +1415,8 @@
+@@ -1414,7 +1417,9 @@ procedure Gnatlink is
end if;
Write_Line (" --GCC=comp Use comp as the compiler");
- Write_Line (" --LINK=nam Use 'nam' for the linking rather than 'gcc'");
-+ Write_Line (" --LINK=nam Use 'nam' for the linking rather than 'gcc-"
++ Write_Line (" --LINK=nam Use 'nam' for the linking rather than '"
++ & Sdefault.Target_Name.all & "-gcc-"
+ & Gnatvsn.Library_Version & "'");
Write_Eol;
Write_Line (" [non-Ada-objects] list of non Ada object files");
Write_Line (" [linker-options] other options for the linker");
--- a/src/gcc/ada/make.adb
+++ b/src/gcc/ada/make.adb
-@@ -670,9 +670,12 @@
+@@ -670,9 +670,15 @@ package body Make is
-- Compiler, Binder & Linker Data and Subprograms --
----------------------------------------------------
@@ -40,34 +50,38 @@ Author: Nicolas Boulenguez <nicolas@debian.org>
- Gnatbind : String_Access := Program_Name ("gnatbind", "gnatmake");
- Gnatlink : String_Access := Program_Name ("gnatlink", "gnatmake");
+ Gcc : String_Access := Program_Name
-+ ("gcc-" & Gnatvsn.Library_Version, "gnatmake");
++ (Sdefault.Target_Name.all & "-gcc-" &
++ Gnatvsn.Library_Version, "gnatmake");
+ Gnatbind : String_Access := Program_Name
-+ ("gnatbind-" & Gnatvsn.Library_Version, "gnatmake");
++ (Sdefault.Target_Name.all & "-gnatbind-" &
++ Gnatvsn.Library_Version, "gnatmake");
+ Gnatlink : String_Access := Program_Name
-+ ("gnatlink-" & Gnatvsn.Library_Version, "gnatmake");
++ (Sdefault.Target_Name.all & "-gnatlink-" &
++ Gnatvsn.Library_Version, "gnatmake");
-- Default compiler, binder, linker programs
Saved_Gcc : String_Access := null;
--- a/src/gcc/ada/mdll-utl.adb
+++ b/src/gcc/ada/mdll-utl.adb
-@@ -29,6 +29,7 @@
+@@ -29,6 +29,8 @@ with Ada.Text_IO;
with Ada.Exceptions;
with GNAT.Directory_Operations;
+with Gnatvsn;
++with Sdefault;
with Osint;
package body MDLL.Utl is
-@@ -39,7 +40,7 @@
+@@ -39,7 +41,7 @@ package body MDLL.Utl is
Dlltool_Name : constant String := "dlltool";
Dlltool_Exec : OS_Lib.String_Access;
- Gcc_Name : constant String := "gcc";
-+ Gcc_Name : constant String := "gcc-" & Gnatvsn.Library_Version;
++ Gcc_Name : constant String := Sdefault.Target_Name.all & "-gcc-" & Gnatvsn.Library_Version;
Gcc_Exec : OS_Lib.String_Access;
Gnatbind_Name : constant String := "gnatbind";
-@@ -212,7 +213,7 @@
+@@ -212,7 +214,7 @@ package body MDLL.Utl is
end;
end if;
@@ -78,21 +92,23 @@ Author: Nicolas Boulenguez <nicolas@debian.org>
--- a/src/gcc/ada/mlib-utl.adb
+++ b/src/gcc/ada/mlib-utl.adb
-@@ -23,6 +23,7 @@
+@@ -23,6 +23,8 @@
-- --
------------------------------------------------------------------------------
+with Gnatvsn;
++with Sdefault;
with MLib.Fil; use MLib.Fil;
with MLib.Tgt; use MLib.Tgt;
with Opt;
-@@ -446,7 +447,8 @@
+@@ -446,7 +448,9 @@ package body MLib.Utl is
if Driver_Name = No_Name then
if Gcc_Exec = null then
if Gcc_Name = null then
- Gcc_Name := Osint.Program_Name ("gcc", "gnatmake");
+ Gcc_Name := Osint.Program_Name
-+ ("gcc-" & Gnatvsn.Library_Version, "gnatmake");
++ (Sdefault.Target_Name.all & "-gcc-" &
++ Gnatvsn.Library_Version, "gnatmake");
end if;
Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
@@ -106,12 +122,13 @@ Author: Nicolas Boulenguez <nicolas@debian.org>
with Makeutl; use Makeutl;
with Opt;
with Output;
-@@ -115,7 +116,7 @@
+@@ -115,7 +116,8 @@ package body Prj.Makr is
procedure Dup2 (Old_Fd, New_Fd : File_Descriptor);
- Gcc : constant String := "gcc";
-+ Gcc : constant String := "gcc-" & Gnatvsn.Library_Version;
++ Gcc : constant String := Sdefault.Target_Name.all
++ & "-gcc-" & Gnatvsn.Library_Version;
Gcc_Path : String_Access := null;
Non_Empty_Node : constant Project_Node_Id := 1;
Reply to: