clang 3.6 compile failure but clang 3.4 success

Hi,

I just tried clang 3.6 compile on one file in Linux kernel, it failed,
but clang 3.4 can success.
(I didn't apply any patch on clang source code, it's from clang repo
36 release tag)

Anyone can help this would be much appreciated.

In Linux kernel:

jovi@ubuntu:~/linux$ make CC=clang kernel/sched/core.o

  CHK include/config/kernel.release

  CHK include/generated/uapi/linux/version.h

  CHK include/generated/utsrelease.h

  CC kernel/bounds.s

clang: warning: optimization flag '-fno-delete-null-pointer-checks' is
not supported

kernel/bounds.c:18:2: error: unexpected token at start of statement

        DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);

        ^

include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'

        asm volatile("\n->" #sym " %0 " #val : : "i" (val))

                        ^

<inline asm>:2:1: note: instantiated into assembly here

->NR_PAGEFLAGS $25 __NR_PAGEFLAGS

^

kernel/bounds.c:19:2: error: unexpected token at start of statement

        DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);

        ^

include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'

        asm volatile("\n->" #sym " %0 " #val : : "i" (val))

                        ^

<inline asm>:2:1: note: instantiated into assembly here

->MAX_NR_ZONES $4 __MAX_NR_ZONES

^

kernel/bounds.c:21:2: error: unexpected token at start of statement

        DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS));

        ^

include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'

        asm volatile("\n->" #sym " %0 " #val : : "i" (val))

                        ^

<inline asm>:2:1: note: instantiated into assembly here

->NR_CPUS_BITS $8 ilog2(CONFIG_NR_CPUS)

^

kernel/bounds.c:23:2: error: unexpected token at start of statement

        DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t));

        ^

include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'

        asm volatile("\n->" #sym " %0 " #val : : "i" (val))

                        ^

<inline asm>:2:1: note: instantiated into assembly here

->SPINLOCK_SIZE $4 sizeof(spinlock_t)

^

4 errors generated.

Add -no-integrated-as. This is a known abuse of the compiler to output something other than assembly:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-February/070522.html

Hi,

Thanks for help, it works.

After strace clang, I found clang 3.4 don't invoke external assembler
when compile files,
is this means clang 3.4 use integrated assembler? then why clang 3.4
don't failure when compile that kernel file?

Actually what I wish in my case is clang 3.6 don't invoke external
assembler, just like clang 3.4.

Thank you.

You only need to add -no-integrated-as to compile actions like this one that are outputting invalid assembly. If Clang thinks it is going to use the integrated assembler, it will parse the inline assembly to validate that it’s well-formed so we don’t get assembler errors during codegen.