From 3e759e70ac919595f45c1dc80c19fc8d3499b459 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 15 Jan 2020 11:44:39 -0700 Subject: [PATCH] Allow conditionally adding -fcommon to CFLAGS by defining %_legacy_common_support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Miro HronĨok --- buildflags.md | 12 ++++++++++++ macros | 2 +- redhat-rpm-config.spec | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/buildflags.md b/buildflags.md index 177bd59..033c070 100644 --- a/buildflags.md +++ b/buildflags.md @@ -148,6 +148,18 @@ to the RPM spec file to disable these strict checks. Alternatively, you can pass `-z undefs` to ld (written as `-Wl,-z,undefs` on the gcc command line). The latter needs binutils 2.29.1-12.fc28 or later. +### Legacy -fcommon + +Since version 10, [gcc defaults to `-fno-common`](https://gcc.gnu.org/gcc-10/porting_to.html#common). +Builds may fail with `multiple definition of ...` errors. + +As a short term workaround for such failure, +it is possible to add `-fcommon` to the flags by defining `%_legacy_common_support`. + + %define _legacy_common_support 1 + +Properly fixing the failure is always preferred! + # Individual compiler flags Compiler flags end up in the environment variables `CFLAGS`, diff --git a/macros b/macros index cd06548..2d8e6dd 100644 --- a/macros +++ b/macros @@ -230,7 +230,7 @@ print(result) %_ld_as_needed 1 %_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} -%__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %{_annotated_cflags} +%__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %{_annotated_cflags}%{?_legacy_common_support: -fcommon} # Automatically trim changelog entries after 2 years %_changelog_trimtime %{lua:print(os.time() - 2 * 365 * 86400)} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index edb661e..876fd01 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 148 +Version: 149 Release: 1%{?dist} # No version specified. License: GPL+ @@ -207,6 +207,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Thu Jan 23 2020 Jeff Law - 149-1 +- Allow conditionally adding -fcommon to CFLAGS by defining %%_legacy_common_support + * Mon Jan 20 2020 Florian Weimer - 148-1 - Reenable annobin after GCC 10 integration (#1792892)