#1387 Update Ada packaging guidelines
Merged 5 months ago by james. Opened 5 months ago by rombobeorn.
rombobeorn/packaging-committee master  into  master

@@ -14,17 +14,19 @@ 

    the default Ada compiler in Fedora.

    All packages that contain Ada code *MUST* have “`+BuildRequires: gcc-gnat+`”

    to ensure that the compiler is available.

+ * The GNAT tools are usually invoked through the builder GPRbuild,

+   so Ada packages typically need “`+BuildRequires: gprbuild+`”.

  * There are a number of RPM macros that contain

    Fedora’s standard compiler and linker flags adapted for GNAT.

    The appropriate macro *MUST* be used in the build stage.

    The right macro to use depends on what build tools the package uses.

- ** For packages that are built with Gnatmake or GPRbuild but without Comfignat

+ ** For packages that are built with GPRbuild or Gnatmake but without Comfignat

     there are the macros

-    +++<var>Gnatmake_optflags</var>+++

-    and +++<var>GPRbuild_optflags</var>+++,

+    +++<var>GPRbuild_flags</var>+++

+    and +++<var>Gnatmake_flags</var>+++,

     which contain builder, compiler and linker flags.

  ** In case a package’s build system invokes the underlying GNAT tools

-    without using Gnatmake or GPRbuild,

+    without using GPRbuild or Gnatmake,

     then the appropriate macro for each tool *MUST* be used.

     If for example Gnatlink is invoked directly,

     then the expansion of +++<var>Gnatlink_flags</var>+++ shall be passed to it.
@@ -50,12 +52,14 @@ 

  For the installation stage of Comfignat-using packages,

  the macro +++<var>make_install</var>+++ (*not* +++<var>makeinstall</var>+++)

  is recommended.

- * The macro +++<var>GNAT_arches</var>+++ expands to a list of architectures

+ * The macros +++<var>GPRbuild_arches</var>+++ and +++<var>GNAT_arches</var>+++

+ expand to a list of architectures

  where GNAT packages are available in Fedora.

- Starting with Fedora 18, when there is a need to prevent attempts

+ When there is a need to prevent attempts

  to build an Ada package on secondary architectures

  where GNAT has not been bootstrapped,

- this *MUST* be done with “`+ExclusiveArch: %{GNAT_arches}+`”.

+ this *MUST* be done with either “`+ExclusiveArch: %{GPRbuild_arches}+`”

+ or “`+ExclusiveArch: %{GNAT_arches}+`”.

  * All packages that contain Ada code *MUST* have

  “`+BuildRequires: fedora-gnat-project-common+`”

  to ensure that the necessary RPM macros are defined.
@@ -63,11 +67,36 @@ 

  for example a GNAT project file or makefiles and a configuration script,

  then it’s probably best to use that if possible.

  If not, it is recommended that the packager write a GNAT project file

- to control the compilation.

+ and use GPRbuild to control the compilation.

+ 

+ === Trampolines

+ 

+ An executable stack has been made a linker error in Fedora.

+ This can affect Ada packages because

+ https://gcc.gnu.org/onlinedocs/gccint/Trampolines.html[GCC uses trampolines]

+ to implement some language constructs.

+ The compiler’s usage of trampolines has been greatly reduced, but

+ https://gcc.gnu.org/onlinedocs/gnat_rm/No_005fImplicit_005fDynamic_005fCode.html[some cases remain].

+ One case that occurs is

+ when a nested subprogram in Ada

+ is passed as a callback routine

+ to a function written in C –

+ which means that the executable stack is also exposed to C code

+ that may contain buffer overflows.

+ In such cases the options are

+ to explicitly allow an executable stack

+ by passing “`+-largs -Wl,--no-warn-execstack+`” to GPRbuild,

+ or restructure the code to eliminate the need for trampolines.

+ Which option is best may depend on

+ how exposed the program is to potentially hostile input.

+ 

+ Correct usage of the RPM macros

+ should result in a warning message from the compiler

+ that points out where in the code a trampoline is needed.

  

  == Runpaths

  

- Gnatmake and GPRbuild both add a runpath to the built binaries by default.

+ GPRbuild adds a runpath to the built binaries by default.

  Fedora’s builder flags normally include an option

  to disable the automatic runpath.

  There are however cases where it would be advantageous to allow a runpath.
@@ -76,7 +105,7 @@ 

  and they may rely on an automatic runpath for this.

  In those cases the spec file may define a macro named

  +++<var>GNAT_add_rpath</var>+++.

- The builders will then be allowed to add a runpath

+ The builder will then be allowed to add a runpath

  in those parts of the spec file where

  +++<var>GNAT_add_rpath</var>+++ is defined.

  
@@ -175,12 +204,6 @@ 

  either in the name of each project file

  or in the name of the subdirectory where the project files are placed.

  

- == Rpmlint and Ada packages

- 

- Rpmlint is a program that checks packages for common problems.

- For Ada packages,

- some of the rpmlint messages, such as “executable-stack”,

- can be disregarded,

- because GNAT uses trampolines for pointers to nested functions.

- (See for example

- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24355[this entry in the GCC Bugzilla].)

+ Packages that use GPRinstall in the installation phase

+ can use the macro +++<var>GPRinstall_flags</var>+++

+ to pass the correct pathnames and other parameters to GPRinstall.

The Ada packaging guidelines have grown a bit stale and need some updates.

  • The guidance about trampolines in Ada needs to be updated. GCC's usage of trampolines has been greatly reduced, and those cases that remain can't just be ignored now that an executable stack has been made an error. Advice on how to handle them belongs in the section on compilation rather than the one about RPMlint.

  • I'm not aware of any other RPMlint warnings that should be ignored as a rule, so the section about RPMlint becomes empty and is thus removed.

  • Since the macro optflags is deprecated in favor of build_*flags, a corresponding change has been made to two macros for Ada packages. The policy should be updated with the new names.

  • GPRbuild has almost entirely superseded Gnatmake, so let's mention it more prominently.

  • The macro GPRbuild_arches should have been mentioned ten years ago. It seems to have been forgotten.

  • A macro named GPRinstall_flags has been added. Using it should not be mandatory, but it would be nice to mention it in the guidelines. (What's mandatory is to put files in the right directories.)

  • The words "starting with Fedora 18" can be dropped because Fedora 17 and earlier are no longer a concern.

rebased onto 502cfe3

5 months ago

+1

I have to admit that I thought "comfignat" was a typo. Even adaic.org gets it wrong as https://www.adaic.org/ada-resources/tools-libraries has it listed under "confignat".

rebased onto aee8da2

5 months ago

Commit fc234cd fixes this pull-request

Pull-Request has been merged by james

5 months ago

Pull-Request has been merged by james

5 months ago
Metadata