Diff for /wikisrc/pkgsrc/gcc.mdwn between versions 1.1 and 1.3

version 1.1, 2017/11/26 01:07:36 version 1.3, 2017/11/26 01:28:44
Line 1 Line 1
 Using gcc in pkgsrc  
   
 On many systems pkgsrc supports, gcc is the standard compiler.  In  On many systems pkgsrc supports, gcc is the standard compiler.  In
 general, different versions of each OS have different gcc versions,  general, different versions of each OS have different gcc versions,
 and some packages require newer GCC versions, in order to support  and some packages require newer gcc versions, in order to support
 newer language standards (e.g. c++11, written in the style of  newer language standards (e.g. c++11, written in the style of
 USE_LANGUAGES), or because older versions don't work (infrequently).  USE_LANGUAGES), or because older versions don't work (infrequently).
   
Line 20  build gcc versions (typically newer vers Line 18  build gcc versions (typically newer vers
 in a compiler within ${PREFIX}, e.g. /usr/pkg/gcc6/bin/gcc.  This  in a compiler within ${PREFIX}, e.g. /usr/pkg/gcc6/bin/gcc.  This
 compiler can then be used to compile other packages.  compiler can then be used to compile other packages.
   
 Issues with using base system gcc are typically that it is too old,  The Issue with using base system gcc is typically that it is too old,
 such as gcc 4.5 with NetBSD 6, which cannot compile c++11.  such as gcc 4.5 with NetBSD 6, which cannot compile c++11.
   
 Issues when using pkgsrc gcc are that  Issues when using pkgsrc gcc are that
Line 45  This section attempts to gather all the  Line 43  This section attempts to gather all the 
   - The set of packages that are needed when building a bootstrap    - The set of packages that are needed when building a bootstrap
     compiler should be minimized.      compiler should be minimized.
   
   - All packages that use C++ should be built with the same compiler version.  
   
   - All packages that use C should have final linking with the highest    - All packages that use C should have final linking with the highest
     version used in any included library.      version used in any included library.
   
     - All packages that use C++ should be built with the same compiler
       version.  Because these in the general case may include C, the
       version used for C++ must be at least as new as the version used
       for any used C package.
   
   - pkgsrc should avoid building gcc unless it is more or less    - pkgsrc should avoid building gcc unless it is more or less
     necessary to build packges.  (As an example, if the base system      necessary to build packges.  (As an example, if the base system
     gcc can build c99 but not c++11, building a c99-only program      gcc can build c99 but not c++11, building a c99-only program
     should not trigger building a gcc version adequate for c++11.)      should not trigger building a gcc version adequate for c++11.)
   
   - The compiler selection logic should work on NetBSD 6, and in-use    - The compiler selection logic should work on NetBSD 6 and newer,
     (including LTS) GNU/Linux systems.  It is desirable for this logic      and other systems currently supported by pkgsrc, including in-use
     to work on NetBSD 5.      LTS GNU/Linux systems.  It should work on systems that default to
       clang, when set to use GCC, at least as well as the current
       scheme.  It is desirable for this logic to work on NetBSD 5.
   
   - The compiler selection logic should be understandable and not brittle.    - The compiler selection logic should be understandable and not brittle.
   
 ## Design  ## Design
   
 The above requirements could in theory be satisfied in many ways, but  The above requirements could in theory be satisfied in many ways, but
 most of them are too complicated.  most of them are too complicated.  We present a design that aims to be
   sound while mimimizing complexity.
   
   - Packages declare what languages they need, with c++, c++11, and    - Packages declare what languages they need, with c++, c++11, and
     c++14 being expressed differently.      c++14 being expressed differently.  (This is exactly current
       practice and just noted for completeness.)
   
   - The package-settable variable GCC_REQD will be used only when a    - The package-settable variable GCC_REQD will be used only when a
     compiler that generally can compile the declared language version      compiler that generally can compile the declared language version
     is insufficient.  These cases are expected to be relatively rare.      is insufficient.  These cases are expected to be relatively rare;
       an example is firefox that is in c++ (but not c+11) and needs gcc
       4.9.
   
   - A user-settable variable PKGSRC_GCC_VERSION will declare the    - A user-settable variable PKGSRC_GCC_VERSION will declare the
     version of gcc to be used for C programs, with an OS- and      version of gcc to be used for C programs, with an OS- and
Line 95  most of them are too complicated. Line 102  most of them are too complicated.
     package building will fail.  We call the resulting      package building will fail.  We call the resulting
     PKGSRC_GCC_VERSION or PKGSRC_GXX_VERSION the chosen version.      PKGSRC_GCC_VERSION or PKGSRC_GXX_VERSION the chosen version.
   
   - When building a program using C or C++, the chosen version is not    - When building a program using C or C++, if the chosen version is
     provided by the base system, and the chosen version is not      not provided by the base system, and the chosen version is not
     installed via pkgsrc, then it (and its dependencies) will be built      installed via pkgsrc, then it (and its dependencies) will be built
     from pkgsrc in a special bootstrap mode.  When building in      from pkgsrc in a special bootstrap mode.  When building in
     bootstrap mode, the version selection logic is ignored and the      bootstrap mode, the version selection logic is ignored and the
Line 121  most of them are too complicated. Line 128  most of them are too complicated.
     approach is possible inconsistency with gcc's dependencies being      approach is possible inconsistency with gcc's dependencies being
     built with the base compiler and used later.      built with the base compiler and used later.
   
     - We hope that the chosen version can be built using the base system
       version, and hope to avoid multi-stage bootstrapping.
   
   - We expect that any program containing C++ will undergo final    - We expect that any program containing C++ will undergo final
     linking with a C++ compiler.  This is not a change from the      linking with a C++ compiler.  This is not a change from the
     current situation.      current situation.
Line 141  exist. Line 151  exist.
 \todo: Discuss adjusting options to minimize dependencies, including  \todo: Discuss adjusting options to minimize dependencies, including
 gcc-inplace-math and nls.  gcc-inplace-math and nls.
   
   ### Differing GCC and GXX versions
   
   Perhaps it is a mistake to allow the chosen GCC and GXX versions to
   differ.  If we require them to be the same, then essentially all
   systems with a base system compiler older than gcc 5 will have to
   bootstrap the compiler.  For now, we allow them to differ and will
   permit the defaults to differ.
   
 ### Default versions for various systems  ### Default versions for various systems
   
 Note that if any particular system (or bulk build), a newer gcc has to  Note that if for any particular system's set of installed packages (or
 be built, it does not hurt incrementally to have built it earlier.  bulk build), a newer gcc has to be built, it does not hurt to have
   built it earlier.
   
 When the base system is old (e.g., gcc 4.5 in NetBSD 6, or 4.1, in  When the base system is old (e.g., gcc 4.5 in NetBSD 6, or 4.1, in
 NetBSD 5), then it is clear that a newer version must be built.  For  NetBSD 5), then it is clear that a newer version must be built.  For
 these, PKGSRC_GXX_VERSION should default to a newish gcc, avoiding  these, PKGSRC_GXX_VERSION should default to a newish gcc, avoiding
 being so new as to cause building issues.  Currently, gcc6 is probably  being so new as to cause building issues.  Currently, gcc6 is probably
 a good choice.  PKGSRC_GCC_VERSION should probably default to the  a good choice.  PKGSRC_GCC_VERSION should probably default to the
 system version if it can build C99, or match PKGSRC_GXX_VERSION, if  system version if it can build all C99 programs, or match
 the system version is too old.  Perhaps gcc 4.5 would be used, but 4.1  PKGSRC_GXX_VERSION, if the system version is too old.  Perhaps gcc 4.5
 not used.  \todo Discuss.  would be used, but 4.1 not used.  \todo Discuss.
   
 When the base system is almost new enough, the decision about the  When the base system is almost new enough, the decision about the
 default is more complicated.  A key example is gcc 4.8, found in  default is more complicated.  A key example is gcc 4.8, found in
 NetBSD 7.  Firefox requires gcc 4.9 (\todo because the c++11 support  NetBSD 7.  Firefox requires gcc 4.9, and all programs using c++14 also
 in 4.8 is not quite good enough), and all programs using c++14 also  
 need a newer version.  One options is to choose 4.8, resulting in  need a newer version.  One options is to choose 4.8, resulting in
 firefox failing, as well as all c++14 programs.  Another is to choose  firefox failing, as well as all c++14 programs.  Another is to choose
 4.9, but this makes little sense because c++14 programs will still  4.9, but this makes little sense because c++14 programs will still
Line 173  used.  By "new enough", we mean that alm Line 191  used.  By "new enough", we mean that alm
 to build with it, which implies that it supports (almost all) C++14  to build with it, which implies that it supports (almost all) C++14
 programs.   Our current definiton of new enough is gcc 5.  programs.   Our current definiton of new enough is gcc 5.
   
   ### Limited mixed versions
   
   One approach would be to allow limited mixed versions, where
   individual programs could force a specific version to be bootstrapped
   and used, so that e.g. firefox could use 4.9 even though most programs
   use 4.8, which is what happens now on NetBSD 7.  This would rely on
   being able to link c++ with 4.9 including some things built with 4.8
   (which is done presently).  However, this approach would become
   unsound with a library rather than an end program.  We reject this as
   too much complexity for avoiding building a newer compiler in limited
   situations.
   
 ### Fortran  ### Fortran
   
 Fortran support is currently somewhat troubled..  It seems obvious to  Fortran support is currently somewhat troubled..  It seems obvious to
Line 198  not worsened by the above design.  \todo Line 228  not worsened by the above design.  \todo
    is the base system version if >= 4.5 (or 4.4?), and otherwise 6,     is the base system version if >= 4.5 (or 4.4?), and otherwise 6,
    and that PKGSRC_GXX_VERSION is the base system version if >= 5, and     and that PKGSRC_GXX_VERSION is the base system version if >= 5, and
    otherwise 6.     otherwise 6.
   
   ### Later steps
   
    - Address fortran.

Removed from v.1.1  
changed lines
  Added in v.1.3


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb