comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: link errors with GNAT GPL 2016 and gprof
Date: Sun, 3 Sep 2017 11:23:55 -0700 (PDT)
Date: 2017-09-03T11:23:55-07:00	[thread overview]
Message-ID: <76eec2b1-22e9-4e44-a560-54f4fe715b0d@googlegroups.com> (raw)
In-Reply-To: <712651ae-2403-4d61-ab8e-f696c9352dc9@googlegroups.com>

On Sunday, September 3, 2017 at 11:01:12 AM UTC-5, Anh Vo wrote:
> On Saturday, September 2, 2017 at 3:02:48 PM UTC-7, Stephen Leake wrote:
> > I'm trying to Do The Right Thing and profile my code before I start messing with it to make it faster. But GNAT is _not_ cooperating!
> > 
> > According to the gnat user guide, to use gprof, we compile as:
> > 
> >    gnatmake -f -pg -P <project.gpr>
> > 
> > That fails with GNAT GPL 2016:
> > 
> > gprbuild: illegal option "-pg" on the command line
> > 
> > So I added "-pg" in the Builder package in the project file:
> > 
> >    package Builder is
> >       case Profile is
> >       when "Full" =>
> >          for Default_Switches ("Ada") use ("-f", "-pg");
> > 
> >       when "On" =>
> >          for Default_Switches ("Ada") use ("-pg");
> > 
> >       when "Off" =>
> >          null;
> >       end case;
> > 
> >    end Builder;
> > 
> > That gives -pg options on each 'gcc' command, but fails at link time:
> > 
> > gcc run_ada_lite_parser.o -o run_ada_lite_parser.exe
> > run_ada_lite_parser.o: In function `ada_run_ada_lite_parser':
> > C:/Projects/org.wisitoken.stephe-1/wisi/test/run_ada_lite_parser.adb:12: undefined reference to `mcount'
> > 
> > I noticed there is no '-pg' on the 'gcc' link command line, so I added it to the Linker package:
> > 
> >    package Linker is
> >       case Profile is
> >       when "Full" | "On" =>
> >          for Default_Switches ("Ada") use ("-pg");
> > 
> >       when "Off" =>
> >          null;
> >       end case;
> > 
> >    end Linker;
> > 
> > That did not help. Also tried adding it to the Binder package; no help there either.
> > 
> > How do I tell gprbuild to specify "-pg" for linking?
> > 
> > The gnat user guide has always been unhelpful about mapping command line options to project file packages.
> > 
> > -- Stephe
> 
> In order to pass switches to the linker thru gnatmake, use -largs opts according to gnatmake --help shown. Could you try this?
> 
> Anh Vo

As I said, gnatmake does not work with GNAT GPL 2016; it calls gprbuild. But gprbuild does support the -largs option ... and that works.

Thanks for that. I'd still like to know how to put it in the project file, sigh.

-- Stephe

  reply	other threads:[~2017-09-03 18:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-02 22:02 link errors with GNAT GPL 2016 and gprof Stephen Leake
2017-09-03 16:01 ` Anh Vo
2017-09-03 18:23   ` Stephen Leake [this message]
2017-09-03 19:26     ` gautier_niouzes
2017-09-04  0:07       ` Stephen Leake
2017-09-04 21:01         ` gautier_niouzes
2017-09-04  5:52 ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox