Skip to content

Commit a6b67eb

Browse files
chleroyzx2c4
authored andcommitted
powerpc/vdso: Refactor CFLAGS for CVDSO build
In order to avoid two much duplication when we add new VDSO functionnalities in C like getrandom, refactor common CFLAGS. Signed-off-by: Christophe Leroy <[email protected]> Acked-by: Michael Ellerman <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent b163596 commit a6b67eb

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

arch/powerpc/kernel/vdso/Makefile

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,11 @@ obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o not
1010

1111
ifneq ($(c-gettimeofday-y),)
1212
CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y)
13-
CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
14-
CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector)
15-
CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING
16-
CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
17-
CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
18-
CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
19-
# This flag is supported by clang for 64-bit but not 32-bit so it will cause
20-
# an unused command line flag warning for this file.
21-
ifdef CONFIG_CC_IS_CLANG
22-
CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection
23-
endif
24-
CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
25-
CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
26-
CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
27-
CFLAGS_vgettimeofday-64.o += -DDISABLE_BRANCH_PROFILING
28-
CFLAGS_vgettimeofday-64.o += -ffreestanding -fasynchronous-unwind-tables
29-
CFLAGS_REMOVE_vgettimeofday-64.o = $(CC_FLAGS_FTRACE)
3013
# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true
3114
# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is
3215
# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code
3316
# generation is minimal, it will just use r29 instead.
34-
CFLAGS_vgettimeofday-64.o += $(call cc-option, -ffixed-r30)
17+
CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) $(call cc-option, -ffixed-r30)
3518
endif
3619

3720
# Build rules
@@ -49,6 +32,11 @@ targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o
4932
obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
5033

5134
ccflags-y := -fno-common -fno-builtin
35+
ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN)
36+
ccflags-y += $(call cc-option, -fno-stack-protector)
37+
ccflags-y += -DDISABLE_BRANCH_PROFILING
38+
ccflags-y += -ffreestanding -fasynchronous-unwind-tables
39+
ccflags-remove-y := $(CC_FLAGS_FTRACE)
5240
ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS)
5341
ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
5442
ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
@@ -57,6 +45,12 @@ ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WAR
5745
ldflags-y += $(filter-out $(CC_AUTO_VAR_INIT_ZERO_ENABLER) $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
5846

5947
CC32FLAGS := -m32
48+
CC32FLAGSREMOVE := -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
49+
# This flag is supported by clang for 64-bit but not 32-bit so it will cause
50+
# an unused command line flag warning for this file.
51+
ifdef CONFIG_CC_IS_CLANG
52+
CC32FLAGSREMOVE += -fno-stack-clash-protection
53+
endif
6054
LD32FLAGS := -Wl,-soname=linux-vdso32.so.1
6155
AS32FLAGS := -D__VDSO32__
6256

@@ -105,7 +99,7 @@ quiet_cmd_vdso32ld_and_check = VDSO32L $@
10599
quiet_cmd_vdso32as = VDSO32A $@
106100
cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
107101
quiet_cmd_vdso32cc = VDSO32C $@
108-
cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
102+
cmd_vdso32cc = $(VDSOCC) $(filter-out $(CC32FLAGSREMOVE), $(c_flags)) $(CC32FLAGS) -c -o $@ $<
109103

110104
quiet_cmd_vdso64ld_and_check = VDSO64L $@
111105
cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)

0 commit comments

Comments
 (0)