On Wed, Feb 07, 2018 at 10:28:38PM +0000, David Woodhouse wrote: > > > On Wed, 2018-02-07 at 13:52 -0800, Guenter Roeck wrote: > > clang has its own set of compiler options for retpoline support. > > > > Link: > > https://github.com/llvm-mirror/clang/commit/0d816739a82da29748caf88570affb9715e18b69 > > Link: > > https://github.com/llvm-mirror/llvm/commit/fd5a8723ce9f2a6b250e85972ef859e4253ea95d > > Link: > > https://github.com/llvm-mirror/llvm/commit/59b64490fda69d29bb42cfdf7eec37bcc31ff833 > > Cc: David Woodhouse <d...@amazon.co.uk> > > Cc: Thomas Gleixner <t...@linutronix.de> > > Cc: Ingo Molnar <mi...@kernel.org> > > Cc: gno...@lxorguk.ukuu.org.uk > > Cc: Rik van Riel <r...@redhat.com> > > Cc: Andi Kleen <a...@linux.intel.com> > > Cc: Josh Poimboeuf <jpoim...@redhat.com> > > Cc: thomas.lenda...@amd.com > > Cc: Peter Zijlstra <pet...@infradead.org> > > Cc: Linus Torvalds <torva...@linux-foundation.org> > > Cc: Jiri Kosina <ji...@kernel.org> > > Cc: Andy Lutomirski <l...@amacapital.net> > > Cc: Dave Hansen <dave.han...@intel.com> > > Cc: Kees Cook <keesc...@google.com> > > Cc: Tim Chen <tim.c.c...@linux.intel.com> > > Cc: Greg Kroah-Hartman <gre...@linux-foundation.org> > > Cc: Paul Turner <p...@google.com> > > Signed-off-by: Guenter Roeck <li...@roeck-us.net> > > --- > > v2: llvm has been updated to use the same thunk names as gcc. > > Tested with: > > clang version 7.0.0 > > (https://git.llvm.org/git/clang.git/ > > 848874aed95a913fb45f363120500cebfe54e2ef) > > (https://git.llvm.org/git/llvm.git/ > > 3afd566557f3616881505db0d69f5d19bf55ae14) > > cross-checked with gcc 7.3.0 (x86_64-linux-gcc.br_real (Buildroot > > 2018.02-rc1) 7.3.0). > > > > Tested with 64-bit builds only; 32-bit images fail to build with clang > > with various unrelated errors and are difficult to test. > > > > I had to change '+=' to '=' below since make otherwise sets > > RETPOLINE_CFLAGS to " ", and the subsequent ifneq would always match. > > This is also the reason for the "ifeq ($(RETPOLINE_CFLAGS),)". > > If there is another/different/better way to handle this, please let > > me know. > > See > http://git.infradead.org/users/dwmw2/linux-retpoline.git/commitdiff/82a1f41600 > Nice. > > > There are curently lots of warnings when building an image with clang. > > > > ./include/linux/init.h:134:6: warning: > > unknown attribute 'indirect_branch' ignored > > > > I was inclined to add "&& !defined(__clang__)" to the condition for the > > __noretpoline define to fix the problem, but concluded that this should > > be a separate patch unless it can be addressed in clang. > > ... where I fixed that too as well as providing the > __x86_indirect_thunk for 32-bit builds (which are broken for other > reasons anyway). >
Much better and more comprehensive than my patch. Let's go with yours. > We do still need the %V asm constraint modifier to work in clang > though, because otherwise it still doesn't build if you have any > hypervisor guest support. Let's see what Chandler's feedback is. Worst case we can handle that in a separate patch; we won't be able to fix all clang problems in a single patch anyway. Thanks, Guenter