AdaCore / gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Other
65 stars 21 forks source link

Library GPR compiler options issue with main program compilation. #137

Closed Blady-Com closed 1 year ago

Blady-Com commented 1 year ago

Here is a weird case of compiler options combined with two levels of GPR files: one on library level and one on main program level.

When I compiled the library all is fine: test_20230204_trans_opt.zip

% gprbuild -f -P alib/alib.gpr  
Compile
   [Ada]          alib.adb
Build Libraries
   [gprlib]       alib.lexch
   [archive]      libalib.a
   [index]        libalib.a

But when I compiled the main program I got an error on library interface file:

% gprbuild -f -P aprog/aprog.gpr
Compile
   [Ada]          aprog.adb
alib.ads:3:35: error: strings are delimited by double quote character
gprbuild: *** compilation phase failed

It is as if the options of the library were not taken into account when withed in the main program.

Of course I can put all the library options in the main GPR but it is annoying to force library's users in that way.

How to specify the library GPR that the options must be enforced for interface files when compiling the main program?

See full example sources in attached archive.

t-14 commented 1 year ago

There is currently no way to control the compilation options of a client of a package from the compilation of the package itself. The compilation of an Ada unit is supposed to be standalone, and gprbuild relies on that. Unfortunately, there are some corner cases where this isn't true, with -gnatW8 indeed being one example. We don't have a solution for that at the moment other than adding -gnatW8 to client projects.