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, Oct 18, 2017 at 1:20 PM, Jeff Layton <jlayton@xxxxxxxxxxxxxxx> wrote:
>
> 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.

Does all open source package follow this convention or that is a result
of a lot of open source project using autotools

>
> 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

So here by specifying CFLAGS, the original assign for CFLAGS:

CFLAGS = -O$(OPT) -finline-functions -fno-strict-aliasing -g

The above assignment will be ignored. Is that intentional?

Put it in a different way, Now " -finline-functions
-fno-strict-aliasing" are no longer
pass to gcc when compile sparse files any more.

>
> 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.

So your intention is just adding arguments. No removing existing CFLAG
arguments. e.g. removing " -finline-functions -fno-strict-aliasing" from
your invocation is just accident.

>> 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.

Well, sparse is not using autotools. So it is always be special if you consider
autotools the norm.

If your goal is just add some baseline compile options to gcc.
It seems better by provide some thing like CFLAGS_CMD as part of the
ALL_CFLAGS group. Then you can just add your options there. The variable
name of "CFLAGS_CMD" is subject to discussion. You can make suggestions.
Overwrite the CFLAGS variable from command line does have side effect
of dropping some options like " -finline-functions -fno-strict-aliasing".
It comes down to is your intend to drop those?

>
> 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.

" -finline-functions -fno-strict-aliasing" has impact on the output code
it produce. Unless you are intentionally dropping them. Provide other variable
for you to overwrite can preserve those compile flags.

You do know that once you specify CFLAGS in the make command line,
by default all other assign to CFLAGS from the Makefile will be ignored.

Chris
--
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