History

Merge tag 'clang-lto-v5.12-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull more clang LTO updates from Kees Cook: "Clang LTO x86 enablement. Full disclosure: while this has _not_ been in linux-next (since it initially looked like the objtool dependencies weren't going to make v5.12), it has been under daily build and runtime testing by Sami for quite some time. These x86 portions have been discussed on lkml, with Peter, Josh, and others helping nail things down. The bulk of the changes are to get objtool working happily. The rest of the x86 enablement is very small. Summary: - Generate __mcount_loc in objtool (Peter Zijlstra) - Support running objtool against vmlinux.o (Sami Tolvanen) - Clang LTO enablement for x86 (Sami Tolvanen)" Link: https://lore.kernel.org/lkml/20201013003203.4168817-26-samitolvanen@google.com/ Link: https://lore.kernel.org/lkml/cover.1611263461.git.jpoimboe@redhat.com/ * tag 'clang-lto-v5.12-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: kbuild: lto: force rebuilds when switching CONFIG_LTO x86, build: allow LTO to be selected x86, cpu: disable LTO for cpu.c x86, vdso: disable LTO only for vDSO kbuild: lto: postpone objtool objtool: Split noinstr validation from --vmlinux x86, build: use objtool mcount tracing: add support for objtool mcount objtool: Don't autodetect vmlinux.o objtool: Fix __mcount_loc generation with Clang's assembler objtool: Add a pass for generating __mcount_loc

Linus Torvalds committed 5 years ago

Commit 414eece2 parents 6dd580b 5e9532516 files · +195 −33Browse files

Showing the changes to scripts (4 of 16 files). Show all

Unified · Split

4 files
  1. scripts/Makefile.build +2 −17
  2. scripts/Makefile.lib +12 −0
  3. scripts/Makefile.modfinal +16 −3
  4. scripts/link-vmlinux.sh +25 −3
