Everyday DevOps: building gcc 9.3.1 for CentOS 8

Severstal has implemented large corporate systems such as SAP or QMET, but there are also many different tasks that our own development covers, and the tasks of this development are rarely simple. This means that the requirements for development tools are quite specific. What if your developers need gcc-9 on CentOS and it is not in the public repositories? Roll up your sleeves and create the required bags, of course. But this task looks simple only at first glance. 





If you are wondering what rakes are laid out on the way to replacing the system compiler, and how we dealt with them, welcome to cat. 





Stage 1. The actual assembly of gcc 

It would seem that everything is simple here: take gcc.spec from the gcc-8.3.1 package, change 8 to 9, run rpmbuild –bb, how long are we waiting? Yes, but no. To begin with, you will have to revise and correct all the patches, and at the same time also install binutils fresher, since it is not difficult. Then, we don't just change the compiler, give us some more nvptx-tools, which means that when the build is over and testing starts, the tests in libgomp, tied to unloading the code, will start to hang and get stuck in various strange poses ... 





There can be two solutions here: 





  1. Conservative: tell the developers "sorry, I couldn't do it" and disable nvptx-tools. 





  1. : ,  nvptx  ,  rpmbuild, .  tests failed  , . 





Stage 2. Package libgcc.i686 has inferior architecture 

,      gcc-9.3.1-3.el8.x86_64.rpm, gcc-offload-nvptx-9.3.1-3.el8.x86_64.rpm  ..  ..   ,  ,   /etc/yum.repos.d,  dnf update β€¦ , ,  ? . , 64-  Debian  RedHat   x86 32- ( ,  multilib),   multilib    32- , (libgcc.i686, libgfortran.i686, libgomp.i686, libquadmath.i686  libstdc++.i686) . , : 





  1. :  mock      i686, (nvptx, , ). 





  1. : , 32- 64-,      .  gcc.spec  ,  .  gcc.spec  libgcc-i686.spec, %build, %install  : 





%install 

rm -rf %{buildroot} 

mkdir -p %{buildroot} 

tar cf - -C %{_buildrootdir}/%{name}-%{version}-%{release}.x86_64 usr | tar xf - -C %{buildroot} 

 

FULLPATH=%{buildroot}%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major} 

FULLEPATH=%{buildroot}%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_major} 

 

# fix some things 

mkdir -p %{buildroot}/%{_lib} 

mv -f %{buildroot}%{_prefix}/%{_lib}/libgcc_s.so.1 %{buildroot}/%{_lib}/libgcc_s-%{gcc_major}-%{DATE}.so.1 

chmod 755 %{buildroot}/%{_lib}/libgcc_s-%{gcc_major}-%{DATE}.so.1 

ln -sf libgcc_s-%{gcc_major}-%{DATE}.so.1 %{buildroot}/%{_lib}/libgcc_s.so.1 

 

mkdir -p %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib} 

mv -f %{buildroot}%{_prefix}/%{_lib}/libstdc++*gdb.py* \ 

      %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/ 

pushd %{name}-%{version}-%{DATE}/libstdc++-v3/python 

 

for i in `find . -name \*.py`; do 

  touch -r $i %{buildroot}%{_prefix}/share/gcc-%{gcc_major}/python/$i 

done 

touch -r hook.in %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/libstdc++*gdb.py 

popd 

 

for f in `find %{buildroot}%{_prefix}/share/gcc-%{gcc_major}/python/ \ 

       %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/ -name \*.py`; do 

  r=${f/$RPM_BUILD_ROOT/} 

  %{__python3} -c 'import py_compile; py_compile.compile("'$f'", dfile="'$r'")' 

  %{__python3} -O -c 'import py_compile; py_compile.compile("'$f'", dfile="'$r'")' 

done 

 

rm -rf %{buildroot}%{_prefix}/%{_lib}/%{name} 
      
      



 rpmbuild β€“bb libgcc-i686.spec - ,  gcc   torture,  ,  32- ( , $RPM_BUILD_ROOT/RPMS/i686).  , ,  dnf makecache β€“repo gcc-9 && dnf update β€¦ , . 





Stage 3. Annobin  libtool 

,    RHEL  CentOS, ,  gcc   annobin.  , .  annobin.spec  , , : ,  gcc 8.3.1,   gcc,  gcc < %{gcc_next}   gcc <= %{gcc_next}, ,  gcc,  ,  gcc < %{gcc_next}    %undefine _annotated_build β€“ . ,  _annotated_build  , (  ) . 





 libtool.   gcc,  , ,  libtool   gcc,   gcc   gcc-9. 





, . , , , ( dnf downgrade gcc),  . 





-, ? 








All Articles