In this brief technical how-to guide, we’ll discuss using the latest Intel® oneAPI DPC++/C++ Compiler to build a Linux kernel. Using the Intel Compiler allows you to take advantage of the latest Intel hardware features and compiler optimizations. Additionally, it provides access to error message handling, LLVM *sanitizer access for compile-time debug assistance, and the full power and flexibility of the LLVM compiler infrastructure.
Compiler Transition Towards LLVM
With the Intel® oneAPI Toolkits 2024.0 release in October 2024, the Intel® C++ Compiler Classic has been removed from the distribution package, and its ongoing development has been halted. The new Intel oneAPI DPC++/C++ Compiler leverages the LLVM framework and its open-source philosophy. Leading up to this transition have been decades of Intel embracing the open-source community and actively contributing to open standards development, whether we are talking about contributing to and driving UEFI*, the GNU* ecosystem, LLVM*, Clang*, SYCL*, or the Unified Acceleration Foundation* (UXL).
The completion of the transition from the previous closed Intel C++ Compiler Classic to the open Intel oneAPI DPC++/C++ Compiler implies that the frontend has also shifted from the traditional Edison Design Group* (EDG) standard to the Clang/LLVM approach.
Kernel Build Instructions
As such, it is no surprise that the Linux kernel build instructions also differ, and are more in line with and similar to the steps described in the Building Linux with Clang/LLVM found at Kernel.Org. There are, however, additional modifications and considerations.
This document details the changes needed to build the Linux Kernel with the current generation Intel Compilers.
Step 1: Configure Base Location Makefile
The example in this document is based on Linux Kernel version 6.12.34 from Kernel.Org. The Linux Kernel must already be extracted, and the workspace must point to the extracted folder. The first required change for the Linux Kernel code should be to add the following instructions to the base location Makefile:
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
# Code to be added
else ifneq ($(findstring Intel,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
# End of code to be added
endif
The Intel oneAPI DPC++/C++ Compiler uses the same make scripts required for clang, and adding the additional check to detect “Intel” will allow its icx or icpx frontend command interface to be used by the clang make scripts.
Step 2: Configure Kernel Make Settings
Before building the kernel, the configuration options should be generated. Below is a modified call to bring up the menu to configure the make settings for the kernel.
$ make CC=icx menuconfig
Mentioning CC=icx or CC=icpx in the command line specifies that the kernel build uses the Intel Compiler. When the command opens the configuration menu, Binary Emulations should be selected, and IA32 Emulation must be disabled. The flag -m32, which IA32 Emulation enables, is not currently supported.
Select Binary Emulations Configuration with IA32 Emulation Disabled
|
Figure 1: Disable IA32 Emulation for Kernel Build
Step 3: Executing the Kernel Build Makefile
After configuring the options for the Linux Kernel, the below should be called when compiling the kernel.
$ make CC=icx CXX=icpx HOSTCC=icx HOSTCXX=icpx all NOSTDINC_FLAGS="-ffreestanding"
Note:
-ffreestanding removes implicitly added Intel libraries to ensure no external libraries are used, since external libraries are not allowed unless the library is a module.
The Linux Kernel was built successfully when all these steps have been completed.
# kernel build log completion
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
OBJCOPY arch/x86/boot/vmlinux.bin
HOSTCC arch/x86/boot/tools/build
BUILD arch/x86/boot/bzImage
Kernel: arch/x86/boot/bzImage is ready (#1)
Step 4: Install the New Kernel
Finally, as with any Linux kernel, we execute a set of commands similar to the ones below, depending on the target distribution, to install the kernel into the Linux file system and add it to the bootloader:
$ sudo make modules_install
$ sudo make install
$ sudo update-initramfs -c -k <kernel version>
$ sudo update-grub
Summary of Kernel Build Setting Changes
1. Add the following code to the kernel Makefile:
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
# Code to be added
else ifneq ($(findstring Intel,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
# End of code to be added
endif
2. Call to Kernel Configuration Menu:
$ make CC=icx menuconfig
and disable IA32 Emulation located in Binary Emulations
3. Execute the Kernel Build Makefile:
$ make CC=icx CXX=icpx HOSTCC=icx HOSTCXX=icpx all NOSTDINC_FLAGS="-ffreestanding"
Your new Linux kernel is now ready to be installed and used.
Summary and Next Steps
In this brief how-to article, we discussed using the Intel oneAPI DPC++/C++ Compiler to build optimized custom Linux kernels leveraging the LLVM compiler framework.
Join the evolution of Clang/LLVM compiler technology and learn about Intel’s many contributions to the open-source open-standards community at the Intel staging area for llvm.org contributions. Home for Intel LLVM-based projects.
Get the Compiler
You can install the Intel® oneAPI DPC++/C++ Compiler as a part of the Intel® oneAPI Base Toolkit or the Intel® oneAPI HPC Toolkit. You can also download a standalone version of the compiler.
Additional Resources
Here are some detailed resources Intel oneAPI DPC++/C++ Compiler usage for you to explore:
- oneAPI DPC++/C++ Compiler Landing Page
- oneAPI DPC++/C++ Compiler Get Started Guide
- oneAPI DPC++/C++ Compiler Developer Guide and Reference
- Intel® oneAPI Toolkits 2025.2 – Parallelism Unleashed