scripts/Makefile.build+2−17
@@ -218,27 +218,11 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), · 217 unmodified lines
218endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT218endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
219 219
220ifdef CONFIG_STACK_VALIDATION220ifdef CONFIG_STACK_VALIDATION
221ifndef CONFIG_LTO_CLANG
221ifneq ($(SKIP_STACK_VALIDATION),1)222ifneq ($(SKIP_STACK_VALIDATION),1)
222 223
223__objtool_obj := $(objtree)/tools/objtool/objtool224__objtool_obj := $(objtree)/tools/objtool/objtool
224 225
225objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check)
226
227objtool_args += $(if $(part-of-module), --module,)
228
229ifndef CONFIG_FRAME_POINTER
230objtool_args += --no-fp
231endif
232ifdef CONFIG_GCOV_KERNEL
233objtool_args += --no-unreachable
234endif
235ifdef CONFIG_RETPOLINE
236 objtool_args += --retpoline
237endif
238ifdef CONFIG_X86_SMAP
239 objtool_args += --uaccess
240endif
241
242# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory226# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
243# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file227# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
244# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file228# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
@@ -250,6 +234,7 @@ objtool_obj = $(if $(patsubst y%,, \ · 5 unmodified lines
250 $(__objtool_obj))234 $(__objtool_obj))
251 235
252endif # SKIP_STACK_VALIDATION236endif # SKIP_STACK_VALIDATION
237endif # CONFIG_LTO_CLANG
253endif # CONFIG_STACK_VALIDATION238endif # CONFIG_STACK_VALIDATION
254 239
255# Rebuild all objects when objtool changes, or is enabled/disabled.240# Rebuild all objects when objtool changes, or is enabled/disabled.
scripts/Makefile.lib+12−0
@@ -222,6 +222,18 @@ dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \ · 221 unmodified lines
222 $(addprefix -I,$(DTC_INCLUDE)) \222 $(addprefix -I,$(DTC_INCLUDE)) \
223 -undef -D__DTS__223 -undef -D__DTS__
224 224
225# Objtool arguments are also needed for modfinal with LTO, so we define
226# then here to avoid duplication.
227objtool_args = \
228 $(if $(CONFIG_UNWINDER_ORC),orc generate,check) \
229 $(if $(part-of-module), --module,) \
230 $(if $(CONFIG_FRAME_POINTER),, --no-fp) \
231 $(if $(or $(CONFIG_GCOV_KERNEL),$(CONFIG_LTO_CLANG)), \
232 --no-unreachable,) \
233 $(if $(CONFIG_RETPOLINE), --retpoline,) \
234 $(if $(CONFIG_X86_SMAP), --uaccess,) \
235 $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount,)
236
225# Useful for describing the dependency of composite objects237# Useful for describing the dependency of composite objects
226# Usage:238# Usage:
227# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)239# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
scripts/Makefile.modfinal+16−3
@@ -9,7 +9,7 @@ __modfinal: · 8 unmodified lines
9include include/config/auto.conf9include include/config/auto.conf
10include $(srctree)/scripts/Kbuild.include10include $(srctree)/scripts/Kbuild.include
11 11
12# for c_flags12# for c_flags and objtool_args
13include $(srctree)/scripts/Makefile.lib13include $(srctree)/scripts/Makefile.lib
14 14
15# find all modules listed in modules.order15# find all modules listed in modules.order
@@ -34,10 +34,23 @@ ifdef CONFIG_LTO_CLANG · 18 unmodified lines
34# With CONFIG_LTO_CLANG, reuse the object file we compiled for modpost to34# With CONFIG_LTO_CLANG, reuse the object file we compiled for modpost to
35# avoid a second slow LTO link35# avoid a second slow LTO link
36prelink-ext := .lto36prelink-ext := .lto
37endif37
38# ELF processing was skipped earlier because we didn't have native code,
39# so let's now process the prelinked binary before we link the module.
40
41ifdef CONFIG_STACK_VALIDATION
42ifneq ($(SKIP_STACK_VALIDATION),1)
43cmd_ld_ko_o += \
44 $(objtree)/tools/objtool/objtool $(objtool_args) \
45 $(@:.ko=$(prelink-ext).o);
46
47endif # SKIP_STACK_VALIDATION
48endif # CONFIG_STACK_VALIDATION
49
50endif # CONFIG_LTO_CLANG
38 51
39quiet_cmd_ld_ko_o = LD [M] $@52quiet_cmd_ld_ko_o = LD [M] $@
40 cmd_ld_ko_o = \53 cmd_ld_ko_o += \
41 $(LD) -r $(KBUILD_LDFLAGS) \54 $(LD) -r $(KBUILD_LDFLAGS) \
42 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \55 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
43 -T scripts/module.lds -o $@ $(filter %.o, $^); \56 -T scripts/module.lds -o $@ $(filter %.o, $^); \
scripts/link-vmlinux.sh+25−3
@@ -103,14 +103,36 @@ modpost_link() · 102 unmodified lines
103 103
104objtool_link()104objtool_link()
105{105{
106 local objtoolcmd;
106 local objtoolopt;107 local objtoolopt;
107 108
109 if [ "${CONFIG_LTO_CLANG} ${CONFIG_STACK_VALIDATION}" = "y y" ]; then
110 # Don't perform vmlinux validation unless explicitly requested,
111 # but run objtool on vmlinux.o now that we have an object file.
112 if [ -n "${CONFIG_UNWINDER_ORC}" ]; then
113 objtoolcmd="orc generate"
114 fi
115
116 objtoolopt="${objtoolopt} --duplicate"
117
118 if [ -n "${CONFIG_FTRACE_MCOUNT_USE_OBJTOOL}" ]; then
119 objtoolopt="${objtoolopt} --mcount"
120 fi
121 fi
122
108 if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then123 if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then
109 objtoolopt="check"124 objtoolopt="${objtoolopt} --noinstr"
125 fi
126
127 if [ -n "${objtoolopt}" ]; then
128 if [ -z "${objtoolcmd}" ]; then
129 objtoolcmd="check"
130 fi
131 objtoolopt="${objtoolopt} --vmlinux"
110 if [ -z "${CONFIG_FRAME_POINTER}" ]; then132 if [ -z "${CONFIG_FRAME_POINTER}" ]; then
111 objtoolopt="${objtoolopt} --no-fp"133 objtoolopt="${objtoolopt} --no-fp"
112 fi134 fi
113 if [ -n "${CONFIG_GCOV_KERNEL}" ]; then135 if [ -n "${CONFIG_GCOV_KERNEL}" ] || [ -n "${CONFIG_LTO_CLANG}" ]; then
114 objtoolopt="${objtoolopt} --no-unreachable"136 objtoolopt="${objtoolopt} --no-unreachable"
115 fi137 fi
116 if [ -n "${CONFIG_RETPOLINE}" ]; then138 if [ -n "${CONFIG_RETPOLINE}" ]; then
@@ -120,7 +142,7 @@ objtool_link() · 3 unmodified lines
120 objtoolopt="${objtoolopt} --uaccess"142 objtoolopt="${objtoolopt} --uaccess"
121 fi143 fi
122 info OBJTOOL ${1}144 info OBJTOOL ${1}
123 tools/objtool/objtool ${objtoolopt} ${1}145 tools/objtool/objtool ${objtoolcmd} ${objtoolopt} ${1}
124 fi146 fi
125}147}
126 148

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t