AIX Open Source

AIX GCC multi version support improvements

By SANGAMESH MALLAYYA posted 10 days ago

  

This blog post provides an overview of improved multi version gcc support for AIX Toolbox. 

Currently AIX Toolbox provides an option to install multiple versions of gcc at the same time.

Support was provided for gcc-6 and gcc-7 with the package naming as gccX-6.3.0,

where X is the gcc major version 6 or 7, and 6.3.0 is the gcc-6 minor version number.

The default latest gcc version available in AIX Toolbox is gcc-8.3.0 without the multi version support.

 

The binaries and libraries installed were with gccX path.

/opt/freeware/gccX/bin,

/opt/freeware/gccX/lib

 

To compile programs with gccX one has to use the path.

/opt/freeware/gccX/bin/gcc

And the compiled application would have the library search path as 

/opt/freeware/gccX/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0:/opt/freeware/gccX/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/../../..:/usr/lib:/lib

 

The drawbacks with the current approach is that,

  1. If there is a minor version update, for example, from gcc6-6.3.0 to gcc6-6.4.0 then the applications which compiled with older gccX has to be recompiled or LIBPATH environment variable to point to the latest gccX libpath needs to be used as a workaround if the application links to any of the gcc library.
  2. For future long term support, the current approach isn’t feasible and maintenance would be an issue.                                                                                                          

  

To overcome the existing limitation new approach has been used.

Now the gcc packages have been split into two types: ,

  1. The existing gccX(gcc8-8.3.0) packages providing the GCC version X. It can be installed in parallel with other gccX.
  2. gcc packages providing the default GCC, the one used to compile other RPMs. This package is a meta-package having only requirements on its corresponding gccX package and creating links for binaries and libraries. 

          In order to simplify everything, gcc doesn't have minor versions anymore.

          These are managed in gccX packages, which, then, can be upgraded independently.

 

Currently, the default metapackage gcc(gcc-8-1) is for package gcc8(gcc8-8.3.0-4).

Most of the time, users  need to install gcc and the correct gccX will be included as a dependency.

Note that the Epoch inside the default gcc-8-1 RPM has been incremented to override the existing gcc-8.3.0

 

If you're planning to install another gccX, you have to take care about a few things.

 

The default gcc can't be uninstalled nor changed as it's providing the libgcc needed by most of our programs.

Applications compiled with default gcc should continue to work even after update to gccX.

Be careful when changing the LIBPATH in built binaries and libraries. It must first search for its own version libraries (under /opt/freeware/lib/gcc/powerpc-ibm-aix*/X/...),

before searching in the default path (/opt/freeware/lib).

   

Binaries are now suffixed with the version. In order to compile with GCC version 7, one must call gcc-7 or g++-7.
With the default gcc(gcc-8-1) one can either call gcc-8 or just gcc binary.

The compiled application libpath now looks like this.

/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/7:/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/7/../../..:/opt/freeware/lib:/usr/lib:/lib

 

NOTE:

  1. If the existing gccX is already installed, then one can update to new gccX package.
  2. If the existing applications have been compiled with gccX and have a dependency on gcc libraries, then one needs to use the LIBPATH to make them work with latest gccX package.

           For example.

           If the existing application have path like this.

          0      /opt/freeware/gcc6/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0:/opt/freeware/gcc6/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/../../..:/usr/lib:/lib

          1                                    libc.a              shr.o

          2                                    libstdc++.a         libstdc++.so.6

          3                                    libgcc_s.a          shr.o

 

          Then use the LIBPATH to point to the latest gccX.

 

          For gcc6:

         LIBPATH=/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6:/opt/freeware/lib:/usr/lib:/lib  ./a.out  or

         LIBPATH=/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0:/opt/freeware/lib:/usr/lib:/lib ./a.out

 

         For gcc7:

         LIBPATH=/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/7: /opt/freeware/lib:/usr/lib:/lib ./a.out

 

         This workaround is required only in case if the applications are compiled with old gccX

         multi version approach and installed newly adopted multi version gccX package.

         

         The applications compiled with the default gcc then there is no change in library path

          is needed and they continue to work even after update to gccX.

 

  1. gcc-6 doesn’t provide the configuration option to compile with major version number support.

          But tweaks have been done and proper soft links are created to make gcc6 work

          with this new approach.

 

          Compiled application will still have the minor version number in it’s libpath.

          /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6.3.0/../../..:/usr/lib:/lib

 

          But the actual libraries are installed under /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/6.

          Required 6.3.0 soft link will be created in /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0 &      

          /opt/freeware/libexec/gcc/powerpc-ibm-aix7.1.0.0

 

 

  1. If you see any conflict error like below with the existing installed gcc-8.3.0-2 while trying to install multi version gccX (gcc6 or gcc7).

 

           file /opt/freeware/libexec/gcc from install of gcc6-6.3.0-2.ppc conflicts with file from package gcc-cpp-8.3.0-2.ppc

           file /opt/freeware/libexec/gcc/powerpc-ibm-aix7.1.0.0 from install of gcc6-6.3.0-2.ppc conflicts with file from package gcc-cpp-8.3.0-2.ppc

 

          Please update the gcc to default metapackage gcc(gcc-8-1) first and then try installing the gccX.

 

0 comments
169 views

Permalink