linux-stable/scripts
Sami Tolvanen dc5723b02e kbuild: add support for Clang LTO
This change adds build system support for Clang's Link Time
Optimization (LTO). With -flto, instead of ELF object files, Clang
produces LLVM bitcode, which is compiled into native code at link
time, allowing the final binary to be optimized globally. For more
details, see:

  https://llvm.org/docs/LinkTimeOptimization.html

The Kconfig option CONFIG_LTO_CLANG is implemented as a choice,
which defaults to LTO being disabled. To use LTO, the architecture
must select ARCH_SUPPORTS_LTO_CLANG and support:

  - compiling with Clang,
  - compiling all assembly code with Clang's integrated assembler,
  - and linking with LLD.

While using CONFIG_LTO_CLANG_FULL results in the best runtime
performance, the compilation is not scalable in time or
memory. CONFIG_LTO_CLANG_THIN enables ThinLTO, which allows
parallel optimization and faster incremental builds. ThinLTO is
used by default if the architecture also selects
ARCH_SUPPORTS_LTO_CLANG_THIN:

  https://clang.llvm.org/docs/ThinLTO.html

To enable LTO, LLVM tools must be used to handle bitcode files, by
passing LLVM=1 and LLVM_IAS=1 options to make:

  $ make LLVM=1 LLVM_IAS=1 defconfig
  $ scripts/config -e LTO_CLANG_THIN
  $ make LLVM=1 LLVM_IAS=1

