History

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 dc5723b02e52 ("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

Linus Torvalds committed 5 years ago

Commit 79db4d22 parents 3b9cdaf 2b8689524 files · +704 −59Browse files

Showing the changes to scripts/mod (4 of 24 files). Show all

Unified · Split

4 files
  1. scripts/mod/Makefile +1 −0
  2. scripts/mod/modpost.c +7 −9
  3. scripts/mod/modpost.h +9 −0
  4. scripts/mod/sumversion.c +5 −1
scripts/mod/Makefile+1−0
@@ -1,5 +1,6 @@
11 # SPDX-License-Identifier: GPL-2.0
22 OBJECT_FILES_NON_STANDARD := y
3+CFLAGS_REMOVE_empty.o += $(CC_FLAGS_LTO)
34
45 hostprogs-always-y += modpost mk_elfconfig
56 always-y += empty.o
scripts/mod/modpost.c+7−9
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 #include <ctype.h>
1818 #include <string.h>
1919 #include <limits.h>
20−#include <stdbool.h>
2120 #include <errno.h>
2221 #include "modpost.h"
2322 #include "../../include/linux/license.h"
@@ -84,14 +83,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...) · 60 unmodified lines
8483 error_occurred = true;
8584 }
8685
87−static inline bool strends(const char *str, const char *postfix)
88−{
89− if (strlen(str) < strlen(postfix))
90− return false;
91−
92− return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
93−}
94−
9586 void *do_nofail(void *ptr, const char *expr)
9687 {
9788 if (!ptr)
@@ -1988,6 +1979,10 @@ static char *remove_dot(char *s) · 1890 unmodified lines
19881979 size_t m = strspn(s + n + 1, "0123456789");
19891980 if (m && (s[n + m] == '.' || s[n + m] == 0))
19901981 s[n] = 0;
1982+
1983+ /* strip trailing .lto */
1984+ if (strends(s, ".lto"))
1985+ s[strlen(s) - 4] = '\0';
19911986 }
19921987 return s;
19931988 }
@@ -2011,6 +2006,9 @@ static void read_symbols(const char *modname) · 17 unmodified lines
20112006 /* strip trailing .o */
20122007 tmp = NOFAIL(strdup(modname));
20132008 tmp[strlen(tmp) - 2] = '\0';
2009+ /* strip trailing .lto */
2010+ if (strends(tmp, ".lto"))
2011+ tmp[strlen(tmp) - 4] = '\0';
20142012 mod = new_module(tmp);
20152013 free(tmp);
20162014 }
scripts/mod/modpost.h+9−0
@@ -2,6 +2,7 @@ · 1 unmodified line
22 #include <stdio.h>
33 #include <stdlib.h>
44 #include <stdarg.h>
5+#include <stdbool.h>
56 #include <string.h>
67 #include <sys/types.h>
78 #include <sys/stat.h>
@@ -180,6 +181,14 @@ static inline unsigned int get_secindex(const struct elf_info *info, · 172 unmodified lines
180181 return info->symtab_shndx_start[sym - info->symtab_start];
181182 }
182183
184+static inline bool strends(const char *str, const char *postfix)
185+{
186+ if (strlen(str) < strlen(postfix))
187+ return false;
188+
189+ return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
190+}
191+
183192 /* file2alias.c */
184193 extern unsigned int cross_build;
185194 void handle_moddevtable(struct module *mod, struct elf_info *info,
scripts/mod/sumversion.c+5−1
@@ -391,10 +391,14 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) · 390 unmodified lines
391391 struct md4_ctx md;
392392 char *fname;
393393 char filelist[PATH_MAX + 1];
394+ int postfix_len = 1;
395+
396+ if (strends(modname, ".lto.o"))
397+ postfix_len = 5;
394398
395399 /* objects for a module are listed in the first line of *.mod file. */
396400 snprintf(filelist, sizeof(filelist), "%.*smod",
397− (int)strlen(modname) - 1, modname);
401+ (int)strlen(modname) - postfix_len, modname);
398402
399403 buf = read_text_file(filelist);
400404