mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] build: Pass CC, CFLAGS, ... to tools build from main Makefile
@ 2017-10-03 20:48 Douglas Anderson
  2017-10-03 20:48 ` [RFC PATCH 1/2] kbuild: Pass HOSTCC and similar to tools Makefiles Douglas Anderson
  2017-10-03 20:48 ` [RFC PATCH 2/2] tools build: Take CC, AS, and LD from the command line Douglas Anderson
  0 siblings, 2 replies; 10+ messages in thread
From: Douglas Anderson @ 2017-10-03 20:48 UTC (permalink / raw)
  To: yamada.masahiro, mmarek, acme
  Cc: groeck, Dmitry Torokhov, mka, Douglas Anderson, linux-kbuild,
	David Carrillo-Cisneros, linux-kernel, Josh Poimboeuf, Jiri Olsa


While trying to enable CONFIG_STACK_VALIDATION in the Chrome OS build
system, Guenter Roeck noticed that the compilation of objtool was
failing in a weird way.  He tracked this down to the fact that,
although the kernel build ignores CFLAGS as of the ancient commit
69ee0b352242 ("kbuild: do not pick up CFLAGS from the environment"),
those the tools builds generally don't ignore CFLAGS.

For the most part it's OK that the tools builds don't ignore CFLAGS.
One could argue that the tools builds really _should_ honor CFLAGS
because, unlike the kernel, they don't need to be special snowflakes.
In general we're just building normal userspace programs and CFLAGS
from the environment can make sense.

...but... When a tools build is invoked from the kernel build then
CFLAGS probably won't make sense.  Specifically the kernel build
expects that "CC" is the _target_ compiler, not the _host_ compiler.
Presumably if CFLAGS is set in the current environment it will match
"CC".  That means it won't make a lot of sense to use when building
tools.

Technically we could just "fix" this by blanking out CFLAGS in the
call to the tools build, just like we've always done for LDFLAGS.
That would fix the problem that Guenter saw.  ...but we probably want
to go a step further.

In general it seems non-ideal that, even if someone overrides HOSTCC
in the kernel, that the tools build will still go back to a hardcoded
"gcc".  It seems like the compiler provided to the kernel as HOSTCC
really ought to be the compiler used in the tools build.  That seems
like it will be important for clang work.  The patches in this series
attempt to do that.

NOTE: I personally am not spending lots of time on clangification of
the kernel (though many of my colleagues are), so I haven't confirmed
that this is actually useful to clang.  It just seemed like a good
fix.  I also continue to assert that I'm not a kernel build expert, so
I've marked this as RFC in the hopes that people will not scream too
loudly if this is a stupid thing to do.  ;-)


Douglas Anderson (2):
  kbuild: Pass HOSTCC and similar to tools Makefiles
  tools build: Take CC, AS, and LD from the command line

 Makefile                       | 30 ++++++++++++++++++++++++++++--
 tools/scripts/Makefile.include | 22 ++++++++++++++++++++--
 2 files changed, 48 insertions(+), 4 deletions(-)

-- 
2.14.2.920.gcf0c67979c-goog

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-04 16:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 20:48 [RFC PATCH 0/2] build: Pass CC, CFLAGS, ... to tools build from main Makefile Douglas Anderson
2017-10-03 20:48 ` [RFC PATCH 1/2] kbuild: Pass HOSTCC and similar to tools Makefiles Douglas Anderson
2017-10-04  3:05   ` Guenter Roeck
2017-10-04  3:20   ` Masahiro Yamada
2017-10-04  4:07     ` Guenter Roeck
2017-10-04 16:09       ` Doug Anderson
2017-10-04 16:22         ` Josh Poimboeuf
2017-10-03 20:48 ` [RFC PATCH 2/2] tools build: Take CC, AS, and LD from the command line Douglas Anderson
2017-10-04  3:06   ` Guenter Roeck
2017-10-04 15:54     ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®