To prepare for LTO support with other compilers, common parts are
gated behind the CONFIG_LTO option, and LTO can be disabled for
specific files by filtering out CC_FLAGS_LTO.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20201211184633.3213045-3-samitolvanen@google.com
2021-01-14 08:21:08 -08:00
..
atomic locking/atomics: Regenerate the atomics-check SHA1's 2020-11-07 13:20:41 +01:00
basic kbuild: introduce hostprogs-always-y and userprogs-always-y 2020-08-10 01:32:59 +09:00
clang-tools Makefile: Add clang-tidy and static analyzer support to makefile 2020-08-27 00:44:33 +09:00
coccinelle coccinnelle: Remove ptr_ret script 2020-12-15 20:55:19 +01:00
dtc scripts/dtc: Update to upstream version v1.6.0-31-gcbca977ea121 2020-10-12 09:58:15 -05:00
dummy-tools kbuild: add dummy toolchains to enable all cc-option etc. in Kconfig 2020-04-09 00:13:45 +09:00
gcc-plugins gcc-plugins: simplify GCC plugin-dev capability test 2020-12-04 14:09:55 -08:00
gdb scripts/gdb/tasks: add headers and improve spacing format 2020-10-16 11:11:22 -07:00
genksyms genksyms: Ignore module scoped _Static_assert() 2020-12-21 13:57:08 +09:00
kconfig kconfig: fix return value of do_error_if() 2020-12-21 14:48:54 +09:00
ksymoops
mod Kbuild updates for v5.11 2020-12-22 14:02:39 -08:00
package builddeb: Fix rootless build in setuid/setgid directory 2020-11-02 11:31:00 +09:00
selinux scripts/selinux,selinux: update mdp to enable policy capabilities 2020-08-17 20:42:00 -04:00
tracing tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
.gitignore kbuild: preprocess module linker script 2020-09-25 00:36:41 +09:00
Kbuild.include kbuild: remove leftover comment for filechk utility 2020-10-21 00:28:53 +09:00
Kconfig.include kconfig: unify cc-option and as-option 2020-06-17 10:38:42 +09:00
Lindent
Makefile kbuild: preprocess module linker script 2020-09-25 00:36:41 +09:00
Makefile.asm-generic
Makefile.build kbuild: add support for Clang LTO 2021-01-14 08:21:08 -08:00
Makefile.clean kbuild: introduce hostprogs-always-y and userprogs-always-y 2020-08-10 01:32:59 +09:00
Makefile.dtbinst kbuild: refactor Makefile.dtbinst more 2020-03-25 10:19:43 +09:00
Makefile.extrawarn Makefile.extrawarn: remove -Wnested-externs warning 2020-12-08 23:30:05 +09:00
Makefile.gcc-plugins gcc-plugins/stackleak: Use asm instrumentation to avoid useless register saving 2020-06-24 07:48:28 -07:00
Makefile.headersinst kbuild: move headers_check rule to usr/include/Makefile 2019-11-15 00:23:10 +09:00
Makefile.host kbuild: sort hostprogs before passing it to ifneq 2020-08-10 01:32:59 +09:00
Makefile.kasan kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles 2020-09-25 00:36:50 +09:00
Makefile.kcov kbuild: include scripts/Makefile.* only when relevant CONFIG is enabled 2020-08-10 01:32:59 +09:00
Makefile.kcsan Kbuild updates for v5.10 2020-10-22 13:13:57 -07:00
Makefile.lib kasan, arm64: expand CONFIG_KASAN checks 2020-12-22 12:55:08 -08:00
Makefile.modfinal kbuild: add support for Clang LTO 2021-01-14 08:21:08 -08:00
Makefile.modinst
Makefile.modpost kbuild: add support for Clang LTO 2021-01-14 08:21:08 -08:00
Makefile.modsign
Makefile.package kbuild: fix broken builds because of GZIP,BZIP2,LZOP variables 2020-06-11 20:14:41 +09:00
Makefile.ubsan ubsan: move cc-option tests into Kconfig 2020-12-15 22:46:18 -08:00
Makefile.userprogs kbuild: add infrastructure to build userspace programs 2020-05-17 18:52:01 +09:00
adjust_autoksyms.sh kbuild: split adjust_autoksyms.sh in two parts 2020-03-03 20:49:21 +09:00
asn1_compiler.c
bin2c.c
bloat-o-meter tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
bootgraph.pl
bpf_helpers_doc.py bpf: Add a bpf_sock_from_file helper 2020-12-04 22:32:40 +01:00
cc-can-link.sh
check-sysctl-docs docs: add a script to check sysctl docs 2020-02-25 03:35:16 -07:00
check_extable.sh
checkincludes.pl
checkkconfigsymbols.py kconfig: remove '---help---' support 2020-08-14 13:30:03 +09:00
checkpatch.pl checkpatch: prefer strscpy to strlcpy 2020-12-29 15:36:49 -08:00
checkstack.pl scripts/checkstack.pl: fix arm sp regex 2020-05-26 00:03:16 +09:00
checksyscalls.sh
checkversion.pl
clang-version.sh
cleanfile
cleanpatch
coccicheck scripts: coccicheck: Correct usage of make coccicheck 2020-12-24 12:59:43 +01:00
config tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
const_structs.checkpatch const_structs.checkpatch: add pinctrl_ops and pinmux_ops 2020-10-16 11:11:21 -07:00
decode_stacktrace.sh scripts/decode_stacktrace.sh: guess path to vmlinux by release name 2020-08-07 11:33:21 -07:00
decodecode scripts/decodecode: add the capability to supply the program counter 2020-10-13 18:38:26 -07:00
depmod.sh depmod: handle the case of /sbin/depmod without /sbin in PATH 2021-01-01 12:26:39 -08:00
dev-needs.sh scripts/dev-needs: Add script to list device dependencies 2020-09-04 18:19:37 +02:00
diffconfig tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
documentation-file-ref-check scripts: documentation-file-ref-check: Add line break before exit 2020-04-15 15:13:13 -06:00
export_report.pl modpost: move the namespace field in Module.symvers last 2020-03-17 08:59:03 +09:00
extract-cert.c extract-cert: add static to local data 2020-08-18 20:16:46 +09:00
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line
file-size.sh
find-unused-docs.sh scripts/find-unused-docs: Fix massive false positives 2020-01-27 14:25:06 -07:00
gcc-goto.sh
gcc-ld
gcc-version.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_autoksyms.sh kbuild: generate autoksyms.h early 2020-03-03 20:49:21 +09:00
gen_ksymdeps.sh
get_abi.pl tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
get_dvb_firmware
get_feat.pl scripts: get_feat.pl: reduce table width for all features output 2020-12-04 14:34:27 -07:00
get_maintainer.pl get_maintainer: exclude MAINTAINERS file(s) from --git-fallback 2020-10-16 11:11:19 -07:00
gfp-translate
headerdep.pl
headers_check.pl
headers_install.sh Merge branch 'work.fdpic' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 13:29:39 -07:00
insert-sys-cert.c
jobserver-exec docs, parallelism: Rearrange how jobserver reservations are made 2019-11-22 10:35:18 -07:00
kallsyms.c scripts/kallsyms: skip ppc compiler stub *.long_branch.* / *.plt_branch.* 2020-09-25 00:41:54 +09:00
kernel-doc scripts: kernel-doc: fix parsing function-like typedefs 2020-12-03 15:56:14 -07:00
ld-version.sh
leaking_addresses.pl
link-vmlinux.sh kbuild: add support for Clang LTO 2021-01-14 08:21:08 -08:00
lld-version.sh kbuild: Disable CONFIG_LD_ORPHAN_WARN for ld.lld 10.0.1 2020-12-01 22:46:06 +09:00
makelst
markup_oops.pl
mkcompile_h kbuild: Use uname for LINUX_COMPILE_HOST detection 2020-10-21 00:46:04 +09:00
mkmakefile kbuild: get rid of $(realpath ...) from scripts/mkmakefile 2019-08-29 23:54:29 +09:00
mksysmap mksysmap: Fix the mismatch of '.L' symbols in System.map 2020-06-06 23:39:20 +09:00
mkuboot.sh
module.lds.S kbuild: preprocess module linker script 2020-09-25 00:36:41 +09:00
modules-check.sh kbuild: make module name conflict fatal error 2020-05-26 00:03:16 +09:00
nsdeps kbuild: do not use scripts/ld-version.sh for checking spatch version 2020-12-12 18:31:29 +01:00
objdiff
parse-maintainers.pl parse-maintainers: Do not sort section content by default 2020-03-26 15:08:27 -07:00
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c recordmcount: Fix build failure on non arm64 2020-08-10 15:22:06 +01:00
recordmcount.h recordmcount: support >64k sections 2020-06-16 21:21:00 -04:00
recordmcount.pl s390/ftrace: assume -mhotpatch or -mrecord-mcount always available 2020-11-20 19:19:11 +01:00
setlocalversion scripts/setlocalversion: make git describe output more reliable 2020-09-25 02:28:12 +09:00
show_delta tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
sign-file.c
sorttable.c s390/kernel: expand exception table logic to allow new handling options 2020-07-20 10:55:50 +02:00
sorttable.h scripts/sorttable: Implement build-time ORC unwind table sorting 2019-12-13 10:47:58 +01:00
spdxcheck-test.sh
spdxcheck.py scripts/spdxcheck.py: handle license identifiers in XML comments 2020-10-02 11:31:26 +02:00
spelling.txt Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2020-10-15 15:11:56 -07:00
sphinx-pre-install tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
split-man.pl tweewide: Fix most Shebang lines 2020-12-08 23:30:04 +09:00
stackdelta
stackusage
subarch.include
tags.sh Merge branch 'locking/urgent' into locking/core, to pick up fixes 2020-10-09 08:55:17 +02:00
tools-support-relr.sh scripts/tools-support-relr.sh: un-quote variables 2019-11-13 10:52:05 +00:00
unifdef.c
ver_linux ver_linux: Query ld cache for versions of libc/libcpp run-time 2020-02-10 13:35:15 -08:00
xen-hypercalls.sh
xz_wrap.sh kbuild: add variables for compression tools 2020-06-06 23:42:01 +09:00