Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 351622 - sys-apps/openrc disrespects CFLAGS when linking
Summary: sys-apps/openrc disrespects CFLAGS when linking
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: portage-multilib
  Show dependency tree
 
Reported: 2011-01-14 04:06 UTC by Nathan Phillip Brink (binki) (RETIRED)
Modified: 2011-01-14 23:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
openrc-0.7.0-1-g882a4b7-build.log (openrc-0.7.0-1-g882a4b7-build.log,10.68 KB, text/plain)
2011-01-14 04:07 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details
openrc-CFLAGS-during-linking.patch (openrc-CFLAGS-during-linking.patch,1.04 KB, patch)
2011-01-14 04:09 UTC, Nathan Phillip Brink (binki) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-01-14 04:06:08 UTC
This breaks, for example, compiling openrc with:
$ make CFLAGS=-m32
on an amd64 system.
Comment 1 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-01-14 04:07:41 UTC
Created attachment 259760 [details]
openrc-0.7.0-1-g882a4b7-build.log

An example of compilation failure due to disrespect of CFLAGS during linking.
Comment 2 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-01-14 04:09:21 UTC
Created attachment 259762 [details, diff]
openrc-CFLAGS-during-linking.patch

This commit fixes the issue for me.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2011-01-14 04:20:49 UTC
This is the correct behavior -- CFLAGS are to be used only when actually compiling a file. In this particular case, I see that the compiler is only called to link the files, and thus it doesn't need to pass CFLAGS. This is what default make rules do [1].

Please fix your LDFLAGS instead.

[1] http://uw714doc.sco.com/cgi-bin/info2html?(make.info)Catalogue%2520of%2520Rules
Comment 4 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2011-01-14 14:56:04 UTC
I appeal to the higher courts! ;-) Just because implicit make rules don't do something doesn't mean a well-written buildsystem shouldn't do that. For example, I think that CFLAGS should pretty much unconditionally be passed to the compiler driver when it's called. Automake does this and it makes sense, especially when there is a distinction between CPPFLAGS, LDFLAGS, and CFLAGS in the first place. This is a pitifully small patch which can only fix things.
Comment 5 Jory A. Pratt gentoo-dev 2011-01-14 16:35:30 UTC
I do not see the point here but I would like to hear from the rest of the team as to their thoughts on the issue.
Comment 6 William Hubbs gentoo-dev 2011-01-14 18:26:26 UTC
Comment #3 is correct in that Make's default rules do not do this. Also,
it is technically correct that CFLAGS are for compiling and LDFLAGS are
for linking.

However, as pointed out in comment #4, automake/autoconf based build
systems do pass CFLAGS to the linker.

I can see this going either way. We could have him add -m32 to his
ldflags, or we can apply this patch, which I also agree is a trivial
patch, and make our build system behave more like automake in this
regard.

Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2011-01-14 21:02:34 UTC
(In reply to comment #6)
> I can see this going either way. We could have him add -m32 to his
> ldflags, or we can apply this patch, which I also agree is a trivial
> patch, and make our build system behave more like automake in this
> regard.

Or finally migrate to autotools.
Comment 8 SpanKY gentoo-dev 2011-01-14 21:19:50 UTC
patch is fine.  i'm OK with delaying the user-is-stupid debate to some other time and/or place.
Comment 9 William Hubbs gentoo-dev 2011-01-14 23:56:04 UTC
This patch has been applied in git, commit a534b6.