Switch C type safety level to 3 (GCC 14 default), and adjust for GCC 14

No conflict because except for %global build_type_safety 0,
the package is still compatibility with GCC 13 (but does not
enforce the type safety levels anymore).
This commit is contained in:
Florian Weimer 2024-01-15 12:17:56 +01:00
parent a15ac4695e
commit b13edec098
3 changed files with 16 additions and 7 deletions

View File

@ -117,7 +117,7 @@ or:
### Controlling Type Safety ### Controlling Type Safety
The macro `%build_type_safety_c` can be set to change the C type The macro `%build_type_safety_c` can be set to change the C type
safety level. The default level is 1, see below. It can be set to 0 safety level. The default level is 3, see below. It can be set to 0
to get historic levels of type safety. Changing the type safety level to get historic levels of type safety. Changing the type safety level
may depend on correct `CFLAGS` propagation during the build. The may depend on correct `CFLAGS` propagation during the build. The
`%build_type_safety_c` macro needs to be set before `CFLAGS`-related `%build_type_safety_c` macro needs to be set before `CFLAGS`-related
@ -130,14 +130,14 @@ the `%build_type_safety_c` level to increase it, spec file should use
a construct like this to avoid *lowering* a future default: a construct like this to avoid *lowering* a future default:
``` ```
%if %build_type_safety_c < 2 %if %build_type_safety_c < 4
%global build_type_safety_c 2 %global build_type_safety_c 4
%endif %endif
``` ```
At level 0, all C constructs that GCC accepts for backwards At level 0, all C constructs that GCC accepts for backwards
compatibility with obsolete language standards are accepted during compatibility with obsolete language standards are accepted during
package builds. package builds. This is achieved by passing `-fpermissive` to GCC.
At level 1, the following additional error categories are enabled: At level 1, the following additional error categories are enabled:
@ -151,6 +151,12 @@ At level 1, the following additional error categories are enabled:
Previously, such expressions where we compiled as if a declaration Previously, such expressions where we compiled as if a declaration
`extern int function_not_defined_anywhere ();` (a prototype-less `extern int function_not_defined_anywhere ();` (a prototype-less
function declaration) were in scope. function declaration) were in scope.
* `-Werror=return-mismatch`: Reject `return` statements with missing
or extra expressions, based on the declared return type of the
function.
* `-Wdeclaration-missing-parameter-type`: Reject function declarations
that contain unknown type names (which used to be treated as ignored
identifier names).
At level 2, the following error category is enabled in addition: At level 2, the following error category is enabled in addition:

4
macros
View File

@ -400,14 +400,14 @@ for k,_ in pairs(stripped_flags) do print(k .. " ") end
# This can be set to a positive integer to obtain increasing type # This can be set to a positive integer to obtain increasing type
# safety levels for C. See buildflags.md. # safety levels for C. See buildflags.md.
%build_type_safety_c 1 %build_type_safety_c 3
# Some linkers default to a build-id algorithm that is not supported by rpmbuild, # Some linkers default to a build-id algorithm that is not supported by rpmbuild,
# so we need to specify the right algorithm to use. # so we need to specify the right algorithm to use.
%_build_id_flags -Wl,--build-id=sha1 %_build_id_flags -Wl,--build-id=sha1
%_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe %_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
%_warning_options -Wall%[%__build_for_lang_any && "%toolchain" == "gcc" ? " -Wno-complain-wrong-lang" : ""]%[%__build_for_lang_c + %__build_for_lang_cxx ? " -Werror=format-security" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 1) ? " -Werror=implicit-function-declaration -Werror=implicit-int" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 2) ? " -Werror=int-conversion" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 3) ? " -Werror=incompatible-pointer-types" : ""] %_warning_options -Wall%[%__build_for_lang_any && "%toolchain" == "gcc" ? " -Wno-complain-wrong-lang" : ""]%[%__build_for_lang_c + %__build_for_lang_cxx ? " -Werror=format-security" : ""]%[%__build_for_lang_c && (%build_type_safety_c == 0) ? " -fpermissive" : ""]%[%__build_for_lang_c && (%build_type_safety_c == 1) ? " -Wno-error=int-conversion" : ""]%[%__build_for_lang_c && (%build_type_safety_c > 0 && %build_type_safety_c < 3) ? " -Wno-error=incompatible-pointer-types" : ""]
%_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS %_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
# Common variables are no longer generated by default by gcc and clang # Common variables are no longer generated by default by gcc and clang

View File

@ -4,7 +4,7 @@
# 2) When making changes, increment the version (in baserelease) by 1. # 2) When making changes, increment the version (in baserelease) by 1.
# rpmdev-bumpspec and other tools update the macro below, which is used # rpmdev-bumpspec and other tools update the macro below, which is used
# in Version: to get the desired effect. # in Version: to get the desired effect.
%global baserelease 276 %global baserelease 277
Summary: Red Hat specific rpm configuration files Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config Name: redhat-rpm-config
@ -258,6 +258,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua
%doc buildflags.md %doc buildflags.md
%changelog %changelog
* Mon Jan 15 2024 Florian Weimer <fweimer@redhat.com> - 277-1
- Switch C type safety level to 3 (GCC 14 default), and adjust for GCC 14
* Thu Jan 11 2024 Jan Grulich <jgrulich@redhat.com> - 276-1 * Thu Jan 11 2024 Jan Grulich <jgrulich@redhat.com> - 276-1
- Drop qt5-srpm-macros from RHEL 10 - Drop qt5-srpm-macros from RHEL 10