comp.lang.ada
 help / color / mirror / Atom feed
* link errors with GNAT GPL 2016 and gprof
@ 2017-09-02 22:02 Stephen Leake
  2017-09-03 16:01 ` Anh Vo
  2017-09-04  5:52 ` Jacob Sparre Andersen
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Leake @ 2017-09-02 22:02 UTC (permalink / raw)


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

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

* Re: link errors with GNAT GPL 2016 and gprof
  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
  2017-09-04  5:52 ` Jacob Sparre Andersen
  1 sibling, 1 reply; 7+ messages in thread
From: Anh Vo @ 2017-09-03 16:01 UTC (permalink / raw)


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
 


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

* Re: link errors with GNAT GPL 2016 and gprof
  2017-09-03 16:01 ` Anh Vo
@ 2017-09-03 18:23   ` Stephen Leake
  2017-09-03 19:26     ` gautier_niouzes
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2017-09-03 18:23 UTC (permalink / raw)


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

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

* Re: link errors with GNAT GPL 2016 and gprof
  2017-09-03 18:23   ` Stephen Leake
@ 2017-09-03 19:26     ` gautier_niouzes
  2017-09-04  0:07       ` Stephen Leake
  0 siblings, 1 reply; 7+ messages in thread
From: gautier_niouzes @ 2017-09-03 19:26 UTC (permalink / raw)


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

See the Profiling mode in zipada.gpr @ http://unzip-ada.sf.net

G.

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

* Re: link errors with GNAT GPL 2016 and gprof
  2017-09-03 19:26     ` gautier_niouzes
@ 2017-09-04  0:07       ` Stephen Leake
  2017-09-04 21:01         ` gautier_niouzes
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2017-09-04  0:07 UTC (permalink / raw)


On Sunday, September 3, 2017 at 2:26:32 PM UTC-5, gautier...@hotmail.com wrote:
> > I'd still like to know how to put it in the project file, sigh.
> 
> See the Profiling mode in zipada.gpr @ http://unzip-ada.sf.net
> 
> G.

That has -pg in the Linker package, which I thought was the right way. 

I just tried that again, and it doesn't work for me. I have two .gpr files; one 'with's the other. The Linker package is in the file that controls the executable source, so it should be applied. Nor does it work if the Linker package is in both files.

I miss having an AdaCore support contract ...

--  Stephe


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

* Re: link errors with GNAT GPL 2016 and gprof
  2017-09-02 22:02 link errors with GNAT GPL 2016 and gprof Stephen Leake
  2017-09-03 16:01 ` Anh Vo
@ 2017-09-04  5:52 ` Jacob Sparre Andersen
  1 sibling, 0 replies; 7+ messages in thread
From: Jacob Sparre Andersen @ 2017-09-04  5:52 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

We're using "gcov" regularly on a project I'm working on.  (For some
reason I can't get "gprof" to give me meaningful data, even though
"gcov" works fine.)

The whole setup is for various reasons a bit complex, but in its
essense, it reduces to:

   project Build is
      [...]

      package Compiler is
         for Default_Switches ("Ada") use ([...],
                                           "-fprofile-arcs",
                                           "-ftest-coverage");
      end Compiler;

      package Linker is
         for Default_Switches ("Ada") use ([...],
                                           "-pg",
                                           "-fprofile-arcs");
      end Linker;
   end Build;

Greetings,

Jacob
-- 
"people who live in glass houses shouldn't be throwing rocks
 -- especially at those who don't live in glass houses"


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

* Re: link errors with GNAT GPL 2016 and gprof
  2017-09-04  0:07       ` Stephen Leake
@ 2017-09-04 21:01         ` gautier_niouzes
  0 siblings, 0 replies; 7+ messages in thread
From: gautier_niouzes @ 2017-09-04 21:01 UTC (permalink / raw)


In this case, extending the zipada.gpr example, the following is working on GPL 2017 (with some luck, on 2016 or earlier too) :

zzz.gpr :
----
with "zipada";

project ZZZ is

   for Main use ("zzz.adb");
   for Source_Dirs use ("zzz");
   for Exec_Dir use ".";

   package Ide      renames ZipAda.Ide;
   package Builder  renames ZipAda.Builder;
   package Compiler renames ZipAda.Compiler;
   package Binder   renames ZipAda.Binder;
   package Linker   renames ZipAda.Linker;

end ZZZ;
----
New directory "zzz", and a copy of tools/zipada.adb as zzz/zzz.adb.
Then:
  gprbuild -P ZZZ -XBuild_Mode=Profiling
Testing the executable:
  zzz gpr *.gpr
(creates a Zip file gpr.zip, plus gmon.out)
Run the profiler:
  gprof zzz.exe >zzz.log
(creates zzz.log with profiling report)

HTH
G.

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

end of thread, other threads:[~2017-09-04 21:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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