* [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh
@ 2022-05-28 15:47 Masahiro Yamada
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-28 15:47 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, linux-kernel, Josh Poimboeuf, Masahiro Yamada,
Michal Marek
These are cleaned by the top Makefile.
vmlinux.o and .vmlinux.d matches the '*.[aios]' and '.*.d' patterns
respectively.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/link-vmlinux.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index a7f6196c7e41..844fc0125d72 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -309,8 +309,6 @@ cleanup()
rm -f System.map
rm -f vmlinux
rm -f vmlinux.map
- rm -f vmlinux.o
- rm -f .vmlinux.d
rm -f .vmlinux.objs
rm -f .vmlinux.export.c
}
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-05-28 15:47 [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Masahiro Yamada
@ 2022-05-28 15:47 ` Masahiro Yamada
2022-05-29 14:40 ` Sedat Dilek
2022-06-01 19:49 ` Nicolas Schier
2022-05-28 15:47 ` [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o Masahiro Yamada
` (2 subsequent siblings)
3 siblings, 2 replies; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-28 15:47 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, linux-kernel, Josh Poimboeuf, Masahiro Yamada,
Michal Marek
Change the "make clean" rule to remove all the .tmp_* files.
.tmp_objdiff is the only exception, which should be removed by
"make mrproper".
Rename the record directory of objdiff, .tmp_objdiff to .objdiff to
avoid the removal by "make clean".
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 4 ++--
scripts/link-vmlinux.sh | 3 ---
scripts/objdiff | 2 +-
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index edc3f44cd96c..7011d43dff35 100644
--- a/Makefile
+++ b/Makefile
@@ -1490,7 +1490,7 @@ CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
# Directories & files removed with 'make mrproper'
MRPROPER_FILES += include/config include/generated \
- arch/$(SRCARCH)/include/generated .tmp_objdiff \
+ arch/$(SRCARCH)/include/generated .objdiff \
debian snap tar-install \
.config .config.old .version \
Module.symvers \
@@ -1857,7 +1857,7 @@ clean: $(clean-dirs)
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
- -o -name '.tmp_*.o.*' \
+ -o -name '.tmp_*' \
-o -name '*.c.[012]*.*' \
-o -name '*.ll' \
-o -name '*.gcno' \
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 844fc0125d72..b593cb1a8137 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -303,9 +303,6 @@ sorttable()
cleanup()
{
rm -f .btf.*
- rm -f .tmp_System.map
- rm -f .tmp_initcalls.lds
- rm -f .tmp_vmlinux*
rm -f System.map
rm -f vmlinux
rm -f vmlinux.map
diff --git a/scripts/objdiff b/scripts/objdiff
index 72b0b63c3fe1..68b8d74e5c6f 100755
--- a/scripts/objdiff
+++ b/scripts/objdiff
@@ -32,7 +32,7 @@ if [ -z "$SRCTREE" ]; then
exit 1
fi
-TMPD=$SRCTREE/.tmp_objdiff
+TMPD=$SRCTREE/.objdiff
usage() {
echo >&2 "Usage: $0 <command> <args>"
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o
2022-05-28 15:47 [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Masahiro Yamada
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
@ 2022-05-28 15:47 ` Masahiro Yamada
2022-05-29 14:42 ` Sedat Dilek
2022-05-28 15:47 ` [PATCH 4/4] kbuild: factor out the common objtool arguments Masahiro Yamada
2022-05-29 14:37 ` [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Sedat Dilek
3 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-28 15:47 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, linux-kernel, Josh Poimboeuf, Masahiro Yamada,
Michal Marek, Nathan Chancellor, Tom Rix, llvm
This is a preparation for the objtool move in the next commit.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.vmlinux_o | 61 ++++++++++++++++++++++++++++++++++++++
scripts/link-vmlinux.sh | 41 +------------------------
2 files changed, 62 insertions(+), 40 deletions(-)
create mode 100644 scripts/Makefile.vmlinux_o
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
new file mode 100644
index 000000000000..a9b375ca86d5
--- /dev/null
+++ b/scripts/Makefile.vmlinux_o
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+PHONY := __default
+__default: vmlinux.o
+
+include include/config/auto.conf
+include $(srctree)/scripts/Kbuild.include
+
+# Generate a linker script to ensure correct ordering of initcalls for Clang LTO
+# ---------------------------------------------------------------------------
+
+quiet_cmd_gen_initcalls_lds = GEN $@
+ cmd_gen_initcalls_lds = \
+ $(PYTHON3) $(srctree)/scripts/jobserver-exec \
+ $(PERL) $(real-prereqs) > $@
+
+.tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
+ $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+ $(call if_changed,gen_initcalls_lds)
+
+targets := .tmp_initcalls.lds
+
+ifdef CONFIG_LTO_CLANG
+initcalls-lds := .tmp_initcalls.lds
+endif
+
+# Link of vmlinux.o used for section mismatch analysis
+# ---------------------------------------------------------------------------
+
+quiet_cmd_ld_vmlinux.o = LD $@
+ cmd_ld_vmlinux.o = \
+ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \
+ $(addprefix -T , $(initcalls-lds)) \
+ --whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
+ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \
+
+define rule_ld_vmlinux.o
+ $(call cmd_and_savecmd,ld_vmlinux.o)
+endef
+
+vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+ $(call if_changed_rule,ld_vmlinux.o)
+
+targets += vmlinux.o
+
+# Add FORCE to the prequisites of a target to force it to be always rebuilt.
+# ---------------------------------------------------------------------------
+
+PHONY += FORCE
+FORCE:
+
+# Read all saved command lines and dependencies for the $(targets) we
+# may be building above, using $(if_changed{,_dep}). As an
+# optimization, we don't need to read them if the target does not
+# exist, we will rebuild anyway in that case.
+
+existing-targets := $(wildcard $(sort $(targets)))
+
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
+
+.PHONY: $(PHONY)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index b593cb1a8137..90680b6bd710 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -45,45 +45,6 @@ info()
printf " %-7s %s\n" "${1}" "${2}"
}
-# Generate a linker script to ensure correct ordering of initcalls.
-gen_initcalls()
-{
- info GEN .tmp_initcalls.lds
-
- ${PYTHON3} ${srctree}/scripts/jobserver-exec \
- ${PERL} ${srctree}/scripts/generate_initcall_order.pl \
- ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS} \
- > .tmp_initcalls.lds
-}
-
-# Link of vmlinux.o used for section mismatch analysis
-# ${1} output file
-modpost_link()
-{
- local objects
- local lds=""
-
- objects="--whole-archive \
- ${KBUILD_VMLINUX_OBJS} \
- --no-whole-archive \
- --start-group \
- ${KBUILD_VMLINUX_LIBS} \
- --end-group"
-
- if is_enabled CONFIG_LTO_CLANG; then
- gen_initcalls
- lds="-T .tmp_initcalls.lds"
-
- # This might take a while, so indicate that we're doing
- # an LTO link
- info LTO ${1}
- else
- info LD ${1}
- fi
-
- ${LD} ${KBUILD_LDFLAGS} -r -o ${1} ${lds} ${objects}
-}
-
objtool_link()
{
local objtoolcmd;
@@ -336,7 +297,7 @@ fi;
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
#link vmlinux.o
-modpost_link vmlinux.o
+${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
objtool_link vmlinux.o
# Generate the list of objects in vmlinux
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/4] kbuild: factor out the common objtool arguments
2022-05-28 15:47 [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Masahiro Yamada
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
2022-05-28 15:47 ` [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o Masahiro Yamada
@ 2022-05-28 15:47 ` Masahiro Yamada
2022-05-29 14:46 ` Sedat Dilek
2022-05-29 14:37 ` [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Sedat Dilek
3 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-28 15:47 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, linux-kernel, Josh Poimboeuf, Masahiro Yamada,
Michal Marek
scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups
for the objtool arguments.
It is difficult to factor out them because the vmlinux build rule is
written in a shell script. It is somewhat tedious to touch the two
files every time a new objtool option is supported.
To reduce the code duplication, implement everything about objtool in
Makefile.
Move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o.
Move the common macros to Makefile.lib so they are shared by
Makefile.build and Makefile.vmlinux_o.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.build | 26 --------------
scripts/Makefile.lib | 26 ++++++++++++++
scripts/Makefile.vmlinux_o | 26 ++++++++++++++
scripts/link-vmlinux.sh | 71 --------------------------------------
4 files changed, 52 insertions(+), 97 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4cb7145071b9..1f01ac65c0cd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -210,38 +210,12 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),
$(sub_cmd_record_mcount))
endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
-ifdef CONFIG_OBJTOOL
-
-objtool := $(objtree)/tools/objtool/objtool
-
-objtool_args = \
- $(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
- $(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
- $(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
- $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
- $(if $(CONFIG_UNWINDER_ORC), --orc) \
- $(if $(CONFIG_RETPOLINE), --retpoline) \
- $(if $(CONFIG_SLS), --sls) \
- $(if $(CONFIG_STACK_VALIDATION), --stackval) \
- $(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
- --uaccess \
- $(if $(delay-objtool), --link) \
- $(if $(part-of-module), --module) \
- $(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
-
-cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
-cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
-
-endif # CONFIG_OBJTOOL
-
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
-delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
-
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
ifdef CONFIG_TRIM_UNUSED_KSYMS
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index f75138385449..f691fb231ce5 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -225,6 +225,32 @@ dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \
$(addprefix -I,$(DTC_INCLUDE)) \
-undef -D__DTS__
+ifdef CONFIG_OBJTOOL
+
+objtool := $(objtree)/tools/objtool/objtool
+
+objtool_args = \
+ $(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
+ $(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
+ $(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
+ $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
+ $(if $(CONFIG_UNWINDER_ORC), --orc) \
+ $(if $(CONFIG_RETPOLINE), --retpoline) \
+ $(if $(CONFIG_SLS), --sls) \
+ $(if $(CONFIG_STACK_VALIDATION), --stackval) \
+ $(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
+ --uaccess \
+ $(if $(delay-objtool), --link) \
+ $(if $(part-of-module), --module) \
+ $(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
+
+delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
+
+cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
+cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
+
+endif # CONFIG_OBJTOOL
+
# Useful for describing the dependency of composite objects
# Usage:
# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index a9b375ca86d5..3c97a1564947 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -6,6 +6,9 @@ __default: vmlinux.o
include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
+# for objtool
+include $(srctree)/scripts/Makefile.lib
+
# Generate a linker script to ensure correct ordering of initcalls for Clang LTO
# ---------------------------------------------------------------------------
@@ -24,6 +27,27 @@ ifdef CONFIG_LTO_CLANG
initcalls-lds := .tmp_initcalls.lds
endif
+# objtool for vmlinux.o
+# ---------------------------------------------------------------------------
+#
+# For LTO and IBT, objtool doesn't run on individual translation units.
+# Run everything on vmlinux instead.
+
+objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION))
+
+# Reuse objtool_args defined in scripts/Makefile.lib if LTO or IBT is enabled.
+#
+# Add some more flags as needed.
+# --no-unreachable and --link might be added twice, but it is fine.
+#
+# Expand objtool_args to a simple variable to avoid circular reference.
+
+objtool_args := \
+ $(if $(delay-objtool),$(objtool_args)) \
+ $(if $(CONFIG_NOINSTR_VALIDATION), --noinstr) \
+ $(if $(CONFIG_GCOV_KERNEL), --no-unreachable) \
+ --link
+
# Link of vmlinux.o used for section mismatch analysis
# ---------------------------------------------------------------------------
@@ -33,9 +57,11 @@ quiet_cmd_ld_vmlinux.o = LD $@
$(addprefix -T , $(initcalls-lds)) \
--whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
+ $(cmd_objtool)
define rule_ld_vmlinux.o
$(call cmd_and_savecmd,ld_vmlinux.o)
+ $(call cmd,gen_objtooldep)
endef
vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 90680b6bd710..1ac4e180fa3f 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -45,76 +45,6 @@ info()
printf " %-7s %s\n" "${1}" "${2}"
}
-objtool_link()
-{
- local objtoolcmd;
- local objtoolopt;
-
- if ! is_enabled CONFIG_OBJTOOL; then
- return;
- fi
-
- if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then
-
- # For LTO and IBT, objtool doesn't run on individual
- # translation units. Run everything on vmlinux instead.
-
- if is_enabled CONFIG_HAVE_JUMP_LABEL_HACK; then
- objtoolopt="${objtoolopt} --hacks=jump_label"
- fi
-
- if is_enabled CONFIG_HAVE_NOINSTR_HACK; then
- objtoolopt="${objtoolopt} --hacks=noinstr"
- fi
-
- if is_enabled CONFIG_X86_KERNEL_IBT; then
- objtoolopt="${objtoolopt} --ibt"
- fi
-
- if is_enabled CONFIG_FTRACE_MCOUNT_USE_OBJTOOL; then
- objtoolopt="${objtoolopt} --mcount"
- fi
-
- if is_enabled CONFIG_UNWINDER_ORC; then
- objtoolopt="${objtoolopt} --orc"
- fi
-
- if is_enabled CONFIG_RETPOLINE; then
- objtoolopt="${objtoolopt} --retpoline"
- fi
-
- if is_enabled CONFIG_SLS; then
- objtoolopt="${objtoolopt} --sls"
- fi
-
- if is_enabled CONFIG_STACK_VALIDATION; then
- objtoolopt="${objtoolopt} --stackval"
- fi
-
- if is_enabled CONFIG_HAVE_STATIC_CALL_INLINE; then
- objtoolopt="${objtoolopt} --static-call"
- fi
-
- objtoolopt="${objtoolopt} --uaccess"
- fi
-
- if is_enabled CONFIG_NOINSTR_VALIDATION; then
- objtoolopt="${objtoolopt} --noinstr"
- fi
-
- if [ -n "${objtoolopt}" ]; then
-
- if is_enabled CONFIG_GCOV_KERNEL; then
- objtoolopt="${objtoolopt} --no-unreachable"
- fi
-
- objtoolopt="${objtoolopt} --link"
-
- info OBJTOOL ${1}
- tools/objtool/objtool ${objtoolopt} ${1}
- fi
-}
-
# Link of vmlinux
# ${1} - output file
# ${2}, ${3}, ... - optional extra .o files
@@ -298,7 +228,6 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
#link vmlinux.o
${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
-objtool_link vmlinux.o
# Generate the list of objects in vmlinux
for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh
2022-05-28 15:47 [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Masahiro Yamada
` (2 preceding siblings ...)
2022-05-28 15:47 ` [PATCH 4/4] kbuild: factor out the common objtool arguments Masahiro Yamada
@ 2022-05-29 14:37 ` Sedat Dilek
2022-05-29 17:30 ` Masahiro Yamada
3 siblings, 1 reply; 16+ messages in thread
From: Sedat Dilek @ 2022-05-29 14:37 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, linux-kernel, Josh Poimboeuf,
Michal Marek
On Sat, May 28, 2022 at 10:20 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> These are cleaned by the top Makefile.
>
> vmlinux.o and .vmlinux.d matches the '*.[aios]' and '.*.d' patterns
> respectively.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
I applied this patchset on top of yesterday's kbuild.git#for-next
(today's did not fit due to "kbuild: do not try to parse *.cmd files
for objects provided by compiler").
Might be related to this patchset or not:
$ LC_ALL=C ll .*vmlinux*export*
-rw-r--r-- 1 dileks dileks 4.2K May 29 15:11 ..vmlinux.export.o.cmd
-rw-r--r-- 1 dileks dileks 508K May 29 15:11 .vmlinux.export.c
-rw-r--r-- 1 dileks dileks 2.6M May 29 15:11 .vmlinux.export.o
You see the leading double-dot for ..vmlinux.export.o.cmd - intended or not?
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
-Sedat-
> ---
>
> scripts/link-vmlinux.sh | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index a7f6196c7e41..844fc0125d72 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -309,8 +309,6 @@ cleanup()
> rm -f System.map
> rm -f vmlinux
> rm -f vmlinux.map
> - rm -f vmlinux.o
> - rm -f .vmlinux.d
> rm -f .vmlinux.objs
> rm -f .vmlinux.export.c
> }
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
@ 2022-05-29 14:40 ` Sedat Dilek
2022-05-29 17:32 ` Masahiro Yamada
2022-06-01 19:49 ` Nicolas Schier
1 sibling, 1 reply; 16+ messages in thread
From: Sedat Dilek @ 2022-05-29 14:40 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, linux-kernel, Josh Poimboeuf,
Michal Marek
On Sat, May 28, 2022 at 9:43 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Change the "make clean" rule to remove all the .tmp_* files.
>
> .tmp_objdiff is the only exception, which should be removed by
> "make mrproper".
>
> Rename the record directory of objdiff, .tmp_objdiff to .objdiff to
> avoid the removal by "make clean".
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
When does someone see .objdiff file(s)?
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
( Never seen here. )
-Sedat-
> ---
>
> Makefile | 4 ++--
> scripts/link-vmlinux.sh | 3 ---
> scripts/objdiff | 2 +-
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index edc3f44cd96c..7011d43dff35 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1490,7 +1490,7 @@ CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
>
> # Directories & files removed with 'make mrproper'
> MRPROPER_FILES += include/config include/generated \
> - arch/$(SRCARCH)/include/generated .tmp_objdiff \
> + arch/$(SRCARCH)/include/generated .objdiff \
> debian snap tar-install \
> .config .config.old .version \
> Module.symvers \
> @@ -1857,7 +1857,7 @@ clean: $(clean-dirs)
> -o -name '*.lex.c' -o -name '*.tab.[ch]' \
> -o -name '*.asn1.[ch]' \
> -o -name '*.symtypes' -o -name 'modules.order' \
> - -o -name '.tmp_*.o.*' \
> + -o -name '.tmp_*' \
> -o -name '*.c.[012]*.*' \
> -o -name '*.ll' \
> -o -name '*.gcno' \
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 844fc0125d72..b593cb1a8137 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -303,9 +303,6 @@ sorttable()
> cleanup()
> {
> rm -f .btf.*
> - rm -f .tmp_System.map
> - rm -f .tmp_initcalls.lds
> - rm -f .tmp_vmlinux*
> rm -f System.map
> rm -f vmlinux
> rm -f vmlinux.map
> diff --git a/scripts/objdiff b/scripts/objdiff
> index 72b0b63c3fe1..68b8d74e5c6f 100755
> --- a/scripts/objdiff
> +++ b/scripts/objdiff
> @@ -32,7 +32,7 @@ if [ -z "$SRCTREE" ]; then
> exit 1
> fi
>
> -TMPD=$SRCTREE/.tmp_objdiff
> +TMPD=$SRCTREE/.objdiff
>
> usage() {
> echo >&2 "Usage: $0 <command> <args>"
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o
2022-05-28 15:47 ` [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o Masahiro Yamada
@ 2022-05-29 14:42 ` Sedat Dilek
0 siblings, 0 replies; 16+ messages in thread
From: Sedat Dilek @ 2022-05-29 14:42 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, linux-kernel, Josh Poimboeuf,
Michal Marek, Nathan Chancellor, Tom Rix, llvm
On Sat, May 28, 2022 at 8:25 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> This is a preparation for the objtool move in the next commit.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
-Sedat-
> ---
>
> scripts/Makefile.vmlinux_o | 61 ++++++++++++++++++++++++++++++++++++++
> scripts/link-vmlinux.sh | 41 +------------------------
> 2 files changed, 62 insertions(+), 40 deletions(-)
> create mode 100644 scripts/Makefile.vmlinux_o
>
> diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
> new file mode 100644
> index 000000000000..a9b375ca86d5
> --- /dev/null
> +++ b/scripts/Makefile.vmlinux_o
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +PHONY := __default
> +__default: vmlinux.o
> +
> +include include/config/auto.conf
> +include $(srctree)/scripts/Kbuild.include
> +
> +# Generate a linker script to ensure correct ordering of initcalls for Clang LTO
> +# ---------------------------------------------------------------------------
> +
> +quiet_cmd_gen_initcalls_lds = GEN $@
> + cmd_gen_initcalls_lds = \
> + $(PYTHON3) $(srctree)/scripts/jobserver-exec \
> + $(PERL) $(real-prereqs) > $@
> +
> +.tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
> + $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
> + $(call if_changed,gen_initcalls_lds)
> +
> +targets := .tmp_initcalls.lds
> +
> +ifdef CONFIG_LTO_CLANG
> +initcalls-lds := .tmp_initcalls.lds
> +endif
> +
> +# Link of vmlinux.o used for section mismatch analysis
> +# ---------------------------------------------------------------------------
> +
> +quiet_cmd_ld_vmlinux.o = LD $@
> + cmd_ld_vmlinux.o = \
> + $(LD) ${KBUILD_LDFLAGS} -r -o $@ \
> + $(addprefix -T , $(initcalls-lds)) \
> + --whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
> + --start-group $(KBUILD_VMLINUX_LIBS) --end-group \
> +
> +define rule_ld_vmlinux.o
> + $(call cmd_and_savecmd,ld_vmlinux.o)
> +endef
> +
> +vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
> + $(call if_changed_rule,ld_vmlinux.o)
> +
> +targets += vmlinux.o
> +
> +# Add FORCE to the prequisites of a target to force it to be always rebuilt.
> +# ---------------------------------------------------------------------------
> +
> +PHONY += FORCE
> +FORCE:
> +
> +# Read all saved command lines and dependencies for the $(targets) we
> +# may be building above, using $(if_changed{,_dep}). As an
> +# optimization, we don't need to read them if the target does not
> +# exist, we will rebuild anyway in that case.
> +
> +existing-targets := $(wildcard $(sort $(targets)))
> +
> +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
> +
> +.PHONY: $(PHONY)
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index b593cb1a8137..90680b6bd710 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -45,45 +45,6 @@ info()
> printf " %-7s %s\n" "${1}" "${2}"
> }
>
> -# Generate a linker script to ensure correct ordering of initcalls.
> -gen_initcalls()
> -{
> - info GEN .tmp_initcalls.lds
> -
> - ${PYTHON3} ${srctree}/scripts/jobserver-exec \
> - ${PERL} ${srctree}/scripts/generate_initcall_order.pl \
> - ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS} \
> - > .tmp_initcalls.lds
> -}
> -
> -# Link of vmlinux.o used for section mismatch analysis
> -# ${1} output file
> -modpost_link()
> -{
> - local objects
> - local lds=""
> -
> - objects="--whole-archive \
> - ${KBUILD_VMLINUX_OBJS} \
> - --no-whole-archive \
> - --start-group \
> - ${KBUILD_VMLINUX_LIBS} \
> - --end-group"
> -
> - if is_enabled CONFIG_LTO_CLANG; then
> - gen_initcalls
> - lds="-T .tmp_initcalls.lds"
> -
> - # This might take a while, so indicate that we're doing
> - # an LTO link
> - info LTO ${1}
> - else
> - info LD ${1}
> - fi
> -
> - ${LD} ${KBUILD_LDFLAGS} -r -o ${1} ${lds} ${objects}
> -}
> -
> objtool_link()
> {
> local objtoolcmd;
> @@ -336,7 +297,7 @@ fi;
> ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
>
> #link vmlinux.o
> -modpost_link vmlinux.o
> +${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
> objtool_link vmlinux.o
>
> # Generate the list of objects in vmlinux
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] kbuild: factor out the common objtool arguments
2022-05-28 15:47 ` [PATCH 4/4] kbuild: factor out the common objtool arguments Masahiro Yamada
@ 2022-05-29 14:46 ` Sedat Dilek
2022-05-29 17:34 ` Masahiro Yamada
0 siblings, 1 reply; 16+ messages in thread
From: Sedat Dilek @ 2022-05-29 14:46 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, linux-kernel, Josh Poimboeuf,
Michal Marek
On Sat, May 28, 2022 at 9:45 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups
> for the objtool arguments.
>
> It is difficult to factor out them because the vmlinux build rule is
> written in a shell script. It is somewhat tedious to touch the two
> files every time a new objtool option is supported.
>
> To reduce the code duplication, implement everything about objtool in
> Makefile.
>
> Move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o.
>
> Move the common macros to Makefile.lib so they are shared by
> Makefile.build and Makefile.vmlinux_o.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
With some comments (see below).
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
-Sedat-
> ---
>
> scripts/Makefile.build | 26 --------------
> scripts/Makefile.lib | 26 ++++++++++++++
> scripts/Makefile.vmlinux_o | 26 ++++++++++++++
> scripts/link-vmlinux.sh | 71 --------------------------------------
> 4 files changed, 52 insertions(+), 97 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 4cb7145071b9..1f01ac65c0cd 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -210,38 +210,12 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),
> $(sub_cmd_record_mcount))
> endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
>
> -ifdef CONFIG_OBJTOOL
> -
> -objtool := $(objtree)/tools/objtool/objtool
> -
> -objtool_args = \
> - $(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
> - $(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
> - $(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
> - $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
> - $(if $(CONFIG_UNWINDER_ORC), --orc) \
> - $(if $(CONFIG_RETPOLINE), --retpoline) \
> - $(if $(CONFIG_SLS), --sls) \
> - $(if $(CONFIG_STACK_VALIDATION), --stackval) \
> - $(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
> - --uaccess \
> - $(if $(delay-objtool), --link) \
> - $(if $(part-of-module), --module) \
> - $(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
> -
> -cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
> -cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
> -
> -endif # CONFIG_OBJTOOL
> -
> # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
> # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
> # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
>
^^ What is with this block?
If this belongs together with objtool - shall this be moved, too?
> is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
>
> -delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
> -
> $(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
>
> ifdef CONFIG_TRIM_UNUSED_KSYMS
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index f75138385449..f691fb231ce5 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -225,6 +225,32 @@ dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \
> $(addprefix -I,$(DTC_INCLUDE)) \
> -undef -D__DTS__
>
> +ifdef CONFIG_OBJTOOL
> +
> +objtool := $(objtree)/tools/objtool/objtool
> +
> +objtool_args = \
> + $(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
> + $(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
> + $(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
> + $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
> + $(if $(CONFIG_UNWINDER_ORC), --orc) \
> + $(if $(CONFIG_RETPOLINE), --retpoline) \
> + $(if $(CONFIG_SLS), --sls) \
> + $(if $(CONFIG_STACK_VALIDATION), --stackval) \
> + $(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
> + --uaccess \
> + $(if $(delay-objtool), --link) \
> + $(if $(part-of-module), --module) \
> + $(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
> +
> +delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
> +
> +cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
> +cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
> +
> +endif # CONFIG_OBJTOOL
> +
> # Useful for describing the dependency of composite objects
> # Usage:
> # $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
> diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
> index a9b375ca86d5..3c97a1564947 100644
> --- a/scripts/Makefile.vmlinux_o
> +++ b/scripts/Makefile.vmlinux_o
> @@ -6,6 +6,9 @@ __default: vmlinux.o
> include include/config/auto.conf
> include $(srctree)/scripts/Kbuild.include
>
> +# for objtool
> +include $(srctree)/scripts/Makefile.lib
> +
> # Generate a linker script to ensure correct ordering of initcalls for Clang LTO
> # ---------------------------------------------------------------------------
>
> @@ -24,6 +27,27 @@ ifdef CONFIG_LTO_CLANG
> initcalls-lds := .tmp_initcalls.lds
> endif
>
> +# objtool for vmlinux.o
> +# ---------------------------------------------------------------------------
> +#
> +# For LTO and IBT, objtool doesn't run on individual translation units.
> +# Run everything on vmlinux instead.
> +
> +objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION))
> +
> +# Reuse objtool_args defined in scripts/Makefile.lib if LTO or IBT is enabled.
> +#
> +# Add some more flags as needed.
> +# --no-unreachable and --link might be added twice, but it is fine.
> +#
> +# Expand objtool_args to a simple variable to avoid circular reference.
> +
> +objtool_args := \
> + $(if $(delay-objtool),$(objtool_args)) \
> + $(if $(CONFIG_NOINSTR_VALIDATION), --noinstr) \
> + $(if $(CONFIG_GCOV_KERNEL), --no-unreachable) \
> + --link
> +
> # Link of vmlinux.o used for section mismatch analysis
> # ---------------------------------------------------------------------------
>
> @@ -33,9 +57,11 @@ quiet_cmd_ld_vmlinux.o = LD $@
> $(addprefix -T , $(initcalls-lds)) \
> --whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
> --start-group $(KBUILD_VMLINUX_LIBS) --end-group \
> + $(cmd_objtool)
>
> define rule_ld_vmlinux.o
> $(call cmd_and_savecmd,ld_vmlinux.o)
> + $(call cmd,gen_objtooldep)
> endef
>
> vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 90680b6bd710..1ac4e180fa3f 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -45,76 +45,6 @@ info()
> printf " %-7s %s\n" "${1}" "${2}"
> }
>
> -objtool_link()
> -{
> - local objtoolcmd;
> - local objtoolopt;
> -
> - if ! is_enabled CONFIG_OBJTOOL; then
> - return;
> - fi
> -
> - if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then
> -
> - # For LTO and IBT, objtool doesn't run on individual
> - # translation units. Run everything on vmlinux instead.
> -
> - if is_enabled CONFIG_HAVE_JUMP_LABEL_HACK; then
> - objtoolopt="${objtoolopt} --hacks=jump_label"
> - fi
> -
> - if is_enabled CONFIG_HAVE_NOINSTR_HACK; then
> - objtoolopt="${objtoolopt} --hacks=noinstr"
> - fi
> -
> - if is_enabled CONFIG_X86_KERNEL_IBT; then
> - objtoolopt="${objtoolopt} --ibt"
> - fi
> -
> - if is_enabled CONFIG_FTRACE_MCOUNT_USE_OBJTOOL; then
> - objtoolopt="${objtoolopt} --mcount"
> - fi
> -
> - if is_enabled CONFIG_UNWINDER_ORC; then
> - objtoolopt="${objtoolopt} --orc"
> - fi
> -
> - if is_enabled CONFIG_RETPOLINE; then
> - objtoolopt="${objtoolopt} --retpoline"
> - fi
> -
> - if is_enabled CONFIG_SLS; then
> - objtoolopt="${objtoolopt} --sls"
> - fi
> -
> - if is_enabled CONFIG_STACK_VALIDATION; then
> - objtoolopt="${objtoolopt} --stackval"
> - fi
> -
> - if is_enabled CONFIG_HAVE_STATIC_CALL_INLINE; then
> - objtoolopt="${objtoolopt} --static-call"
> - fi
> -
> - objtoolopt="${objtoolopt} --uaccess"
> - fi
> -
> - if is_enabled CONFIG_NOINSTR_VALIDATION; then
> - objtoolopt="${objtoolopt} --noinstr"
> - fi
> -
> - if [ -n "${objtoolopt}" ]; then
> -
> - if is_enabled CONFIG_GCOV_KERNEL; then
> - objtoolopt="${objtoolopt} --no-unreachable"
> - fi
> -
> - objtoolopt="${objtoolopt} --link"
> -
> - info OBJTOOL ${1}
> - tools/objtool/objtool ${objtoolopt} ${1}
> - fi
> -}
> -
> # Link of vmlinux
> # ${1} - output file
> # ${2}, ${3}, ... - optional extra .o files
> @@ -298,7 +228,6 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
>
> #link vmlinux.o
^^ While you are at it, change the comment to "# Link of vmlinux.o".
> ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
> -objtool_link vmlinux.o
>
> # Generate the list of objects in vmlinux
> for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh
2022-05-29 14:37 ` [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Sedat Dilek
@ 2022-05-29 17:30 ` Masahiro Yamada
2022-05-30 9:33 ` Sedat Dilek
0 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-29 17:30 UTC (permalink / raw)
To: Sedat Dilek
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 11:38 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Sat, May 28, 2022 at 10:20 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > These are cleaned by the top Makefile.
> >
> > vmlinux.o and .vmlinux.d matches the '*.[aios]' and '.*.d' patterns
> > respectively.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> I applied this patchset on top of yesterday's kbuild.git#for-next
> (today's did not fit due to "kbuild: do not try to parse *.cmd files
> for objects provided by compiler").
>
> Might be related to this patchset or not:
>
> $ LC_ALL=C ll .*vmlinux*export*
> -rw-r--r-- 1 dileks dileks 4.2K May 29 15:11 ..vmlinux.export.o.cmd
> -rw-r--r-- 1 dileks dileks 508K May 29 15:11 .vmlinux.export.c
> -rw-r--r-- 1 dileks dileks 2.6M May 29 15:11 .vmlinux.export.o
>
> You see the leading double-dot for ..vmlinux.export.o.cmd - intended or not?
This is intended.
The source file (.vmlinux.export.c) is a dot file.
.*.cmd prepends one more dot.
>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
>
> -Sedat-
>
> > ---
> >
> > scripts/link-vmlinux.sh | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> > index a7f6196c7e41..844fc0125d72 100755
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
> > @@ -309,8 +309,6 @@ cleanup()
> > rm -f System.map
> > rm -f vmlinux
> > rm -f vmlinux.map
> > - rm -f vmlinux.o
> > - rm -f .vmlinux.d
> > rm -f .vmlinux.objs
> > rm -f .vmlinux.export.c
> > }
> > --
> > 2.32.0
> >
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-05-29 14:40 ` Sedat Dilek
@ 2022-05-29 17:32 ` Masahiro Yamada
2022-05-30 9:34 ` Sedat Dilek
0 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-29 17:32 UTC (permalink / raw)
To: Sedat Dilek
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 11:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Sat, May 28, 2022 at 9:43 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Change the "make clean" rule to remove all the .tmp_* files.
> >
> > .tmp_objdiff is the only exception, which should be removed by
> > "make mrproper".
> >
> > Rename the record directory of objdiff, .tmp_objdiff to .objdiff to
> > avoid the removal by "make clean".
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> When does someone see .objdiff file(s)?
It is created when you run scripts/objdiff
>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
> ( Never seen here. )
>
> -Sedat-
>
> > ---
> >
> > Makefile | 4 ++--
> > scripts/link-vmlinux.sh | 3 ---
> > scripts/objdiff | 2 +-
> > 3 files changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index edc3f44cd96c..7011d43dff35 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1490,7 +1490,7 @@ CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
> >
> > # Directories & files removed with 'make mrproper'
> > MRPROPER_FILES += include/config include/generated \
> > - arch/$(SRCARCH)/include/generated .tmp_objdiff \
> > + arch/$(SRCARCH)/include/generated .objdiff \
> > debian snap tar-install \
> > .config .config.old .version \
> > Module.symvers \
> > @@ -1857,7 +1857,7 @@ clean: $(clean-dirs)
> > -o -name '*.lex.c' -o -name '*.tab.[ch]' \
> > -o -name '*.asn1.[ch]' \
> > -o -name '*.symtypes' -o -name 'modules.order' \
> > - -o -name '.tmp_*.o.*' \
> > + -o -name '.tmp_*' \
> > -o -name '*.c.[012]*.*' \
> > -o -name '*.ll' \
> > -o -name '*.gcno' \
> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> > index 844fc0125d72..b593cb1a8137 100755
> > --- a/scripts/link-vmlinux.sh
> > +++ b/scripts/link-vmlinux.sh
> > @@ -303,9 +303,6 @@ sorttable()
> > cleanup()
> > {
> > rm -f .btf.*
> > - rm -f .tmp_System.map
> > - rm -f .tmp_initcalls.lds
> > - rm -f .tmp_vmlinux*
> > rm -f System.map
> > rm -f vmlinux
> > rm -f vmlinux.map
> > diff --git a/scripts/objdiff b/scripts/objdiff
> > index 72b0b63c3fe1..68b8d74e5c6f 100755
> > --- a/scripts/objdiff
> > +++ b/scripts/objdiff
> > @@ -32,7 +32,7 @@ if [ -z "$SRCTREE" ]; then
> > exit 1
> > fi
> >
> > -TMPD=$SRCTREE/.tmp_objdiff
> > +TMPD=$SRCTREE/.objdiff
> >
> > usage() {
> > echo >&2 "Usage: $0 <command> <args>"
> > --
> > 2.32.0
> >
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] kbuild: factor out the common objtool arguments
2022-05-29 14:46 ` Sedat Dilek
@ 2022-05-29 17:34 ` Masahiro Yamada
2022-05-30 9:36 ` Sedat Dilek
0 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2022-05-29 17:34 UTC (permalink / raw)
To: Sedat Dilek
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 11:47 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Sat, May 28, 2022 at 9:45 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups
> > for the objtool arguments.
> >
> > It is difficult to factor out them because the vmlinux build rule is
> > written in a shell script. It is somewhat tedious to touch the two
> > files every time a new objtool option is supported.
> >
> > To reduce the code duplication, implement everything about objtool in
> > Makefile.
> >
> > Move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o.
> >
> > Move the common macros to Makefile.lib so they are shared by
> > Makefile.build and Makefile.vmlinux_o.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> With some comments (see below).
>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
>
> -Sedat-
>
> > ---
> >
> > scripts/Makefile.build | 26 --------------
> > scripts/Makefile.lib | 26 ++++++++++++++
> > scripts/Makefile.vmlinux_o | 26 ++++++++++++++
> > scripts/link-vmlinux.sh | 71 --------------------------------------
> > 4 files changed, 52 insertions(+), 97 deletions(-)
> >
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 4cb7145071b9..1f01ac65c0cd 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -210,38 +210,12 @@ cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),
> > $(sub_cmd_record_mcount))
> > endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
> >
> > -ifdef CONFIG_OBJTOOL
> > -
> > -objtool := $(objtree)/tools/objtool/objtool
> > -
> > -objtool_args = \
> > - $(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
> > - $(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
> > - $(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
> > - $(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
> > - $(if $(CONFIG_UNWINDER_ORC), --orc) \
> > - $(if $(CONFIG_RETPOLINE), --retpoline) \
> > - $(if $(CONFIG_SLS), --sls) \
> > - $(if $(CONFIG_STACK_VALIDATION), --stackval) \
> > - $(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
> > - --uaccess \
> > - $(if $(delay-objtool), --link) \
> > - $(if $(part-of-module), --module) \
> > - $(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
> > -
> > -cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
> > -cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
> > -
> > -endif # CONFIG_OBJTOOL
> > -
> > # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
> > # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
> > # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
> >
>
> ^^ What is with this block?
> If this belongs together with objtool - shall this be moved, too?
No.
These are unneeded for vmlinux.o
> > - fi
> > -}
> > -
> > # Link of vmlinux
> > # ${1} - output file
> > # ${2}, ${3}, ... - optional extra .o files
> > @@ -298,7 +228,6 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
> >
> > #link vmlinux.o
>
> ^^ While you are at it, change the comment to "# Link of vmlinux.o".
In my plan, this code will be gone sooner or later.
It would be a noise.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh
2022-05-29 17:30 ` Masahiro Yamada
@ 2022-05-30 9:33 ` Sedat Dilek
0 siblings, 0 replies; 16+ messages in thread
From: Sedat Dilek @ 2022-05-30 9:33 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 7:32 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
...
> > Might be related to this patchset or not:
> >
> > $ LC_ALL=C ll .*vmlinux*export*
> > -rw-r--r-- 1 dileks dileks 4.2K May 29 15:11 ..vmlinux.export.o.cmd
> > -rw-r--r-- 1 dileks dileks 508K May 29 15:11 .vmlinux.export.c
> > -rw-r--r-- 1 dileks dileks 2.6M May 29 15:11 .vmlinux.export.o
> >
> > You see the leading double-dot for ..vmlinux.export.o.cmd - intended or not?
>
> This is intended.
>
> The source file (.vmlinux.export.c) is a dot file.
>
> .*.cmd prepends one more dot.
>
Fine with me.
-sed@-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-05-29 17:32 ` Masahiro Yamada
@ 2022-05-30 9:34 ` Sedat Dilek
0 siblings, 0 replies; 16+ messages in thread
From: Sedat Dilek @ 2022-05-30 9:34 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 7:33 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
...
> > When does someone see .objdiff file(s)?
>
> It is created when you run scripts/objdiff
>
Never used this - thanks for the info.
-sed@-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] kbuild: factor out the common objtool arguments
2022-05-29 17:34 ` Masahiro Yamada
@ 2022-05-30 9:36 ` Sedat Dilek
0 siblings, 0 replies; 16+ messages in thread
From: Sedat Dilek @ 2022-05-30 9:36 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Sun, May 29, 2022 at 7:36 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
...
> > > # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
> > > # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
> > > # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
> > >
> >
> > ^^ What is with this block?
> > If this belongs together with objtool - shall this be moved, too?
>
> No.
> These are unneeded for vmlinux.o
>
OK.
> > > #link vmlinux.o
> >
> > ^^ While you are at it, change the comment to "# Link of vmlinux.o".
>
>
> In my plan, this code will be gone sooner or later.
>
> It would be a noise.
>
Hope you have fruitful plans :-).
-sed@-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
2022-05-29 14:40 ` Sedat Dilek
@ 2022-06-01 19:49 ` Nicolas Schier
2022-06-03 13:22 ` Masahiro Yamada
1 sibling, 1 reply; 16+ messages in thread
From: Nicolas Schier @ 2022-06-01 19:49 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, linux-kernel, Josh Poimboeuf,
Michal Marek
On Sun 29 May 2022 00:47:02 +0900, Masahiro Yamada wrote:
> Change the "make clean" rule to remove all the .tmp_* files.
>
> .tmp_objdiff is the only exception, which should be removed by
> "make mrproper".
>
> Rename the record directory of objdiff, .tmp_objdiff to .objdiff to
> avoid the removal by "make clean".
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Makefile | 4 ++--
> scripts/link-vmlinux.sh | 3 ---
> scripts/objdiff | 2 +-
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
...
> diff --git a/scripts/objdiff b/scripts/objdiff
> index 72b0b63c3fe1..68b8d74e5c6f 100755
> --- a/scripts/objdiff
> +++ b/scripts/objdiff
> @@ -32,7 +32,7 @@ if [ -z "$SRCTREE" ]; then
> exit 1
> fi
>
> -TMPD=$SRCTREE/.tmp_objdiff
> +TMPD=$SRCTREE/.objdiff
>
> usage() {
> echo >&2 "Usage: $0 <command> <args>"
scripts/objdiff still has two occurrences of .tmp_objdiff (in the
comment block at the top).
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean
2022-06-01 19:49 ` Nicolas Schier
@ 2022-06-03 13:22 ` Masahiro Yamada
0 siblings, 0 replies; 16+ messages in thread
From: Masahiro Yamada @ 2022-06-03 13:22 UTC (permalink / raw)
To: Nicolas Schier
Cc: Linux Kbuild mailing list, Nick Desaulniers,
Linux Kernel Mailing List, Josh Poimboeuf, Michal Marek
On Thu, Jun 2, 2022 at 4:50 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Sun 29 May 2022 00:47:02 +0900, Masahiro Yamada wrote:
> > Change the "make clean" rule to remove all the .tmp_* files.
> >
> > .tmp_objdiff is the only exception, which should be removed by
> > "make mrproper".
> >
> > Rename the record directory of objdiff, .tmp_objdiff to .objdiff to
> > avoid the removal by "make clean".
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > Makefile | 4 ++--
> > scripts/link-vmlinux.sh | 3 ---
> > scripts/objdiff | 2 +-
> > 3 files changed, 3 insertions(+), 6 deletions(-)
> >
> ...
> > diff --git a/scripts/objdiff b/scripts/objdiff
> > index 72b0b63c3fe1..68b8d74e5c6f 100755
> > --- a/scripts/objdiff
> > +++ b/scripts/objdiff
> > @@ -32,7 +32,7 @@ if [ -z "$SRCTREE" ]; then
> > exit 1
> > fi
> >
> > -TMPD=$SRCTREE/.tmp_objdiff
> > +TMPD=$SRCTREE/.objdiff
> >
> > usage() {
> > echo >&2 "Usage: $0 <command> <args>"
>
> scripts/objdiff still has two occurrences of .tmp_objdiff (in the
> comment block at the top).
Ah, thank you for catching it.
I sent a fixup.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-06-03 13:23 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 15:47 [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Masahiro Yamada
2022-05-28 15:47 ` [PATCH 2/4] kbuild: clean .tmp_* pattern by make clean Masahiro Yamada
2022-05-29 14:40 ` Sedat Dilek
2022-05-29 17:32 ` Masahiro Yamada
2022-05-30 9:34 ` Sedat Dilek
2022-06-01 19:49 ` Nicolas Schier
2022-06-03 13:22 ` Masahiro Yamada
2022-05-28 15:47 ` [PATCH 3/4] kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o Masahiro Yamada
2022-05-29 14:42 ` Sedat Dilek
2022-05-28 15:47 ` [PATCH 4/4] kbuild: factor out the common objtool arguments Masahiro Yamada
2022-05-29 14:46 ` Sedat Dilek
2022-05-29 17:34 ` Masahiro Yamada
2022-05-30 9:36 ` Sedat Dilek
2022-05-29 14:37 ` [PATCH 1/4] kbuild: remove redundant cleanups in scripts/link-vmlinux.sh Sedat Dilek
2022-05-29 17:30 ` Masahiro Yamada
2022-05-30 9:33 ` Sedat Dilek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.