Bug #115484 Missing BuildRequires for gcc-toolset-12 in mysql.spec.in for 9.0.0+
Submitted: 2 Jul 7:21 Modified: 27 Aug 23:39
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:9.0.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: repeatable builds, rpm

[2 Jul 7:21] Simon Mudd
Description:
Building MySQL 9.0.0 rpms from source seems to have missing BuildRequires: dependencies vs 8.0.37 builds.

I see the rpm spec file template setup changes to use gcc-toolset-13 instead of gcc-toolset-12 used in 8.0. However, you still need to build the 8.0 lib-compat libraries and if the gcc-toolset-12 rpms are required to do this and are not added to the build environment then the build will fail.

I notice that trying to build from a clean ol9 docker image the build fails if I don't pre-install the gcc-toolset-12 rpms. These are NOT mentioned in the spec file's BuildRequires: section and the build failure code explicitly says that gcc-toolset-12 rpms are needed.

How to repeat:
Build from an empty container, ensure that only the BuildRequires rpms are installed

building shows:

~/rpmbuild/BUILD/mysql-9.0.0/mysql-8.0.37 ~/rpmbuild/BUILD/mysql-9.0.0
+ mkdir build
+ pushd build
~/rpmbuild/BUILD/mysql-9.0.0/mysql-8.0.37/build ~/rpmbuild/BUILD/mysql-9.0.0/mysql-8.0.37 ~/rpmbuild/BUILD/mysql-9.0.0
+ cmake .. -DBUILD_CONFIG=mysql_release -DINSTALL_LAYOUT=RPM -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMYSQL_MAINTAINER_MODE=0 '-DCMAKE_C_FLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe
 -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x8
6-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' '-DCMAKE_CXX_FLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-sec
urity -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64-v2 -mtune=generic -f
asynchronous-unwind-tables -fstack-clash-protection -fcf-protection' -DWITH_SYSTEMD=0 -DWITH_BOOST=../boost -DWITH_ROUTER=0 -DWITH_AUTHENTICATION_CLIENT_PLUGINS=0 -DWITHOUT_SERVER=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql
/mysql.sock -DMYSQLX_UNIX_ADDR=/var/run/mysqld/mysqlx.sock '-DCOMPILATION_COMMENT=MySQL Community - GPL' '-DCOMPILATION_COMMENT_SERVER=MySQL Community Server - GPL' -DMYSQL_SERVER_SUFFIX=
-- Running cmake version 3.26.5
-- Found Git: /usr/bin/git (found version "2.43.5")
-- This is .el9. as found from 'rpm -qf /'
-- Looking for a devtoolset compiler
CMake Warning at CMakeLists.txt:407 (MESSAGE):
  Could not find devtoolset compiler/linker in /opt/rh/gcc-toolset-12

CMake Warning at CMakeLists.txt:409 (MESSAGE):
  You need to install the required packages:

   yum install gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-annocheck gcc-toolset-12-annobin-plugin-gcc

Suggested fix:

1. Add these rpms to the BuildRequires: section in https://github.com/mysql/mysql-server/blob/trunk/packaging/rpm-oel/mysql.spec.in

2. Consider trying to build your environment from a clean, empty environment as by doing this you'll catch these build failures.  Your build setup may be more complex as you need to build for many OS versions and also build the Enterprise and Community and now Cloud versions but by doing a clean build from an empty environment this sort of missing configuration will become more visible to you.  It is not the first time that I have reported such issues.

3. Also please document your build process so that others can reproduce it more easily. My code at https://github.com/sjmudd/mysql-rpm-builder is updated to ensure that I can build new rpms directly from a clean empty environment. You may consider there are better ways to do this but it's allowed me to at least be sure that if I want to rebuild rpms I am able to do this and can be confident I will be find the process fails unexpectedly.

I'm currently rebuilding the MySQL 9.0.0 rpms against OL9. Once done I'll push the latest change to my repo.
[2 Jul 7:43] Simon Mudd
If you remove the rpms from https://github.com/sjmudd/mysql-rpm-builder/blob/main/config/ossetup/centos9__9.0.0.sh#L56... in my build repo you will see the build fail if you clone the repo on a machine with docker and run ./build_one ol9 9.0.0

Note: in theory if the rpms are not installed rpm should complain about the missing packages as they should be in the BuildRequires: section.  If the rpms are mentioned then tooling can detect this (it's harder if this is wrapped in OS specific %if macros but it's still possible) and ensure they are present.
[2 Jul 9:14] MySQL Verification Team
Hi Mr. Mudd,

Thank you for your bug report.

We reproduced the problems on Oracle Linux 8.9.

Verified as reported.
[2 Jul 9:44] Simon Mudd
Hi,

Thanks for confirming the issue.

> We reproduced the problems on Oracle Linux 8.9.

Indeed, I'm rebuilding multiple OS / MySQL combinations at the moment. This takes a while on my home setup. Pending build checks where also for ol9 / 9.0.0 but the rpm build process and dependencies is going to be pretty much the same.
[3 Jul 9:46] MySQL Verification Team
Mr. Mudd,

You are truly welcome.
[3 Jul 12:59] Terje Røsten
GCC 13 is for 9.0.0 only at the moment.
[3 Jul 13:16] MySQL Verification Team
Thank you, Terje, for correcting the version.
[7 Jul 14:23] Simon Mudd
FWIW: Made this PR: https://github.com/mysql/mysql-server/pull/556
[8 Jul 10:07] MySQL Verification Team
Thank you, Mr. Mudd.
[15 Jul 13:46] OCA Admin
Contribution submitted via Github - bug#115484: Modify BuildRequires: to include gcc-toolset-12 for compat libraries 
(*) Contribution by Simon Mudd (Github sjmudd, mysql-server/pull/556#issuecomment-2213651632): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1956459113.txt (text/plain), 2.17 KiB.

[27 Aug 23:39] Philip Olson
Fixed as of the upcoming MySQL Server 9.1.0 release, and here's the proposed changelog entry from the documentation team:

----
Added gcc-toolset-12 to the EL8 and EL9 build specification file to allow
building the MySQL 8.0 mysql-community-libs-compat RPM.

Our thanks to Simon Mudd for the contribution.
----

Thank you for the bug report.
[16 Sep 9:23] MySQL Verification Team
Thank you, Phillip.