From Fedora Project Wiki

Revision as of 23:47, 21 April 2009 by Toshio (talk | contribs) (Draft Compiler Flags changes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Add a paragraph with instructions for adding compiler flags in common circumstances


Compiler flags

Current

Compilers used to build packages should honor the applicable compiler flags set in the system rpm configuration. As of Aug 2006, this means in practice $RPM_OPT_FLAGS/%{optflags} for C, C++, and Fortran compilers. Honoring means that the contents of that variable is used as the basis of the flags actually used by the compiler during the package build. Adding to and overriding or filtering parts of these flags is permitted if there's a good reason to do so; the rationale for doing so should be reviewed and documented in the specfile especially in the override and filter cases.

Addition

Most C, C++, and Fortran programs will pick up the correct compiler flags from the %configure macro. If your program does not use %configure the de facto standard is that C compiler flags are picked up via the CFLAGS make variable, C++ Compiler flags via the CXXFLAGS variable, and Fortran flags via FFLAGS. So, you could have something like this in your spec file:

make CFLAGS=%{optflags} all

If the build still does not pick up the proper compiler flags, you will have to look in the configure script or Makefiles to diagnose what's going on.