Hello. The attached reproducer_installed demonstrates that * 903694 is a bug in gcc-7, not in the source for gcc-snapshot. * 856274 is fixed in gcc-7.
I have tried to rebuild gcc-7 with itself, replacing the former debian/patches/ada-gcc-name.diff with the attached version. Then reproducer_in_tree reported no error, so I hope that the fixed gcc-7 will be able to build gcc-snapshot and will cause no regression with 856274. I have not been able to test the installed version in a porterbox. It may be possible to enforce the gnatlink executable name manually in gcc-snapshot and make it buildable by unfixed gcc-7 versions, but it is much work because of the mess with recursive Make invokations.
Description: simplifiy detection of machine and version in command name The previous algorithm wrongly tests "End_Of_Prefix > 1", which may happen even if a match has been found. . Note: for historical reasons, gnatchop carries its own version of the old algorithm, which seems to work in our case. Bugs-Debian: https://bugs.debian.org/903694 Bugs-Debian: https://bugs.debian.org/856274 Author: Ludovic Brenta <lbre...@debian.org> Author: Nicolas Boulenguez <nico...@debian.org> --- a/src/gcc/ada/osint.adb +++ b/src/gcc/ada/osint.adb @@ -2199,22 +2199,14 @@ ------------------ function Program_Name (Nam : String; Prog : String) return String_Access is - End_Of_Prefix : Natural := 0; Start_Of_Prefix : Positive := 1; - Start_Of_Suffix : Positive; begin -- Get the name of the current program being executed Find_Program_Name; - Start_Of_Suffix := Name_Len + 1; - - -- Find the target prefix if any, for the cross compilation case. - -- For instance in "powerpc-elf-gcc" the target prefix is - -- "powerpc-elf-" - -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1" - + -- Find directory part if any, and ignore it from now on. for J in reverse 1 .. Name_Len loop if Name_Buffer (J) = '/' or else Name_Buffer (J) = Directory_Separator @@ -2223,25 +2215,21 @@ end if; end loop; - -- Find End_Of_Prefix - + -- Find the target prefix if any, for the cross compilation case. + -- For instance in "powerpc-elf-gcc" the target prefix is + -- "powerpc-elf-" + -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1" + -- In other terms, search and replace Prog with Nam. for J in Start_Of_Prefix .. Name_Len - Prog'Length + 1 loop if Name_Buffer (J .. J + Prog'Length - 1) = Prog then - End_Of_Prefix := J - 1; - exit; + return new String'(Name_Buffer (Start_Of_Prefix .. J - 1) + & Nam + & Name_Buffer (J + Prog'Length .. Name_Len)); end if; end loop; - if End_Of_Prefix > 1 then - Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1; - end if; - - -- Create the new program name - - return new String' - (Name_Buffer (Start_Of_Prefix .. End_Of_Prefix) - & Nam - & Name_Buffer (Start_Of_Suffix .. Name_Len)); + -- If no match has been found, return the argument unchanged. + return new String'(Nam); end Program_Name; ------------------------------
#!/bin/sh # Attempt to reproduce 856274 and 903694 with the installed packages. # Also check the influence of /usr/bin (see 856274). set -eu MACHINE=`gcc -dumpmachine` BV=`gcc -dumpversion` # Reproduce #856274 for t in gnatchop $MACHINE-gnatchop $MACHINE-gnatchop-$BV gnatchop-$BV; do echo "package P is end P;" > p.a echo echo "Trying: $t" $t -v p.a echo echo "Trying: /usr/bin/$t" /usr/bin/$t -v p.a rm -f p.a p.ads done # Reproduce #903694. for t in gnatmake $MACHINE-gnatmake $MACHINE-gnatmake-$BV gnatmake-$BV; do echo "with Ada.Text_IO; procedure Hello is begin Ada.Text_IO.Put_Line (\"Hello\"); end Hello;" > hello.adb echo echo "Trying: $t" $t -v hello.adb -largs -v echo echo "Trying: /usr/bin/$t" /usr/bin/$t -v hello.adb -largs -v rm -f hello hello.o hello.adb hello.ali b~hello.adb b~hello.ads hello.adb done
#!/bin/sh # Attempt to reproduce 856274 and 903694 in a freshly built tree. # The build and host compilers must match. set -eu MACHINE=`gcc -dumpmachine` BV=`gcc -dumpversion` rts=--RTS=build/$MACHINE/libada for exe in gnatbind gnatlink gnatmake gnatchop; do for lnk in $MACHINE-$exe $MACHINE-$exe-$BV $exe-$BV; do if test ! -x build/gcc/$lnk; then (cd build/gcc && ln -s $exe $lnk) fi done done # Reproduce #856274 for t in gnatchop $MACHINE-gnatchop $MACHINE-gnatchop-$BV gnatchop-$BV; do echo "package P is end P;" > p.a echo echo "Trying: $t" D_LIBRARY_PATH="../$MACHINE/libada/adalib:../$MACHINE/libgnatvsn:build/gcc" PATH="build/gcc:$PATH" $t -v p.a rm -f p.a p.ads done # Reproduce #903694. for t in gnatmake $MACHINE-gnatmake $MACHINE-gnatmake-$BV gnatmake-$BV; do echo "with Ada.Text_IO; procedure Hello is begin Ada.Text_IO.Put_Line (\"Hello\"); end Hello;" > hello.adb echo echo "Trying: $t" D_LIBRARY_PATH="../$MACHINE/libada/adalib:../$MACHINE/libgnatvsn:build/gcc" PATH="build/gcc:$PATH" $t $rts -v hello.adb -largs -v rm -f hello hello.o hello.adb hello.ali b~hello.adb b~hello.ads hello.adb done