slides - Linux Plumbers Conference

Using the Clang Integrated Assembler
to Compile the Linux Kernel
Bryce Adelstein-Lelbach, Louisiana State University
What is the Integrated Assembler?
• The Integrated Assembler (IA) is an assembler
built in to the Clang compiler driver
– Not a separate binary like the GNU Assembler (GAS)
• Supports all platforms that Clang supports
• Largely compatible with GAS
• Benefits
– Clang-style diagnostics for assembly
– Faster compile times
– No temporary assembly files
IA Issues
• IA rejects ambiguous inline x86 assembly that
GAS accepts
• IA has no support for 16-bit mode on x86
• IA has no support for switching assembly modes
on x86 (e.g. .code16, .code32, .code64)
• IA does not support GCC-style explicit register
variables (ERVs)
• IA uses ARM Unified Assembly Language (UAL),
and does not support GAS's ARM assembly
Ambiguous x86 Inline Assembly
• GAS is more lenient about accepting inline x86
assembly that is ambiguous. For example:
__asm__("add %al, (%rax)");
__asm__("addw $4, (%rax)");
__asm__("add $4, (%rax)");
• Discussion: how should we fix this?
– Can someone give me an example of when the
more explicit form would be bad?
16-bit Mode/Mode Switching
• LLVM has no x86-16 backend
– Essential for compiling kernel boot code,
bootloaders, etc
• GAS .code16, .code32, .code64 directives
– These directives tell GAS what type of assembly to
• Longer term project
– Discussion: Could this be accomplished in a GSoC?
Explicit Register Variables
• Places a variable into a specific hardware register.
register uint64_t sp __asm__("%rsp");
• Compiler must exclude these registers from
register allocation while the variable is in scope
• Used to access the stack pointer in the kernel
– A possible solution for this use case would be to add
__builtin_stack_pointer() to Clang and GCC.
• Also used in Xen, glibc and most dynamic linkers

similar documents