Fix warnings that appear during the build of the llvm package

The package redefines %optflags on i686 and s390x, so the
%__build_for_lang_* macros are no longer expanded, triggering
a warning from RPM (“%__build_for_lang_any defined but not
used within scope”).  Clang warns about -Wno-complain-wrong-lang
with -Wall, so the warning option is suppressed for
"%toolchain" != "gcc".

Reported-by: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>
This commit is contained in:
Florian Weimer 2023-07-07 13:58:33 +02:00
parent d9c3154737
commit f447520e2d
2 changed files with 11 additions and 7 deletions

13
macros
View File

@ -393,7 +393,7 @@ print(result)
%_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 ? " -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 >= 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" : ""]
%_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
@ -408,14 +408,15 @@ print(result)
# and shadowing redefinitions are used for the __build_for_* variables # and shadowing redefinitions are used for the __build_for_* variables
# to remain largely compatible with existing spec files that have # to remain largely compatible with existing spec files that have
# hard-coded assumptions which macros assume which other macros. # hard-coded assumptions which macros assume which other macros.
# Note: Using short-circuit evaluation with || in __build_for_* conditionals # The __build_flags_no_macro_warning construct suppresses a warning
# may result in unused-macro warnings from RPM. # about unused RPM macros.
%__build_for_lang_c 1 %__build_for_lang_c 1
%__build_for_lang_cxx 1 %__build_for_lang_cxx 1
%__build_for_lang_any 1 %__build_for_lang_any 1
%__build_flags_common() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{optflags} %__build_flags_no_macro_warning %[%__build_for_lang_c + %__build_for_lang_cxx + %__build_for_lang_any ? "" : ""]
%__build_flags_lang_c() %{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{optflags} %__build_flags_common() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_cxx() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_any 0}%{optflags} %__build_flags_lang_c() %{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_cxx() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
# Automatically trim changelog entries after 2 years # Automatically trim changelog entries after 2 years
%_changelog_trimage %{expr:2*365*24*60*60} %_changelog_trimage %{expr:2*365*24*60*60}

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 260 %global baserelease 261
Summary: Red Hat specific rpm configuration files Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config Name: redhat-rpm-config
@ -254,6 +254,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md %doc buildflags.md
%changelog %changelog
* Fri Jul 7 2023 Florian Weimer <fweimer@redhat.com> - 261-1
- Fix warnings that appear during the build of the llvm package
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 260-1 * Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 260-1
- Implement the %%build_type_safety_c macro (#2218019) - Implement the %%build_type_safety_c macro (#2218019)