[Ada] Fix PR ada/118247

Message ID 21980174.4csPzL39Zc@fomalhaut
State New
Headers
Series [Ada] Fix PR ada/118247 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply

Commit Message

Eric Botcazou Jan. 6, 2025, 11:23 a.m. UTC
  This is a regression introduced by
  https://gcc.gnu.org/pipermail/gcc-cvs/2024-July/405522.html
in the form of a spurious relinking of the gnatbind executable for the install 
target of cross Ada compilers.

Tested on x86-64/Linux, applied on the mainline.


2025-01-06  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/118247
	* gcc-interface/Make-lang.in (GNATTOOLS_CROSS_MV): Copy gnatbind
	instead of moving it.
  

Comments

Maciej W. Rozycki Jan. 7, 2025, 4:07 p.m. UTC | #1
On Mon, 6 Jan 2025, Eric Botcazou wrote:

> This is a regression introduced by
>   https://gcc.gnu.org/pipermail/gcc-cvs/2024-July/405522.html
> in the form of a spurious relinking of the gnatbind executable for the install 
> target of cross Ada compilers.

 The fix feels hackish and I wonder how other frontends handle this, but 
overall thank you for taking care of this peculiarity.

  Maciej
  
Eric Botcazou Jan. 7, 2025, 5:38 p.m. UTC | #2
>  The fix feels hackish and I wonder how other frontends handle this, but
> overall thank you for taking care of this peculiarity.

You're welcome.  The main Makefile does the same for xgcc -> gcc-cross and,
as this example shows, every change is this area is almost guaranteed to break 
something, so the simpler, the better.
  
Maciej W. Rozycki Jan. 8, 2025, 12:59 a.m. UTC | #3
On Tue, 7 Jan 2025, Eric Botcazou wrote:

> >  The fix feels hackish and I wonder how other frontends handle this, but
> > overall thank you for taking care of this peculiarity.
> 
> You're welcome.  The main Makefile does the same for xgcc -> gcc-cross and,
> as this example shows, every change is this area is almost guaranteed to break 
> something, so the simpler, the better.

 Thank you for the clarification, I can see the Makefile fragment now and 
I agree it was the right choice to follow it.  I think such explanatory 
notes are best placed in the change description though, for the benefit of 
people coming across it in the future.

  Maciej
  

Patch

diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index 1d8f0970980..b0c568ad60b 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -833,10 +833,14 @@  gnatlib gnatlib-sjlj gnatlib-zcx gnatlib-shared: force
 gnattools-cross-mv:
 	$(GNATTOOLS_CROSS_MV)
 
+# gnatbind$(exeext) is a prerequisite of the ada target and
+# thus needs to be copied instead of moved.
 GNATTOOLS_CROSS_MV=\
-  for tool in $(ADA_TOOLS) ; do \
-    if [ -f $$tool$(exeext) ] ; \
-    then \
+  if [ -f gnatbind$(exeext) ] ; then \
+    $(CP) gnatbind$(exeext) gnatbind-cross$(exeext); \
+  fi; \
+  for tool in $(filter-out gnatbind, $(ADA_TOOLS)) ; do \
+    if [ -f $$tool$(exeext) ] ; then \
       $(MV) $$tool$(exeext) $$tool-cross$(exeext); \
     fi; \
   done