Bug 691558 - Define compilation flags to be used with GPRbuild.
Define compilation flags to be used with GPRbuild.
Product: Fedora
Classification: Fedora
Component: fedora-gnat-project-common (Show other bugs)
All All
unspecified Severity high
: ---
: ---
Assigned To: Björn Persson
Fedora Extras Quality Assurance
: Improvement, Reopened
Depends On:
  Show dependency treegraph
Reported: 2011-03-28 16:06 EDT by Pavel Zhukov
Modified: 2011-05-04 12:48 EDT (History)
2 users (show)

See Also:
Fixed In Version: fedora-gnat-project-common-2.2-1.fc15
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2011-05-04 12:48:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Pavel Zhukov 2011-03-28 16:06:15 EDT
Description of problem:
%GNAT_optflags contains strange and unusable compilation flags

Version-Release number of selected component (if applicable):

How reproducible:
Try compile any Ada source with gprbuild and %GNAT_optflags
Actual results:
fail to compile (even if cargs used) because some of flags are absolutely strange for ada.

Expected results:
Successfully compilation

Additional info:
Comment 1 Pavel Zhukov 2011-03-28 16:11:05 EDT
Please separate flags for gnatmake/gprbuild from gcc flags if possible
Comment 2 Björn Persson 2011-03-28 18:38:30 EDT
I defined GNAT_optflags by simply removing the one parameter in optflags that Gnatmake didn't like and then adding some Gnat-specific ones that I found useful. If GPRbuild doesn't take the same parameters as Gnatmake, then there should probably be another RPM macro with GPRbuild parameters.

I'll look into this, but not this night. You can help by explaining which parameters shouldn't be used, what they do and why they are bad for Ada.
Comment 3 Pavel Zhukov 2011-03-29 14:29:07 EDT
%ada_optflags %(echo '%{optflags}' | sed 's/-Wall//' | sed 's/--param=ssp-buffer-size=[0-9]*//g' | sed 's/-pipe//'| sed 's/-Wp\,-D_FORTIFY_SOURCE=2//')

%GNAT_optflags  -R -p -XHARDWARE_PLATFORM=%{_arch}  -cargs %{ada_optflags}

In /etc/rpm/macros.gnat works for me. But we should add smp_optflags. 

I patch Makefile(-s) for gprbuild -Pproject_name ${GNATFLAGS}
Comment 4 Vadim Godunko 2011-03-30 03:53:07 EDT
I suggest to use -cargs:ada for gprbuild and -cargs for gnatmake. Use of -cargs for gprbuild is not recommended, because specified parameters are passed to all compilers not to GNAT only. As result, gprbuild will can't build mixed languages projects.
Comment 5 Pavel Zhukov 2011-03-31 01:37:53 EDT
Can you add me to co-mointainers of fedora-gnat-project-common ?
Comment 6 Björn Persson 2011-04-01 19:48:43 EDT
In order to support multiple languages I suppose we should also include the optflags for C with -cargs:C, and similarly for other languages. Something like this maybe:

%GPRbuild_optflags -cargs:Ada %{Ada_optflags} -cargs:C %{optflags} -cargs:Fortran %{optflags} -gargs -R -p -XHARDWARE_PLATFORM=%{_arch}

The Fortran guidelines require that optflags be used unmodified. Do you guys know if there is a version of optflags adapted for C++?

(In reply to comment #5)
> Can you add me to co-mointainers of fedora-gnat-project-common ?

I'll give you commit access if you apply in the package database, but please discuss with me before you make any nontrivial changes.
Comment 7 Björn Persson 2011-04-03 08:50:42 EDT
Actually it seems like optflags can be used unmodified if prefixed with -cargs. This works for me with both Gnatmake and GPRbuild:

%GNAT_builder_flags %{?_smp_mflags} -R -p -XHARDWARE_PLATFORM=%{_arch}

%GNAT_optflags -cargs %{optflags} -margs %{GNAT_builder_flags}

(I tested it by rebuilding Mine Detector in Fedora 15 on i386, substituting gprbuild for gnatmake in the spec file.)

-Wall is actually documented in the GNAT User's Guide under Switches for gcc. -Wp is of course irrelevant for Ada and -pipe may not do much, but I can't see that they do any harm so writing code to filter them out would just add unnecessary complexity. Thus it currently appears that the same compiler parameters shall be passed for all languages, so -cargs will do for both Gnatmake and GPRbuild. If we need to add any Ada-specific parameters we should use -cargs:Ada for those, but let's not make this more complicated than it needs to be.
Comment 8 Fedora Update System 2011-04-03 11:42:54 EDT
fedora-gnat-project-common-2.2-1.fc15 has been submitted as an update for Fedora 15.
Comment 9 Vadim Godunko 2011-04-04 07:02:05 EDT
You miss one important point: gprbuild can be used to any languages, not only for that is come with gcc. It is actually used by several Ada packages (Auto_Text_IO and QtAda are examples) in this way.
Comment 10 Fedora Update System 2011-04-05 16:25:31 EDT
Package fedora-gnat-project-common-2.2-1.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing fedora-gnat-project-common-2.2-1.fc15'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 11 Björn Persson 2011-04-06 19:36:04 EDT
(In reply to comment #9)
> You miss one important point: gprbuild can be used to any languages, not only
> for that is come with gcc. It is actually used by several Ada packages
> (Auto_Text_IO and QtAda are examples) in this way.

I'd like to look at the examples. Which file in the QTada source tree should I look at?

I don't see any references to GPRbuild in Auto_Text_IO 3.05.
Comment 12 Björn Persson 2011-04-13 20:57:13 EDT
I just discovered that moving -g into -cargs causes the binder files to be left out from debuginfo packages because Gnatlink deletes them. I should push another update to pass -g to Gnatlink, but I need to check first what -largs -g does with GPRbuild.
Comment 13 Fedora Update System 2011-04-15 17:16:01 EDT
fedora-gnat-project-common-2.2-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 14 Björn Persson 2011-04-15 18:54:51 EDT
Just as the beta freeze is lifted and 2.2 is finally pushed to the stable repository, I have submitted 2.3 to get the missing binder files back.

I'm also working on a bigger set of changes that includes using -cargs:<language> for GPRbuild. I'll keep this bug open until those changes are done.
Comment 15 Björn Persson 2011-05-04 12:48:19 EDT
Version 3.1 is now in Rawhide. It has separate Gnatmake_optflags and GPRbuild_optflags, and should work with compilers that don't understand GCC's parameters.

I can make a version 2.4 for Fedora 15 if there's a need to package anything that uses GPRbuild with a non-GCC compiler. Otherwise 2.3 will do for Fedora 15.

Note You need to log in before you can comment on or make changes to this bug.