From d44be71e50f0b927590590f6da9b466df0bb9a77 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Aug 22 2024 16:19:48 +0000 Subject: [PATCH 1/5] Removed the "opt" part of two macro names. Since the macro optflags is deprecated in favor of build_*flags, a corresponding change has been made to two macros for Ada packages. --- diff --git a/guidelines/modules/ROOT/pages/Ada.adoc b/guidelines/modules/ROOT/pages/Ada.adoc index 30f69c5..6e099f2 100644 --- a/guidelines/modules/ROOT/pages/Ada.adoc +++ b/guidelines/modules/ROOT/pages/Ada.adoc @@ -20,8 +20,8 @@ and the link:../ReviewGuidelines/[Review Guidelines]. 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 there are the macros - +++Gnatmake_optflags+++ - and +++GPRbuild_optflags+++, + +++Gnatmake_flags+++ + and +++GPRbuild_flags+++, which contain builder, compiler and linker flags. ** In case a package’s build system invokes the underlying GNAT tools without using Gnatmake or GPRbuild, From d44ce8465214fc46dc49358c6a8b9a97af10c05b Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Aug 22 2024 16:19:48 +0000 Subject: [PATCH 2/5] Dropped "starting with Fedora 18". Fedora 17 and earlier are no longer a concern. --- diff --git a/guidelines/modules/ROOT/pages/Ada.adoc b/guidelines/modules/ROOT/pages/Ada.adoc index 6e099f2..e688cbc 100644 --- a/guidelines/modules/ROOT/pages/Ada.adoc +++ b/guidelines/modules/ROOT/pages/Ada.adoc @@ -52,7 +52,7 @@ the macro +++make_install+++ (*not* +++makeinstall+++) is recommended. * The macro +++GNAT_arches+++ expands 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}+`”. From 37f68b08532a01702ba48b957fe872f77f6ce97a Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Aug 22 2024 16:19:48 +0000 Subject: [PATCH 3/5] Made GPRbuild more prominent in the Ada guidelines. GPRbuild has almost entirely superseded Gnatmake, so let's mention it first and note the need to buildrequire it. GPRbuild_arches should have been mentioned ten years ago. --- diff --git a/guidelines/modules/ROOT/pages/Ada.adoc b/guidelines/modules/ROOT/pages/Ada.adoc index e688cbc..451beb4 100644 --- a/guidelines/modules/ROOT/pages/Ada.adoc +++ b/guidelines/modules/ROOT/pages/Ada.adoc @@ -14,17 +14,19 @@ and the link:../ReviewGuidelines/[Review Guidelines]. 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 - +++Gnatmake_flags+++ - and +++GPRbuild_flags+++, + +++GPRbuild_flags+++ + and +++Gnatmake_flags+++, 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 +++Gnatlink_flags+++ shall be passed to it. @@ -50,12 +52,14 @@ If needed, a different target and/or additional variables may be appended: For the installation stage of Comfignat-using packages, the macro +++make_install+++ (*not* +++makeinstall+++) is recommended. -* The macro +++GNAT_arches+++ expands to a list of architectures +* The macros +++GPRbuild_arches+++ and +++GNAT_arches+++ +expand to a list of architectures where GNAT packages are available in Fedora. 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,11 @@ to ensure that the necessary RPM macros are defined. 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. == 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 +80,7 @@ but run during the build and need to link to the library in the build directory, and they may rely on an automatic runpath for this. In those cases the spec file may define a macro named +++GNAT_add_rpath+++. -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 +++GNAT_add_rpath+++ is defined. From 07ab5eb76f7a6fb7c6acf8e3fd7bb3125e9b80f7 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Aug 22 2024 16:19:48 +0000 Subject: [PATCH 4/5] Added GPRinstall_flags to the Ada guidelines. --- diff --git a/guidelines/modules/ROOT/pages/Ada.adoc b/guidelines/modules/ROOT/pages/Ada.adoc index 451beb4..daf1ebf 100644 --- a/guidelines/modules/ROOT/pages/Ada.adoc +++ b/guidelines/modules/ROOT/pages/Ada.adoc @@ -179,6 +179,10 @@ The name of the library *MUST* be included either in the name of each project file or in the name of the subdirectory where the project files are placed. +Packages that use GPRinstall in the installation phase +can use the macro +++GPRinstall_flags+++ +to pass the correct pathnames and other parameters to GPRinstall. + == Rpmlint and Ada packages Rpmlint is a program that checks packages for common problems. From bfd2c6d93b54245d5c6f7bd0445c6d37e38a27e6 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Aug 22 2024 16:19:48 +0000 Subject: [PATCH 5/5] Updated the guidance about trampolines in Ada. The usage of trampolines has been greatly reduced, and those cases that remain can't just be ignored as 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. --- diff --git a/guidelines/modules/ROOT/pages/Ada.adoc b/guidelines/modules/ROOT/pages/Ada.adoc index daf1ebf..a8959f8 100644 --- a/guidelines/modules/ROOT/pages/Ada.adoc +++ b/guidelines/modules/ROOT/pages/Ada.adoc @@ -69,6 +69,31 @@ then it’s probably best to use that if possible. If not, it is recommended that the packager write a GNAT project file 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 GPRbuild adds a runpath to the built binaries by default. @@ -182,13 +207,3 @@ or in the name of the subdirectory where the project files are placed. Packages that use GPRinstall in the installation phase can use the macro +++GPRinstall_flags+++ to pass the correct pathnames and other parameters to GPRinstall. - -== 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].)