From 53727072385d3e9327e2f7c466b49078b09286ae Mon Sep 17 00:00:00 2001 From: Sedat Dilek Date: Thu, 3 Jan 2019 15:03:12 +0100 Subject: [PATCH] x86: Workaround clang does not support asm-goto Only warn once that Clang does not support asm-goto (see LLVM bug #9295). Avoid and thus reduce warnings by adding '-D__BPF_TRACING__' argument to KBUILD_CFLAGS where needed (inspired by [1]). Testing: The patch "jump_label: move 'asm goto' support test to Kconfig" from [2]. [1] https://github.com/ClangBuiltLinux/continuous-integration/blob/master/patches/linux/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch [2] https://lore.kernel.org/patchwork/patch/1028282/ [3] https://github.com/ClangBuiltLinux/linux/issues/6 --- arch/x86/Makefile | 5 +++-- arch/x86/boot/compressed/Makefile | 4 ++++ arch/x86/include/asm/cpufeature.h | 8 -------- drivers/firmware/efi/libstub/Makefile | 4 ++++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 9c5a67d1b9c1..ba8ee0de0397 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -290,8 +290,9 @@ vdso_install: archprepare: checkbin checkbin: ifndef CONFIG_CC_HAS_ASM_GOTO - @echo Compiler lacks asm-goto support. - @exit 1 + @echo Warning: Compiler lacks asm-goto support. + @exit 0 +KBUILD_CFLAGS += -D__BPF_TRACING__ endif ifdef CONFIG_RETPOLINE ifeq ($(RETPOLINE_CFLAGS),) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 466f66c8a7f8..bc8991fede60 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -39,6 +39,10 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += -Wno-pointer-sign +ifndef CONFIG_CC_HAS_ASM_GOTO +KBUILD_CFLAGS += -D__BPF_TRACING__ +endif + KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ GCOV_PROFILE := n UBSAN_SANITIZE :=n diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index ce95b8cbd229..4774fafee82b 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -142,14 +142,6 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); #if defined(__clang__) && !defined(CONFIG_CC_HAS_ASM_GOTO) -/* - * Workaround for the sake of BPF compilation which utilizes kernel - * headers, but clang does not support ASM GOTO and fails the build. - */ -#ifndef __BPF_TRACING__ -#warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments" -#endif - #define static_cpu_has(bit) boot_cpu_has(bit) #else diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index d9845099635e..68ff33dc075d 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -24,6 +24,10 @@ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt +ifndef CONFIG_CC_HAS_ASM_GOTO +cflags-$(CONFIG_X86) += -D__BPF_TRACING__ +endif + KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ -D__NO_FORTIFY \ $(call cc-option,-ffreestanding) \ -- 2.20.1