]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Make the names of uninstalled cross-gnattools consistent across builds
authorMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 7 Jul 2024 14:04:51 +0000 (15:04 +0100)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Sun, 7 Jul 2024 14:04:51 +0000 (15:04 +0100)
We suffer from an inconsistency in the names of uninstalled gnattools
executables in cross-compiler configurations.  The cause is a recipe we
have:

ada.all.cross:
for tool in $(ADA_TOOLS) ; do \
  if [ -f $$tool$(exeext) ] ; \
  then \
    $(MV) $$tool$(exeext) $$tool-cross$(exeext); \
  fi; \
done

the intent of which is to give the names of gnattools executables the
'-cross' suffix, consistently with the compiler drivers: 'gcc-cross',
'g++-cross', etc.

A problem with the recipe is that this 'make' target is called too early
in the build process, before gnattools have been made.  Consequently no
renames happen and owing to that they are conditional on the presence of
the individual executables the recipe succeeds doing nothing.

However if a target is requested later on such as 'make pdf' that does
not cause gnattools executables to be rebuilt, then 'ada.all.cross' does
succeed in renaming the executables already present in the build tree.
Then if the 'gnat' testsuite is run later on which expects non-suffixed
'gnatmake' executable, it does not find the 'gnatmake-cross' executable
in the build tree and may either catastrophically fail or incorrectly
use a system-installed copy of 'gnatmake'.

Of course if a target is requested such as `make all' that does cause
gnattools executables to be rebuilt, then both suffixed and non-suffixed
uninstalled executables result.

Fix the problem by moving the renaming of gnattools to a separate 'make'
recipe, pasted into a new 'gnattools-cross-mv' target and the existing
legacy 'cross-gnattools' target.  Then invoke the new target explicitly
from the 'gnattools-cross' recipe in gnattools/.

Update the test harness accordingly, so that suffixed gnattools are used
in cross-compilation testsuite runs.

gcc/ada/
* gcc-interface/Make-lang.in (ada.all.cross): Move recipe to...
(GNATTOOLS_CROSS_MV): ... this new variable.
(cross-gnattools): Paste it here.
(gnattools-cross-mv): New target.

gnattools/
* Makefile.in (gnattools-cross): Also build 'gnattools-cross-mv'
in GCC_DIR.

gcc/testsuite/
* lib/gnat.exp (local_find_gnatmake, find_gnatclean): Use
'-cross' suffix where testing a cross-compiler.

gcc/ada/gcc-interface/Make-lang.in
gcc/testsuite/lib/gnat.exp
gnattools/Makefile.in

index ebf1f70de7812a9547b1e7f5a00895cd743959ac..b28411046516ca40a968f6cb4e70f270df9b66fc 100644 (file)
@@ -780,6 +780,7 @@ regnattools:
 cross-gnattools: force
        $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1-re
        $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2
+       $(GNATTOOLS_CROSS_MV)
 
 canadian-gnattools: force
        $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1-re
@@ -795,19 +796,23 @@ gnatlib gnatlib-sjlj gnatlib-zcx gnatlib-shared: force
           FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
           $@
 
+gnattools-cross-mv:
+       $(GNATTOOLS_CROSS_MV)
+
+GNATTOOLS_CROSS_MV=\
+  for tool in $(ADA_TOOLS) ; do \
+    if [ -f $$tool$(exeext) ] ; \
+    then \
+      $(MV) $$tool$(exeext) $$tool-cross$(exeext); \
+    fi; \
+  done
+
 # use only for native compiler
 gnatlib_and_tools: gnatlib gnattools
 
 # Build hooks:
 
 ada.all.cross:
-       for tool in $(ADA_TOOLS) ; do \
-         if [ -f $$tool$(exeext) ] ; \
-         then \
-           $(MV) $$tool$(exeext) $$tool-cross$(exeext); \
-         fi; \
-       done
-
 ada.start.encap:
 ada.rest.encap:
 ada.man:
index 471f83e984497feebd35053c87c6fa1f3b1cff5f..c278cb7f044fcd94a4ae3973d86ba79c8f09b69e 100644 (file)
@@ -199,12 +199,19 @@ proc prune_gnat_output { text } {
 # which prevent multilib from working, so define a new one.
 
 proc local_find_gnatmake {} {
+    global target_triplet
     global tool_root_dir
+    global host_triplet
 
     if ![is_remote host] {
-        set file [lookfor_file $tool_root_dir gnatmake]
+       if { "$host_triplet" == "$target_triplet" } {
+           set gnatmake gnatmake
+       } else {
+           set gnatmake gnatmake-cross
+       }
+       set file [lookfor_file $tool_root_dir $gnatmake]
         if { $file == "" } {
-           set file [lookfor_file $tool_root_dir gcc/gnatmake]
+           set file [lookfor_file $tool_root_dir gcc/$gnatmake]
         }
         if { $file != "" } {
            set root [file dirname $file]
@@ -225,12 +232,19 @@ proc local_find_gnatmake {} {
 }
 
 proc find_gnatclean {} {
+    global target_triplet
     global tool_root_dir
+    global host_triplet
 
     if ![is_remote host] {
-        set file [lookfor_file $tool_root_dir gnatclean]
+       if { "$host_triplet" == "$target_triplet" } {
+           set gnatclean gnatclean
+       } else {
+           set gnatclean gnatclean-cross
+       }
+       set file [lookfor_file $tool_root_dir $gnatclean]
         if { $file == "" } {
-           set file [lookfor_file $tool_root_dir gcc/gnatclean]
+           set file [lookfor_file $tool_root_dir gcc/$gnatclean]
         }
         if { $file != "" } {
            set gnatclean $file;
index e8fc4af0788cabd35b4f942a33884218c5181a97..4efb0d8f1fe84ec7ea4b4518c74e115c90caacf7 100644 (file)
@@ -223,6 +223,7 @@ gnattools-cross: $(GCC_DIR)/stamp-tools
        # gnattools2
        $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
          $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools
+       $(MAKE) -C $(GCC_DIR) gnattools-cross-mv
 
 # Other
 # -----