public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-23  9:56 ` fxcoudert at gcc dot gnu.org
  2021-12-23 10:18 ` fxcoudert at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-23  9:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |charlet at adacore dot com,
                   |                            |derodat at adacore dot com,
                   |                            |fxcoudert at gcc dot gnu.org
            Summary|please respect calling gnat |GNAT tools do not respect
                   |tools configured with       |--program-suffix and
                   |--program-suffix and        |--program-prefix
                   |--program-prefix            |
   Last reconfirmed|                            |2021-12-23
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Confirmed. This is blocking Ada integration into Homebrew:
https://github.com/Homebrew/homebrew-core/pull/77641

We configure GCC with:
configure --prefix=/tmp/irun --enable-languages=all --program-suffix=-11

This leads to the installation of suffixed gnat tools:

meau /tmp/irun $ ls bin/gnat*
bin/gnat-11      bin/gnatchop-11  bin/gnatkr-11    bin/gnatls-11   
bin/gnatname-11
bin/gnatbind-11  bin/gnatclean-11 bin/gnatlink-11  bin/gnatmake-11 
bin/gnatprep-11

But they're not usable:

meau /tmp/irun $ gnatmake-11 hello.adb
gcc -c hello.adb
clang: error: unknown argument: '-gnatea'
clang: error: unknown argument: '-gnatez'
gnatmake-11: "hello.adb" compilation error

because gnatmake-11 is calling the unsuffixed `gcc`, which does not support
Ada.
(On macOS, this system compiler is a wrapper to clang.)

Even if I try to add some options to gnatmake, it will still somehow fail,
because the relevant options are not passed down to gnatlink:

