comp.lang.ada
 help / color / mirror / Atom feed
* gprbuild and Linker_Options bug?
@ 2014-03-31 23:21 Qun-Ying
  2014-03-31 23:38 ` Qun-Ying
  2014-04-01  7:41 ` Simon Wright
  0 siblings, 2 replies; 3+ messages in thread
From: Qun-Ying @ 2014-03-31 23:21 UTC (permalink / raw)


With gnat 2013, GPRBUILD GPL 2013 (20130314) (x86_64-pc-linux-gnu)

For this simple program:

a.gpr:
--------
project A is

    for Main use ("main.adb");

    package Linker is
       for Linker_Options use ("-lgs");
    end Linker;

end A;

main.adb:
----------
with Interfaces.C; use Interfaces.C;
with b; use b;

procedure Main is
    revision: aliased revision_t;
    ret : int;
begin
    ret := b.revision (revision'Access, revision'Size / 8);
end Main;

b.ads
---------
-- simple single function binding for gs to illustrate the bug
with Interfaces.C;         use Interfaces.C;
with Interfaces.C.Strings;
with System;

package b is
    type revision_t is limited private;
    function revision (pr : access revision_t; len : int) return int;
    pragma Import (C, revision, "gsapi_revision");

private
    type revision_t is limited record
       product      : Interfaces.C.Strings.chars_ptr;
       copyright    : Interfaces.C.Strings.chars_ptr;
       revision     : long;
       revisiondate : long;
    end record;
    pragma Convention (C_Pass_By_Copy, revision_t);
end b;

When running under gprbuild -P a, It will failed with the following message:
gcc main.o -o main
main.o: In function `_ada_main':
main.adb:(.text+0x21): undefined reference to `gsapi_revision'
collect2: error: ld returned 1 exit status
gprbuild: link of main.adb failed

Where it fails to use the Linker_Options defined in the project file.
But "gnatmake -P a" will build the program without problem.

Is this a known problem? Or something I have missed?

If  added a line of 'pragma Linker_Options ("-lgs")' in b.ads, then
gprbuild could build without problem.

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

* Re: gprbuild and Linker_Options bug?
  2014-03-31 23:21 gprbuild and Linker_Options bug? Qun-Ying
@ 2014-03-31 23:38 ` Qun-Ying
  2014-04-01  7:41 ` Simon Wright
  1 sibling, 0 replies; 3+ messages in thread
From: Qun-Ying @ 2014-03-31 23:38 UTC (permalink / raw)


I think I got it when change the line of Linker_Options to
for Default_Switches ("ada") use ("-lgs");
gprbuild will work.

Qun-Ying wrote:
> package Linker is
>        for Linker_Options use ("-lgs");
>     end Linker;



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

* Re: gprbuild and Linker_Options bug?
  2014-03-31 23:21 gprbuild and Linker_Options bug? Qun-Ying
  2014-03-31 23:38 ` Qun-Ying
@ 2014-04-01  7:41 ` Simon Wright
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Wright @ 2014-04-01  7:41 UTC (permalink / raw)


Qun-Ying <zhu.qunying@gmail.com> writes:

> Where it fails to use the Linker_Options defined in the project file.
> But "gnatmake -P a" will build the program without problem.
>
> Is this a known problem? Or something I have missed?

I think it's a feature.

The gprbuild manual[1] says that the Linker_Options "[v]alue is a list
of switches/options that are to be added when linking an executable from
a project importing the current project directly or indirectly.
Linker_Options are not used when linking an executable from the current
project."

And gprbuild & gnatmake have subtly different rules and capabilities.

[1] http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html

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

end of thread, other threads:[~2014-04-01  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 23:21 gprbuild and Linker_Options bug? Qun-Ying
2014-03-31 23:38 ` Qun-Ying
2014-04-01  7:41 ` Simon Wright

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