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 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2OBJECT_FILES_NON_STANDARD := y2OBJECT_FILES_NON_STANDARD := y
3CFLAGS_REMOVE_empty.o += $(CC_FLAGS_LTO)
3 4
4hostprogs-always-y += modpost mk_elfconfig5hostprogs-always-y += modpost mk_elfconfig
5always-y += empty.o6always-y += empty.o
scripts/mod/modpost.c+7−9
@@ -17,7 +17,6 @@ · 16 unmodified lines
17#include <ctype.h>17#include <ctype.h>
18#include <string.h>18#include <string.h>
19#include <limits.h>19#include <limits.h>
20#include <stdbool.h>
21#include <errno.h>20#include <errno.h>
22#include "modpost.h"21#include "modpost.h"
23#include "../../include/linux/license.h"22#include "../../include/linux/license.h"
@@ -84,14 +83,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...) · 60 unmodified lines
84 error_occurred = true;83 error_occurred = true;
85}84}
86 85
87static 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
95void *do_nofail(void *ptr, const char *expr)86void *do_nofail(void *ptr, const char *expr)
96{87{
97 if (!ptr)88 if (!ptr)
@@ -1988,6 +1979,10 @@ static char *remove_dot(char *s) · 1890 unmodified lines
1988 size_t m = strspn(s + n + 1, "0123456789");1979 size_t m = strspn(s + n + 1, "0123456789");
1989 if (m && (s[n + m] == '.' || s[n + m] == 0))1980 if (m && (s[n + m] == '.' || s[n + m] == 0))
1990 s[n] = 0;1981 s[n] = 0;
1982
1983 /* strip trailing .lto */
1984 if (strends(s, ".lto"))
1985 s[strlen(s) - 4] = '\0';
1991 }1986 }
1992 return s;1987 return s;
1993}1988}
@@ -2011,6 +2006,9 @@ static void read_symbols(const char *modname) · 17 unmodified lines
2011 /* strip trailing .o */2006 /* strip trailing .o */
2012 tmp = NOFAIL(strdup(modname));2007 tmp = NOFAIL(strdup(modname));
2013 tmp[strlen(tmp) - 2] = '\0';2008 tmp[strlen(tmp) - 2] = '\0';
2009 /* strip trailing .lto */
2010 if (strends(tmp, ".lto"))
2011 tmp[strlen(tmp) - 4] = '\0';
2014 mod = new_module(tmp);2012 mod = new_module(tmp);
2015 free(tmp);2013 free(tmp);
2016 }2014 }
scripts/mod/modpost.h+9−0
@@ -2,6 +2,7 @@ · 1 unmodified line
2#include <stdio.h>2#include <stdio.h>
3#include <stdlib.h>3#include <stdlib.h>
4#include <stdarg.h>4#include <stdarg.h>
5#include <stdbool.h>
5#include <string.h>6#include <string.h>
6#include <sys/types.h>7#include <sys/types.h>
7#include <sys/stat.h>8#include <sys/stat.h>
@@ -180,6 +181,14 @@ static inline unsigned int get_secindex(const struct elf_info *info, · 172 unmodified lines
180 return info->symtab_shndx_start[sym - info->symtab_start];181 return info->symtab_shndx_start[sym - info->symtab_start];
181}182}
182 183
184static 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
183/* file2alias.c */192/* file2alias.c */
184extern unsigned int cross_build;193extern unsigned int cross_build;
185void handle_moddevtable(struct module *mod, struct elf_info *info,194void 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
391 struct md4_ctx md;391 struct md4_ctx md;
392 char *fname;392 char *fname;
393 char filelist[PATH_MAX + 1];393 char filelist[PATH_MAX + 1];
394 int postfix_len = 1;
395
396 if (strends(modname, ".lto.o"))
397 postfix_len = 5;
394 398
395 /* objects for a module are listed in the first line of *.mod file. */399 /* objects for a module are listed in the first line of *.mod file. */
396 snprintf(filelist, sizeof(filelist), "%.*smod",400 snprintf(filelist, sizeof(filelist), "%.*smod",
397 (int)strlen(modname) - 1, modname);401 (int)strlen(modname) - postfix_len, modname);
398 402
399 buf = read_text_file(filelist);403 buf = read_text_file(filelist);
400 404