Bug #109325 | compilation with gcc-11 or gcc-12 in RelWithDebInfo reports many warnings | ||
---|---|---|---|
Submitted: | 9 Dec 2022 10:58 | Modified: | 20 Dec 2022 15:08 |
Reporter: | Przemysław Skibiński (OCA) | Email Updates: | |
Status: | Won't fix | Impact on me: | |
Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Ubuntu (Ubuntu 22.04.1 LTS) |
Assigned to: | CPU Architecture: | x86 |
[9 Dec 2022 10:58]
Przemysław Skibiński
[9 Dec 2022 11:25]
Przemysław Skibiński
The following patch works fine for me: diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake index fe81e48fd58..10f0553b76b 100644 --- a/cmake/compile_flags.cmake +++ b/cmake/compile_flags.cmake @@ -127,6 +127,12 @@ FUNCTION(ADD_LINUX_DEB_FLAGS) MESSAGE(FATAL_ERROR "WITH_PACKAGE_FLAGS=on but dpkg-buildflags --get failed") ENDIF() + + # remove "-flto=auto -ffat-lto-objects" returned on Ubuntu 22.04 + REMOVE_CMAKE_COMPILER_FLAGS(GET_CFLAGS "-flto(=[0-9a-z]+)?|-ffat-lto-objects") + REMOVE_CMAKE_COMPILER_FLAGS(GET_CXXFLAGS "-flto(=[0-9a-z]+)?|-ffat-lto-objects") + REMOVE_CMAKE_COMPILER_FLAGS(GET_LDFLAGS "-flto(=[0-9a-z]+)?|-ffat-lto-objects") + SET(CMAKE_C_FLAGS "${GET_CFLAGS} ${GET_CPPFLAGS}" PARENT_SCOPE) SET(CMAKE_CXX_FLAGS "${GET_CXXFLAGS} ${GET_CPPFLAGS}" PARENT_SCOPE) SET(CMAKE_EXE_LINKER_FLAGS "${GET_LDFLAGS}" PARENT_SCOPE)
[9 Dec 2022 13:17]
MySQL Verification Team
Hi Mr. Skibinski, Thank you for your bug report. Can you, please, let us know the outputs of the following commands: gcc --version and gcc -V Thanks a lot in advance.
[9 Dec 2022 13:34]
Przemysław Skibiński
Hi, there are warnings because Ubuntu 22.04 Jammy returns: $ dpkg-buildflags --get CXXFLAGS -g -O2 -ffile-prefix-map=/data/mysql-server=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security The same compilers on Ubuntu 20.04 will be fine because: $ dpkg-buildflags --get CXXFLAGS -g -O2 -fdebug-prefix-map=/data/docker=. -fstack-protector-strong -Wformat -Werror=format-security My gcc versions: $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.3.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-xKiWfi/gcc-11-11.3.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) $ gcc-12 -v Using built-in specs. COLLECT_GCC=gcc-12 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)
[9 Dec 2022 14:23]
MySQL Verification Team
Hi, Since we are supporting Ubuntu 22.10, we are verifying this report. Verified.
[20 Dec 2022 15:08]
Tor Didriksen
Posted by developer: Our automated build system builds RPM or DEB packages, and most modern platforms have some builtin flags determined by dpkg-buildflags or 'rpm --eval %optflags' Developers build standalone builds, and by default we add WITH_PACKAGE_FLAGS to RelWithDebInfo builds, because we want the same flags as the automated build, otherwise we migth break it. Having a clean -flto build (on all platforms) is in practice impossible, since this is a moving target: change some code and the linker moves some other code around, and discovers some new 'may be unused'. But we *do* want to see those warnings, so that we can fix them. If you don't like the warnings, then simply turn WITH_PACKAGE_FLAGS OFF. Note that you will lose some performance if you do.
[21 Dec 2022 12:42]
MySQL Verification Team
Thank you, Tor .....