This breaks, for example, compiling openrc with: $ make CFLAGS=-m32 on an amd64 system.
Created attachment 259760 [details] openrc-0.7.0-1-g882a4b7-build.log An example of compilation failure due to disrespect of CFLAGS during linking.
Created attachment 259762 [details, diff] openrc-CFLAGS-during-linking.patch This commit fixes the issue for me.
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
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.
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 #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.
(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.
patch is fine. i'm OK with delaying the user-is-stupid debate to some other time and/or place.
This patch has been applied in git, commit a534b6.