When using the clang integrated assembler, we get a reference
to __force_order that should normally get ignored in a few
rare cases:

ERROR: modpost: "__force_order" [drivers/cpufreq/powernow-k6.ko] undefined!

Add a 'static' definition so any file in which this happens can
have a local copy.

Signed-off-by: Arnd Bergmann <a...@arndb.de>
---
 arch/x86/boot/compressed/pgtable_64.c | 2 ++
 arch/x86/include/asm/special_insns.h  | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/x86/boot/compressed/pgtable_64.c 
b/arch/x86/boot/compressed/pgtable_64.c
index c8862696a47b..8595194cea41 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -12,7 +12,9 @@
  * It is not referenced from the code, but GCC < 5 with -fPIE would fail
  * due to an undefined symbol. Define it to make these ancient GCCs work.
  */
+#ifndef CONFIG_CC_IS_CLANG
 unsigned long __force_order;
+#endif
 
 #define BIOS_START_MIN         0x20000U        /* 128K, less than this is 
insane */
 #define BIOS_START_MAX         0x9f000U        /* 640K, absolute maximum */
diff --git a/arch/x86/include/asm/special_insns.h 
b/arch/x86/include/asm/special_insns.h
index 82436cb04ccf..7081e587c1ea 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -16,8 +16,15 @@
  * A memory clobber would solve the problem, but would prevent reordering of
  * all loads stores around it, which can hurt performance. Solution is to
  * use a variable and mimic reads and writes to it to enforce serialization
+ *
+ * Clang sometimes fails to kill the reference to the dummy variable, so
+ * provide an actual copy.
  */
+#ifdef CONFIG_CC_IS_CLANG
+static unsigned long __force_order;
+#else
 extern unsigned long __force_order;
+#endif
 
 void native_write_cr0(unsigned long val);
 
-- 
2.26.2

Reply via email to