[llvmlinux] LLVM Integrated assembler rules

Renato Golin renato.golin at linaro.org
Tue Feb 25 13:56:32 UTC 2014


There has been a long discussion on how the integrated assembler has
to behave in the weird cases we've seen on the kernel, and the
conclusions may change how the build system works around LLVM and GCC.

The basic idea is that the integrated assembler *will* validate input,
in a way to continue with LLVM's legacy in being a user-friendly
compiler. We want the user to know about problems as early as
possible.

However, when only compiling the file (to .s), you don't need to run
the integrated assembler (though it does, by default), you can easily
disable via -no-integrated-as or -fno-integrated-as.

To sum up:

$ clang -integrated-as -S

Validates before printing ASM back into the final ASM file. Magic
won't work, here.

$ clang -no-integrated-as -S

Prints whatever comes inline back into the final ASM file. Gandalf style.

$ clang -integrated-as -c

Validates before printing ASM back into the final Object file. As usual.

$ clang -no-integrated-as -c

Prints whatever comes inline back into the final ASM file and call the
external assembler.

Clang can also act as an assembler, so that you're sure you're using
the integrated assembler by setting the "assembler" as "clang
-integrated-as".

So, if you need to compile magic in two steps (c -> s -> o), you can use:

CC=clang -no-integrated-as -S
AS=clang -integrated-as

Of course, you can omit the IAS flag if you know it's enabled/disabled
by default in your architecture. On both x86 and ARM it is.

Does that cover the macro+inline problem we saw in the kernel?

cheers,
--renato


More information about the LLVMLinux mailing list