문제

Linux kernel is written for compiling with gcc and uses a lot of small and ugly gcc-hacks. Which compilers can compile linux kernel except gcc?

The one, which can, is the Intel Compiler. What minimal version of it is needed for kernel compiling?

There also was a Tiny C compiler, but it was able to compile only reduced and specially edited version of the kernel.

Is there other compilers capable of building kernel?

도움이 되었습니까?

해결책 2

There is ongoing process of committing LLVMLinux patches into vanilla kernel (2013-2014).

The LLVMLinux is project by The Linux Foundation: http://llvm.linuxfoundation.org/ to enable vanilla kernel to be built with LLVM. Lot of patches are prepared by Behan Webster, who is LLVMLinux project lead.

There is LWN article about the project from May 2013 https://lwn.net/Articles/549203/ "LFCS: The LLVMLinux project"

Current status of LLVMLinux project is tracked at page http://llvm.linuxfoundation.org/index.php/Bugs#Linux_Kernel_Issues

Things (basically gcc-isms) already eliminated from kernel: * Expicit Registers Variables (non-C99) * VLAIS (non C99-compliant undocumented GCC feature "Variable length arrays in structs") like struct S { int array[N];} or even struct S { int array[N]; int array_usb_gadget[M]; } where N and M are non-constant function argument * Nested Functions (Ada feature ported into C by GCC/Gnat developers; not allowed in C99) * Some gcc/gas magic like special segments, or macro

Things to be done: * Usage of __builtin_constant_p builtin to implement scary magic like BUILD_BUG_ON(!__builtin_constant_p(offset));

The good news about LLVMLinux are that after its patches kernel not only becomes buildable with LLVM+clang, but also easier to build by other non-GCC compilers, because the project kills much not C99 code like VLAIS, created by usb gadget author, by netfilter hackers, and by crypto subsystem hackers; also nested functions are killed.

다른 팁

An outdatet information: you need to patch the kernel in order to compile using the Intel CC Download Linux kernel patch for Intel® Compiler

See also Is it possible to compile Linux kernel with something other than gcc for further links and information

On of the most recent sources :http://forums.fedoraforum.org/showthread.php?p=1328718

In short, you cannot, because the kernel code was written to take advantage of the gcc's compiler semantics...and between the kernel and the compiled code, the relationship is a very strong one, i.e. must be compiled with gcc...Since gcc uses 'ELF' (Embedded Linking Format) object files, the kernel must be built using the object code format. Unless you can hack it up to work with another compiler - it may well compile but may not work, as the compilers under Windows produces PE code, there could be unexpected results, meaning the kernel may not boot at all!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top