meau /tmp/irun $ gnatmake-11 hello.adb --GCC=gcc-11 --GNATBIND=gnatbind-11
--GNATLINK=gnatlink-11
gcc-11 -c hello.adb
gnatbind-11 -x hello.ali
gnatlink-11 hello.ali
clang: error: unknown argument: '-gnatA'
clang: error: unknown argument: '-gnatWb'
clang: error: unknown argument: '-gnatiw'
clang: error: unknown argument: '-gnatws'
gnatmake-11: *** link failed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
  2021-12-23  9:56 ` [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix fxcoudert at gcc dot gnu.org
@ 2021-12-23 10:18 ` fxcoudert at gcc dot gnu.org
  2021-12-23 13:28 ` egallager at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-23 10:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

--- Comment #2 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
It's puzzling, because although I've never read any Ada code, I can see there
is some logic in place that should deal with it. In make.adb there is:

   Gcc      : String_Access := Program_Name ("gcc", "gnatmake");
   Gnatbind : String_Access := Program_Name ("gnatbind", "gnatmake");
   Gnatlink : String_Access := Program_Name ("gnatlink", "gnatmake");

and in osint.adb the function Program_Name has some logic to find prefix and
suffix:

      --  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"

and it uses them to return the program that is going to be used:

      --  Create the new program name

      return new String'
        (Name_Buffer (Start_Of_Prefix .. End_Of_Prefix)
         & Nam
         & Name_Buffer (Start_Of_Suffix .. Name_Len));

I tried to debug this by sticking some Ada.Text_IO.Put_Line calls, but either
I'm doing it wrong, or it's never actually called.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
  2021-12-23  9:56 ` [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix fxcoudert at gcc dot gnu.org
  2021-12-23 10:18 ` fxcoudert at gcc dot gnu.org
@ 2021-12-23 13:28 ` egallager at gcc dot gnu.org
  2021-12-23 13:52 ` fxcoudert at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-12-23 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
MacPorts also configures with --program-suffix so if we ever wanted to add ada
support there, this would block that, too.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-23 13:28 ` egallager at gcc dot gnu.org
@ 2021-12-23 13:52 ` fxcoudert at gcc dot gnu.org
  2022-01-03 10:49 ` charlet at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-23 13:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

--- Comment #4 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
The current situation is the result of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=864
Comment 20 by Dave Korn (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=864#c20)
is spot on:

> ... means that it only recognizes a suffix if there is also a prefix, i.e. it only
> works for cross-compilers.  The documentation suggests this is deliberate:
> [...]
> but why?  The native behaviour is wrong and it seems incorrect to me that
> it should have different semantics from the cross-compiler case.

As far as I can see, this comment from 2011 was never addressed, and the bug
was closed. This is what is biting us, this logic needs to be improved.

The simplest patch is to detect suffix in all cases, as far as I can see one
only needs to remove the test:


diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index cf39128fb7b..9a578a62273 100644
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -2286,9 +2286,7 @@ package body Osint is
          end if;
       end loop;

-      if End_Of_Prefix > 1 then
-         Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1;
-      end if;
+      Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1;

       --  Create the new program name


And with this patch I get the expected result:

$ gnatmake-11 hello.adb     
gcc-11 -c hello.adb
gnatbind-11 -x hello.ali
gnatlink-11 hello.ali

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-12-23 13:52 ` fxcoudert at gcc dot gnu.org
@ 2022-01-03 10:49 ` charlet at gcc dot gnu.org
  2022-01-04 14:24 ` fxcoudert at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: charlet at gcc dot gnu.org @ 2022-01-03 10:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

Arnaud Charlet <charlet at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |charlet at gcc dot gnu.org

--- Comment #5 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
Thanks for the investigation. What's tricky and why things got stuck last time
is the complexity of testing all the possible combinations (prefix, or suffix,
or both).
Can you in particular check that your proposed patch isn't breaking the use of
a prefix with no suffix (e.g. i686-elf-gcc) and check the behavior when using
both a prefix and a suffix (e.g. i686-elf-gcc-4.1)?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-01-03 10:49 ` charlet at gcc dot gnu.org
@ 2022-01-04 14:24 ` fxcoudert at gcc dot gnu.org
  2022-01-04 15:25 ` charlet at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-01-04 14:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #6 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
I checked the patch on all 4 possible cases with/without prefix and
with/without suffix. I confirm they all work as expected, with the patch. In
addition, I think the logic of the code is sane (although I have never written
any Ada in my life).

It would really help if we could get this in, it would enable us to ship Ada as
part of GCC in Homebrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2022-01-04 14:24 ` fxcoudert at gcc dot gnu.org
@ 2022-01-04 15:25 ` charlet at gcc dot gnu.org
  2022-01-11 13:27 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: charlet at gcc dot gnu.org @ 2022-01-04 15:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

--- Comment #7 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
Understood, I'll work on it then, thanks for your help!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2022-01-04 15:25 ` charlet at gcc dot gnu.org
@ 2022-01-11 13:27 ` cvs-commit at gcc dot gnu.org
  2022-01-11 13:30 ` charlet at gcc dot gnu.org
  2022-04-06 15:24 ` nicolas at debian dot org
  9 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-11 13:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pierre-Marie de Rodat
<pmderodat@gcc.gnu.org>:

https://gcc.gnu.org/g:7aa3800216ea991050ec904a28c628cd7799021b

commit r12-6459-g7aa3800216ea991050ec904a28c628cd7799021b
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Mon Jan 3 10:51:07 2022 +0000

    [Ada] PR ada/79724

    gcc/ada/

            PR ada/79724
            * osint.adb (Program_Name): Fix handling of suffixes.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2022-01-11 13:27 ` cvs-commit at gcc dot gnu.org
@ 2022-01-11 13:30 ` charlet at gcc dot gnu.org
  2022-04-06 15:24 ` nicolas at debian dot org
  9 siblings, 0 replies; 10+ messages in thread
From: charlet at gcc dot gnu.org @ 2022-01-11 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

Arnaud Charlet <charlet at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #9 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
Should now be fully fixed!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix
       [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2022-01-11 13:30 ` charlet at gcc dot gnu.org
@ 2022-04-06 15:24 ` nicolas at debian dot org
  9 siblings, 0 replies; 10+ messages in thread
From: nicolas at debian dot org @ 2022-04-06 15:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79724

--- Comment #10 from Nicolas Boulenguez <nicolas at debian dot org> ---
Hello.

I suggest that Homebrew adopt a solution tested for years by Debian:
* install the executables as TARGET-gcc-VERSION
* add symbolic links if necessary (gcc, gcc-VERSION, TARGET-gcc)
* apply the patch provided here over 3 years ago
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87777
  This URL always links to latest rebase:
 
https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/ada-gcc-name.diff

Until the assumptions are made explicit, the upstream code trying to guess the
name of the gcc executable will probably keep changing, as it has for at least
ten years. I have counted at least 6 similar bugs, and that’s only on Debian. 

This leads to duplicate efforts. For example, the diagnostic of this specific
index error is included in the patch above.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-06 15:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-79724-4@http.gcc.gnu.org/bugzilla/>
2021-12-23  9:56 ` [Bug ada/79724] GNAT tools do not respect --program-suffix and --program-prefix fxcoudert at gcc dot gnu.org
2021-12-23 10:18 ` fxcoudert at gcc dot gnu.org
2021-12-23 13:28 ` egallager at gcc dot gnu.org
2021-12-23 13:52 ` fxcoudert at gcc dot gnu.org
2022-01-03 10:49 ` charlet at gcc dot gnu.org
2022-01-04 14:24 ` fxcoudert at gcc dot gnu.org
2022-01-04 15:25 ` charlet at gcc dot gnu.org
2022-01-11 13:27 ` cvs-commit at gcc dot gnu.org
2022-01-11 13:30 ` charlet at gcc dot gnu.org
2022-04-06 15:24 ` nicolas at debian dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).