Skip to content

Commit bf48d9b

Browse files
committed
kbuild: change tool coverage variables to take the path relative to $(obj)
Commit 54b8ae6 ("kbuild: change *FLAGS_<basetarget>.o to take the path relative to $(obj)") changed the syntax of per-file compiler flags. The situation is the same for the following variables: OBJECT_FILES_NON_STANDARD_<basetarget>.o GCOV_PROFILE_<basetarget>.o KASAN_SANITIZE_<basetarget>.o KMSAN_SANITIZE_<basetarget>.o KMSAN_ENABLE_CHECKS_<basetarget>.o UBSAN_SANITIZE_<basetarget>.o KCOV_INSTRUMENT_<basetarget>.o KCSAN_SANITIZE_<basetarget>.o KCSAN_INSTRUMENT_BARRIERS_<basetarget>.o The <basetarget> is the filename of the target with its directory and suffix stripped. This syntax comes into a trouble when two files with the same basename appear in one Makefile, for example: obj-y += dir1/foo.o obj-y += dir2/foo.o OBJECT_FILES_NON_STANDARD_foo.o := y OBJECT_FILES_NON_STANDARD_foo.o is applied to both dir1/foo.o and dir2/foo.o. This syntax is not flexbile enough to handle cases where one of them is a standard object, but the other is not. It is more sensible to use the relative path to the Makefile, like this: obj-y += dir1/foo.o OBJECT_FILES_NON_STANDARD_dir1/foo.o := y obj-y += dir2/foo.o OBJECT_FILES_NON_STANDARD_dir2/foo.o := y To maintain the current behavior, I made adjustments to the following two Makefiles: - arch/x86/entry/vdso/Makefile, which compiles vclock_gettime.o, vgetcpu.o, and their vdso32 variants. - arch/x86/kvm/Makefile, which compiles vmx/vmenter.o and svm/vmenter.o Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Acked-by: Sean Christopherson <[email protected]>
1 parent ba3b759 commit bf48d9b

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

arch/x86/entry/vdso/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ include $(srctree)/lib/vdso/Makefile
99
# Sanitizer runtimes are unavailable and cannot be linked here.
1010
KASAN_SANITIZE := n
1111
KMSAN_SANITIZE_vclock_gettime.o := n
12+
KMSAN_SANITIZE_vdso32/vclock_gettime.o := n
1213
KMSAN_SANITIZE_vgetcpu.o := n
14+
KMSAN_SANITIZE_vdso32/vgetcpu.o := n
1315

1416
UBSAN_SANITIZE := n
1517
KCSAN_SANITIZE := n

arch/x86/kvm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ ccflags-y += -I $(srctree)/arch/x86/kvm
44
ccflags-$(CONFIG_KVM_WERROR) += -Werror
55

66
ifeq ($(CONFIG_FRAME_POINTER),y)
7-
OBJECT_FILES_NON_STANDARD_vmenter.o := y
7+
OBJECT_FILES_NON_STANDARD_vmx/vmenter.o := y
8+
OBJECT_FILES_NON_STANDARD_svm/vmenter.o := y
89
endif
910

1011
include $(srctree)/virt/kvm/Makefile.kvm

scripts/Makefile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
214214
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
215215
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
216216

217-
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n),y)
217+
is-standard-object = $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$(target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),y)
218218

219219
$(obj)/%.o: objtool-enabled = $(if $(is-standard-object),$(if $(delay-objtool),$(is-single-obj-m),y))
220220

scripts/Makefile.lib

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
154154
#
155155
ifeq ($(CONFIG_GCOV_KERNEL),y)
156156
_c_flags += $(if $(patsubst n%,, \
157-
$(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
157+
$(GCOV_PROFILE_$(target-stem).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
158158
$(CFLAGS_GCOV))
159159
endif
160160

@@ -165,29 +165,29 @@ endif
165165
ifeq ($(CONFIG_KASAN),y)
166166
ifneq ($(CONFIG_KASAN_HW_TAGS),y)
167167
_c_flags += $(if $(patsubst n%,, \
168-
$(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \
168+
$(KASAN_SANITIZE_$(target-stem).o)$(KASAN_SANITIZE)y), \
169169
$(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE))
170170
endif
171171
endif
172172

173173
ifeq ($(CONFIG_KMSAN),y)
174174
_c_flags += $(if $(patsubst n%,, \
175-
$(KMSAN_SANITIZE_$(basetarget).o)$(KMSAN_SANITIZE)y), \
175+
$(KMSAN_SANITIZE_$(target-stem).o)$(KMSAN_SANITIZE)y), \
176176
$(CFLAGS_KMSAN))
177177
_c_flags += $(if $(patsubst n%,, \
178-
$(KMSAN_ENABLE_CHECKS_$(basetarget).o)$(KMSAN_ENABLE_CHECKS)y), \
178+
$(KMSAN_ENABLE_CHECKS_$(target-stem).o)$(KMSAN_ENABLE_CHECKS)y), \
179179
, -mllvm -msan-disable-checks=1)
180180
endif
181181

182182
ifeq ($(CONFIG_UBSAN),y)
183183
_c_flags += $(if $(patsubst n%,, \
184-
$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
184+
$(UBSAN_SANITIZE_$(target-stem).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
185185
$(CFLAGS_UBSAN))
186186
endif
187187

188188
ifeq ($(CONFIG_KCOV),y)
189189
_c_flags += $(if $(patsubst n%,, \
190-
$(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
190+
$(KCOV_INSTRUMENT_$(target-stem).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
191191
$(CFLAGS_KCOV))
192192
endif
193193

@@ -197,12 +197,12 @@ endif
197197
#
198198
ifeq ($(CONFIG_KCSAN),y)
199199
_c_flags += $(if $(patsubst n%,, \
200-
$(KCSAN_SANITIZE_$(basetarget).o)$(KCSAN_SANITIZE)y), \
200+
$(KCSAN_SANITIZE_$(target-stem).o)$(KCSAN_SANITIZE)y), \
201201
$(CFLAGS_KCSAN))
202202
# Some uninstrumented files provide implied barriers required to avoid false
203203
# positives: set KCSAN_INSTRUMENT_BARRIERS for barrier instrumentation only.
204204
_c_flags += $(if $(patsubst n%,, \
205-
$(KCSAN_INSTRUMENT_BARRIERS_$(basetarget).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \
205+
$(KCSAN_INSTRUMENT_BARRIERS_$(target-stem).o)$(KCSAN_INSTRUMENT_BARRIERS)n), \
206206
-D__KCSAN_INSTRUMENT_BARRIERS__)
207207
endif
208208

0 commit comments

Comments
 (0)