Bug 2184340 - _distro_extra_cflags is ignored if _auto_set_build_flags is enabled
Summary: _distro_extra_cflags is ignored if _auto_set_build_flags is enabled
Keywords:
Status: CLOSED INSUFFICIENT_DATA
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2100610
TreeView+ depends on / blocked
 
Reported: 2023-04-04 11:00 UTC by Dominik 'Rathann' Mierzejewski
Modified: 2023-06-13 13:08 UTC (History)
14 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-06-13 13:08:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dominik 'Rathann' Mierzejewski 2023-04-04 11:00:02 UTC
Description of problem:
build_cflags is defined as:

build_cflags       %{optflags} %{?_distro_extra_cflags}

suggesting that extra flags can be added by defining _distro_extra_cflags.
However, doing

%global _distro_extra_cflags -Wno-error=stringop-overflow

has no effect on build_cflags unless I disable _auto_set_build_flags using

%undefine _auto_set_build_flags

and add %set_build_flags to %build manually.

Version-Release number of selected component (if applicable):
redhat-rpm-config-254-1.fc39.noarch

How reproducible:
Always.

Steps to Reproduce:
1. Add %global _distro_extra_cflags -Wno-error=stringop-overflow to your spec file
2. rpmbuild -bc foo.spec

Actual results:
...
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64   -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'
...

Expected results:
...
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64   -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wno-error=stringop-overflow'
...

Comment 1 Dominik 'Rathann' Mierzejewski 2023-04-04 11:19:19 UTC
Additional info:

rpm -D '_distro_extra_cflags -Wall' -E '%build_cflags' | grep -e '\-Wall$'

does work. Doing the same in a spec file doesn't.

Comment 2 Florian Weimer 2023-04-04 13:36:19 UTC
(In reply to Dominik 'Rathann' Mierzejewski from comment #0)
> Steps to Reproduce:
> 1. Add %global _distro_extra_cflags -Wno-error=stringop-overflow to your
> spec file

If that doesn't work, this is actually a good thing. %_distro_extra_cflags must not be changed in individual spec files, it's reserved for use by the distribution.

That being said, I cannot reproduce this issue.

Comment 3 Dominik 'Rathann' Mierzejewski 2023-04-05 09:38:18 UTC
(In reply to Florian Weimer from comment #2)
> (In reply to Dominik 'Rathann' Mierzejewski from comment #0)
> > Steps to Reproduce:
> > 1. Add %global _distro_extra_cflags -Wno-error=stringop-overflow to your
> > spec file
> 
> If that doesn't work, this is actually a good thing. %_distro_extra_cflags
> must not be changed in individual spec files, it's reserved for use by the
> distribution.

Well, _distro_extra_cflags is undefined at the moment, so I thought it'd be ok to use.

What is the "official" way of adding some extra CFLAGS, then?

> That being said, I cannot reproduce this issue.

Odd. It's 100% reproducible in rawhide mock for me.

Comment 4 Florian Weimer 2023-04-05 09:47:48 UTC
(In reply to Dominik 'Rathann' Mierzejewski from comment #3)
> (In reply to Florian Weimer from comment #2)
> > (In reply to Dominik 'Rathann' Mierzejewski from comment #0)
> > > Steps to Reproduce:
> > > 1. Add %global _distro_extra_cflags -Wno-error=stringop-overflow to your
> > > spec file
> > 
> > If that doesn't work, this is actually a good thing. %_distro_extra_cflags
> > must not be changed in individual spec files, it's reserved for use by the
> > distribution.
> 
> Well, _distro_extra_cflags is undefined at the moment, so I thought it'd be
> ok to use.
> 
> What is the "official" way of adding some extra CFLAGS, then?

Do it at the shell level (CFLAGS="$CFLAGS -Wno-error=stringop-overflow"), I think.

> > That being said, I cannot reproduce this issue.
> 
> Odd. It's 100% reproducible in rawhide mock for me.

I tried with the lua spec file and it worked for me. So we'd need to see your spec file.


Note You need to log in before you can comment on or make changes to this bug.