bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kbuild v3 0/2] add an elfnote with type BUILD_COMPILER_LTO_INFO
@ 2021-04-01  1:24 Yonghong Song
  2021-04-01  1:24 ` [PATCH kbuild v3 1/2] kbuild: move LINUX_ELFNOTE_BUILD_SALT to elfnote.h Yonghong Song
  2021-04-01  1:24 ` [PATCH kbuild v3 2/2] kbuild: add an elfnote with type BUILD_COMPILER_LTO_INFO Yonghong Song
  0 siblings, 2 replies; 5+ messages in thread
From: Yonghong Song @ 2021-04-01  1:24 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Alexei Starovoitov, Arnaldo Carvalho de Melo, bpf, kernel-team,
	Masahiro Yamada, Michal Marek, Nick Desaulniers

Currently, clang LTO built vmlinux won't work with pahole.
LTO introduced cross-cu dwarf tag references and broke
current pahole model which handles one cu as a time.
The solution is to merge all cu's as one pahole cu as in [1].
We would like to do this merging only if cross-cu dwarf
references happens. The LTO build mode is a pretty good
indication for that.

In earlier version of this patch ([2]), clang flag
-grecord-gcc-switches is proposed to add to compilation flags
so pahole could detect "-flto" and then merging cu's.
This will increate the binary size of 1% without LTO though.

Arnaldo suggested to use a note to indicate the vmlinux
is built with LTO. Such a cheap way to get whether the vmlinux
is built with LTO or not helps pahole but is also useful
for tracing as LTO may inline/delete/demote global functions,
promote static functions, etc.

This patch set added an elfnote with type BUILD_COMPILER_LTO_INFO.
The owner of the note is "Linux". Patch #1 did some refactoring
and Patch #2 added the elfnote with BUILD_COMPILER_LTO_INFO to
indicate whether vmlinux is built with LTO or not.

 [1] https://lore.kernel.org/bpf/20210325065316.3121287-1-yhs@fb.com/
 [2] https://lore.kernel.org/bpf/20210331001623.2778934-1-yhs@fb.com/

Yonghong Song (2):
  kbuild: move LINUX_ELFNOTE_BUILD_SALT to elfnote.h
  kbuild: add an elfnote with type BUILD_COMPILER_LTO_INFO

 include/linux/build-salt.h | 2 --
 include/linux/compiler.h   | 8 ++++++++
 include/linux/elfnote.h    | 6 ++++++
 init/version.c             | 2 ++
 scripts/mod/modpost.c      | 1 +
 5 files changed, 17 insertions(+), 2 deletions(-)

-- 
2.30.2


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

end of thread, other threads:[~2021-04-01 20:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01  1:24 [PATCH kbuild v3 0/2] add an elfnote with type BUILD_COMPILER_LTO_INFO Yonghong Song
2021-04-01  1:24 ` [PATCH kbuild v3 1/2] kbuild: move LINUX_ELFNOTE_BUILD_SALT to elfnote.h Yonghong Song
2021-04-01  1:24 ` [PATCH kbuild v3 2/2] kbuild: add an elfnote with type BUILD_COMPILER_LTO_INFO Yonghong Song
2021-04-01 18:28   ` Nick Desaulniers
2021-04-01 20:50     ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).