Compile Driver using Clang
Closed this issue · 0 comments
Problem Statement
By default, the driver is designed to be compiled with GCC, as is typical for most Linux kernels. However, in some cases, the kernel may be compiled with clang. In such instances, we should ensure that our driver can also be compiled using clang. It's generally recommended to avoid using a different compiler than the one used for the kernel, but providing compatibility with clang ensures flexibility in various environments.
Proposed Solution
When the kernel is compiled with clang, our driver can be compiled just as easily by executing the following commands:
sudo apt install -y clang llvm lld
make LLVM=1
If you need to cross-compile the driver, ensure you have the necessary dependencies installed:
sudo apt install -y clang llvm lld
Additionally, you'll need to update the build commands inside both the Makefile and the BearSSL Kbuild file to reflect the use of clang. Replace the existing build command with the following:
$(MAKE) -C $(KBUILD) M=$(PWD) V=$(VERBOSE) CC=$(CLANG) CONFIG_CC_IS_CLANG=y CONFIG_FTRACE_MCOUNT_USE_CC='' CONFIG_RETHUNK='' CONFIG_CC_IS_GCC='' modules
```
At the end:
```
make LLVM=1
```