clang-lto series for v5.12-rc1
- Clang LTO build infrastructure and arm64-specific enablement (Sami Tolvanen)
- Recursive build CC_FLAGS_LTO fix (Alexander Lobakin)
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmA0OEYACgkQiXL039xt
wCYGJw/8CcyvQUGmXYEZVDLMahKz93RYijiGuSTVnhl0pNAyfOojaZ8Z//eD1VNA
s82azW1XybbA6RnPGD7YQzYz27cSF2qUFDmplwVfE4mwBnPXzRxtVBDLSxksP1HS
77sCOu91QhbovPCWET4dSHLJB3DVc78FiW4lVlRgrglyAz+dut1iXYar5e7VNoS0
S4MwnqwteHC6YXP619rubhpdDoj7njuw1uxRIaodt9S/zRSpl5MCUgHmzQusgezs
yWDdPHPWHnF7xxKgwSvE7AKZPdOnIxKxRi6Yd6vUIyrYB3qLZkFe75nUsgMroAhs
/Bgrn69U2McMiJsOdh0ERzP2VNYfvMacBQ308nb45j83Bgv5l6uj8QOZU4ZogmXV
PsDzsfUe9GsxgYexfozGX61rpd6JinzQKVyoDW3oTT54fbBxO3uDqT8kOBw72dPT
9nkOxTzyb+UO0dpb/MhXLGkGcv8+lTA5ffVIKUx5UxKngRbukc3dxwVJgO4HmucK
bwVQGD83D+/if5/JL9WtQRjDwFEn+IFmdv+3cAXkRo4IIS18LPZB1MJncTeWr8Z9
HlkuDXlJOncUWCABGd1IKu1j0S2HpXV4qhqQXJ6PdfOvUPEaD9qgqEAjD5FxxyXF
wpaV2MWya5i1FGwD5UKhi8hVnAFJyF0/w+enjiPwlmIbjdyEVXE=
=6peY
-----END PGP SIGNATURE-----
Merge tag 'clang-lto-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull clang LTO updates from Kees Cook:
"Clang Link Time Optimization.
This is built on the work done preparing for LTO by arm64 folks,
tracing folks, etc. This includes the core changes as well as the
remaining pieces for arm64 (LTO has been the default build method on
Android for about 3 years now, as it is the prerequisite for the
Control Flow Integrity protections).
While x86 LTO enablement is done, it depends on some pending objtool
clean-ups. It's possible that I'll send a "part 2" pull request for
LTO that includes x86 support.
For merge log posterity, and as detailed in commit dc5723b02e
("kbuild: add support for Clang LTO"), here is the lt;dr to do an LTO
build:
make LLVM=1 LLVM_IAS=1 defconfig
scripts/config -e LTO_CLANG_THIN
make LLVM=1 LLVM_IAS=1
(To do a cross-compile of arm64, add "CROSS_COMPILE=aarch64-linux-gnu-"
and "ARCH=arm64" to the "make" command lines.)
Summary:
- Clang LTO build infrastructure and arm64-specific enablement (Sami
Tolvanen)
- Recursive build CC_FLAGS_LTO fix (Alexander Lobakin)"
* tag 'clang-lto-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
kbuild: prevent CC_FLAGS_LTO self-bloating on recursive rebuilds
arm64: allow LTO to be selected
arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS
arm64: vdso: disable LTO
drivers/misc/lkdtm: disable LTO for rodata.o
efi/libstub: disable LTO
scripts/mod: disable LTO for empty.c
modpost: lto: strip .lto from module names
PCI: Fix PREL32 relocations for LTO
init: lto: fix PREL32 relocations
init: lto: ensure initcall ordering
kbuild: lto: add a default list of used symbols
kbuild: lto: merge module sections
kbuild: lto: limit inlining
kbuild: lto: fix module versioning
kbuild: add support for Clang LTO
tracing: move function tracer options to Kconfig
This commit is contained in:
commit
79db4d2293
24 changed files with 704 additions and 59 deletions
|
|
@ -184,19 +184,80 @@ extern bool initcall_debug;
|
|||
* as KEEP() in the linker script.
|
||||
*/
|
||||
|
||||
/* Format: <modname>__<counter>_<line>_<fn> */
|
||||
#define __initcall_id(fn) \
|
||||
__PASTE(__KBUILD_MODNAME, \
|
||||
__PASTE(__, \
|
||||
__PASTE(__COUNTER__, \
|
||||
__PASTE(_, \
|
||||
__PASTE(__LINE__, \
|
||||
__PASTE(_, fn))))))
|
||||
|
||||
/* Format: __<prefix>__<iid><id> */
|
||||
#define __initcall_name(prefix, __iid, id) \
|
||||
__PASTE(__, \
|
||||
__PASTE(prefix, \
|
||||
__PASTE(__, \
|
||||
__PASTE(__iid, id))))
|
||||
|
||||
#ifdef CONFIG_LTO_CLANG
|
||||
/*
|
||||
* With LTO, the compiler doesn't necessarily obey link order for
|
||||
* initcalls. In order to preserve the correct order, we add each
|
||||
* variable into its own section and generate a linker script (in
|
||||
* scripts/link-vmlinux.sh) to specify the order of the sections.
|
||||
*/
|
||||
#define __initcall_section(__sec, __iid) \
|
||||
#__sec ".init.." #__iid
|
||||
|
||||
/*
|
||||
* With LTO, the compiler can rename static functions to avoid
|
||||
* global naming collisions. We use a global stub function for
|
||||
* initcalls to create a stable symbol name whose address can be
|
||||
* taken in inline assembly when PREL32 relocations are used.
|
||||
*/
|
||||
#define __initcall_stub(fn, __iid, id) \
|
||||
__initcall_name(initstub, __iid, id)
|
||||
|
||||
#define __define_initcall_stub(__stub, fn) \
|
||||
int __init __stub(void); \
|
||||
int __init __stub(void) \
|
||||
{ \
|
||||
return fn(); \
|
||||
} \
|
||||
__ADDRESSABLE(__stub)
|
||||
#else
|
||||
#define __initcall_section(__sec, __iid) \
|
||||
#__sec ".init"
|
||||
|
||||
#define __initcall_stub(fn, __iid, id) fn
|
||||
|
||||
#define __define_initcall_stub(__stub, fn) \
|
||||
__ADDRESSABLE(fn)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
|
||||
#define ___define_initcall(fn, id, __sec) \
|
||||
__ADDRESSABLE(fn) \
|
||||
asm(".section \"" #__sec ".init\", \"a\" \n" \
|
||||
"__initcall_" #fn #id ": \n" \
|
||||
".long " #fn " - . \n" \
|
||||
#define ____define_initcall(fn, __stub, __name, __sec) \
|
||||
__define_initcall_stub(__stub, fn) \
|
||||
asm(".section \"" __sec "\", \"a\" \n" \
|
||||
__stringify(__name) ": \n" \
|
||||
".long " __stringify(__stub) " - . \n" \
|
||||
".previous \n");
|
||||
#else
|
||||
#define ___define_initcall(fn, id, __sec) \
|
||||
static initcall_t __initcall_##fn##id __used \
|
||||
__attribute__((__section__(#__sec ".init"))) = fn;
|
||||
#define ____define_initcall(fn, __unused, __name, __sec) \
|
||||
static initcall_t __name __used \
|
||||
__attribute__((__section__(__sec))) = fn;
|
||||
#endif
|
||||
|
||||
#define __unique_initcall(fn, id, __sec, __iid) \
|
||||
____define_initcall(fn, \
|
||||
__initcall_stub(fn, __iid, id), \
|
||||
__initcall_name(initcall, __iid, id), \
|
||||
__initcall_section(__sec, __iid))
|
||||
|
||||
#define ___define_initcall(fn, id, __sec) \
|
||||
__unique_initcall(fn, id, __sec, __initcall_id(fn))
|
||||
|
||||
#define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
|
||||
|
||||
/*
|
||||
|
|
@ -236,7 +297,7 @@ extern bool initcall_debug;
|
|||
#define __exitcall(fn) \
|
||||
static exitcall_t __exitcall_##fn __exit_call = fn
|
||||
|
||||
#define console_initcall(fn) ___define_initcall(fn,, .con_initcall)
|
||||
#define console_initcall(fn) ___define_initcall(fn, con, .con_initcall)
|
||||
|
||||
struct obs_kernel_param {
|
||||
const char *str;
|
||||
|
|
|
|||
|
|
@ -1926,7 +1926,7 @@ enum pci_fixup_pass {
|
|||
};
|
||||
|
||||
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
|
||||
#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
#define ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook) \
|
||||
__ADDRESSABLE(hook) \
|
||||
asm(".section " #sec ", \"a\" \n" \
|
||||
|
|
@ -1935,10 +1935,33 @@ enum pci_fixup_pass {
|
|||
".long " #class ", " #class_shift " \n" \
|
||||
".long " #hook " - . \n" \
|
||||
".previous \n");
|
||||
|
||||
/*
|
||||
* Clang's LTO may rename static functions in C, but has no way to
|
||||
* handle such renamings when referenced from inline asm. To work
|
||||
* around this, create global C stubs for these cases.
|
||||
*/
|
||||
#ifdef CONFIG_LTO_CLANG
|
||||
#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook, stub) \
|
||||
void stub(struct pci_dev *dev); \
|
||||
void stub(struct pci_dev *dev) \
|
||||
{ \
|
||||
hook(dev); \
|
||||
} \
|
||||
___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, stub)
|
||||
#else
|
||||
#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook, stub) \
|
||||
___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook)
|
||||
#endif
|
||||
|
||||
#define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook) \
|
||||
__DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \
|
||||
class_shift, hook)
|
||||
class_shift, hook, __UNIQUE_ID(hook))
|
||||
#else
|
||||
/* Anonymous variables would be nice... */
|
||||
#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue