On Mon, Jul 30, 2018 at 10:21 AM, Mark Rutland wrote: > On Sun, Jul 29, 2018 at 08:12:00PM +0200, Sedat Dilek wrote: >> [ TO Mark Rutland ] >> >> Hi, > > Hi, > >> I was able to build a Linux v4.18-rc6 with tip.git#locking/core [1] on >> top of it here on Debian/buster AMD64. >> >> The patch of interest is [2]... >> >> df79ed2c0643 locking/atomics: Simplify cmpxchg() instrumentation >> >> ...and some more locking/atomics[/x86] may be interesting. >> >> I had also to apply an asm-goto fix to reduce the number of warnings >> when building with clang-7 (version >> 7.0.0-svn337957-1~exp1+0~20180725200907.1908~1.gbpcccb1b (trunk)). > > Just to be clear, clang 7.0.0 has not been released yet, and this is a > trunk build of clang, right? > [ CC Kees and Colin ] Sorry, for not being precise on my build environment and my experimenting for followers. My clang is a snaphot aka clang-7 (svn-trunk: svn337957) from . My system is Debian/testing (which will be buster) AMD64. > Do any released versions of clang (e.g. 6.0.1) build a working kernel? > I haven't tried v6.0.1 from Debian/testing. >> CONFIG_DRM_AMDGPU=m is BROKEN and a known issue [3]. >> >> I had to hack my fakeroot-sysv binary to workaround a fatal build-stop >> by commenting the part "nested operation not yet supported" when using >> bindeb-pkg make-target. > > Does upstream build at all with clang, or are you always having to apply > a number of modifications? > > Which config are you using? > The config is based on the config from thr package in Debian/experimental [1]. With these modifications... LINUX_CONFIG='./.config' ; for config in X86_X32 MODULE_SIG MODULE_SIG_KEY SYSTEM_TRUSTED_KEYS DRM_AMDGPU ; do echo [ $config ] ; scripts/config --file $LINUX_CONFIG --disable $config ; done I do not use signed-certs for my modules and amdgpu is known to be broken as module. Both configs are attached - the one I used for my experiments and the one from Debian/experimental. [1] https://packages.debian.org/experimental/linux-image-4.18.0-rc4-amd64-unsigned >> The kernel does ***not boot*** on bare metal. > > Ok. Does the prior commit boot? > I cannot say as I was not able to compile with clang since the commit 8bf705d13039 mentioned here in the subject. Kees pointed me to issue #7 "__builtin_constant_p() does not work in deep inline functions" which is the cause for not booting. The issue is known as #7. My qemu-log.txt is attached for details if you want to look at. [1] https://github.com/ClangBuiltLinux/linux/issues/7 >> More details see [4] and [5] for the clang-side. > > It's not clear to me how these relate to the patch in question. AFAICT, > those are build-time errors, but you say that the kernel doesn't boot > (which implies it built). > > Are [4,5] relevant to this commit, or to the (unrelated) issue [3]? > > My patch removes the switch, so this doesn't look like the same issue. > ClangBuiltLinux issue #3 "clang validates extended assembly constraints of dead code" is the problem on the clang-side. Matthias and Jan commented on the thread [1] if you want to read. You fixed the issue on the kernel-side, so that I could build a Linux v4.18-rc6 with clang-7 (trunk). This is a huge progress - really. [1] https://groups.google.com/forum/#!topic/kasan-dev/oMgCP37n1vw Is this a bit clearer, now? Many Thanks, Sedat > Thanks, > Mark. > >> >> - Sedat - >> >> [1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/log/?h=locking/core >> [2] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=locking/core&id=df79ed2c064363cdc7d2d896923c1885d4e30520 >> [3] https://lists.freedesktop.org/archives/amd-gfx/2018-July/024634.html >> [4] https://github.com/ClangBuiltLinux/linux/issues/3 >> [5] https://bugs.llvm.org/show_bug.cgi?id=33587 > >> From 5c3485197eab808768271d72e188ad11b6fcecd4 Mon Sep 17 00:00:00 2001 >> From: Sedat Dilek >> Date: Fri, 8 Jun 2018 18:23:26 +0200 >> Subject: [PATCH] x86: Warn clang does not support asm-goto >> >> Signed-off-by: Sedat Dilek >> --- >> arch/x86/Makefile | 2 +- >> arch/x86/include/asm/cpufeature.h | 9 +-------- >> 2 files changed, 2 insertions(+), 9 deletions(-) >> >> diff --git a/arch/x86/Makefile b/arch/x86/Makefile >> index a08e82856563..6042f6f5a1be 100644 >> --- a/arch/x86/Makefile >> +++ b/arch/x86/Makefile >> @@ -181,7 +181,7 @@ ifdef CONFIG_FUNCTION_GRAPH_TRACER >> endif >> >> ifndef CC_HAVE_ASM_GOTO >> - $(error Compiler lacks asm-goto support.) >> + $(warning Compiler lacks asm-goto support.) >> endif >> >> # >> diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h >> index aced6c9290d6..79177f0efdf1 100644 >> --- a/arch/x86/include/asm/cpufeature.h >> +++ b/arch/x86/include/asm/cpufeature.h >> @@ -140,16 +140,9 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); >> >> #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) >> >> +/* Clang does not support asm-goto (see LLVM bug #9295). */ >> #if defined(__clang__) && !defined(CC_HAVE_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 >> -- >> 2.18.0 >> > >