Re: [PATCH] build: assign extra flags to ALL_CFLAGS instead of CFLAGS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2017-10-18 at 12:36 -0700, Christopher Li wrote:
> On Wed, Oct 18, 2017 at 8:07 AM, Jeff Layton <jlayton@xxxxxxxxxx> wrote:
> > From: Jeff Layton <jlayton@xxxxxxxxxx>
> > 
> > The fedora packaging tools want to override $CFLAGS when building
> > sparse, but that fails on a couple of targets.
> > 
> > There are a couple of build targets in the makefile that want to add
> > options to $CFLAGS. When we do a build though, we pass $ALL_CFLAGS
> > to the compiler, and that ends up not getting options passed in
> > via $CFLAGS on the command line.
> 
> Can you give example of what CFLAGS it passed in the command line?
> Does it append some flags only?
> 

Fedora, Red Hat, etc., define some macros that are considered "standard"
build options during packaging. These get passed into "make" and make is
expected to add to that list as necessary.

Here's what the make command looks like when called by rpmbuild with the
fedora package (built out of my homedir):

    $ make DESTDIR=/home/jlayton/rpmbuild/BUILDROOT/sparse-0.5.1-1.fc26.x86_64 PREFIX=/usr BINDIR=/usr/bin LIBDIR=/usr/lib64 INCLUDEDIR=/usr/include PKGCONFIGDIR=/usr/lib64/pkgconfig -j16 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' HAVE_LLVM=no

This is how things like FORTIFY_SOURCE end up being widespread in
distros without having to touch every program.


> It seems wrong to overwrite CFLAGS from command line. That are
> other flags store in the CFLAGS will get overwritten.
> 

I'm not sure I understand the objection here. Basically we just want to
pass in a "base" set of CFLAGS and then let make add others as it sees
fit.

> We have add some variable in the ALL_CFLAGS list for overwrite
> purpose  e.g. CFLAGS_CMD then have command line over write that?
> 

FWIW, I inherited this specfile long ago and have only tweaked it since.
It could probably be better, but I'd like to make it less of a special
snowflake over the long haul. Hand rolled makefiles are generally a pain
in this regard.

I can certainly adapt the specfile this to pass in some other variable
than CFLAGS if you like, but I don't really see how that would improve
anything.

-- 
Jeff Layton <jlayton@xxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux