-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support building with Clang #4
Comments
Cool! What is your workflow in details? I haven't tried to build the kernel with Clang yet. Thanks a lot! |
Yes, that would be quite cool! But even without Clang, this tool is awesome, thank you for it!
Yes, I modified the
Currently I use The quick hack I did to enable Clang (besides installing it) is: --- a/make_linux.py
+++ b/make_linux.py
@@ -19,7 +19,8 @@ def get_cross_compile_args(arch):
if arch == 'i386':
return ['ARCH=i386']
if arch == 'aarch64':
- return ['ARCH=arm64', 'CROSS_COMPILE=aarch64-linux-gnu-']
+ return ['ARCH=arm64', 'CROSS_COMPILE=aarch64-linux-gnu-', 'CC=clang-11'] I've initially wanted to use Clang as assembler as well, but unfortunately arm64 kernel doesn't yet seem to assemble with Clang successfully. |
Hi @xairy ! Hello everyone! I've added the basic clang support in Now we have additional For the Linux kernel compilation, the The kernel build example: $ python3 make_linux.py -a aarch64 -k ~/linux/experiment.config -s ~/linux/linux -o ~/linux/build_out -c clang-12 -- -j5
[+] Going to build the Linux kernel for aarch64
[+] Using "/home/a13x/linux/experiment.config" as kernel config
[+] Using "/home/a13x/linux/linux" as Linux kernel sources directory
[+] Using "/home/a13x/linux/build_out" as build output directory
[+] Going to build with: clang-12
[+] Have additional arguments for 'make': -j5
=== Building with clang-12 ===
Output subdirectory for this build: /home/a13x/linux/build_out/experiment__aarch64__clang-12
Output subdirectory already exists, use it (no cleaning!)
Copy kconfig to output subdirectory as ".config"
Going to save build log to "build_log.txt" in output subdirectory
Compiling with clang requires 'CC=clang'
Add arguments for cross-compilation: ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Run the container: bash ./start_container.sh clang-12 /home/a13x/linux/linux /home/a13x/linux/build_out/experiment__aarch64__clang-12 -n make O=~/out/ CC=clang ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1
Hey, we gonna use sudo for running docker
Starting "kernel-build-container:clang-12"
Source code directory "/home/a13x/linux/linux" is mounted at "~/src"
Build output directory "/home/a13x/linux/build_out/experiment__aarch64__clang-12" is mounted at "~/out"
Run docker in NON-interactive mode
Gonna run "make O=~/out/ CC=clang ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1"
make[1]: Entering directory '/home/a13x/out'
SYNC include/config/auto.conf.cmd
GEN Makefile
...
make[1]: Leaving directory '/home/a13x/out'
The container returned 0
See build log: /home/a13x/linux/build_out/experiment__aarch64__clang-12/build_log.txt
Only remove the container id file:
Hey, we gonna use sudo for running docker
Search "container.id" file in build output directory "/home/a13x/linux/build_out/experiment__aarch64__clang-12"
OK, "container.id" file exists, removing it
OK, container 48a25a340a1ceb3d1ee4baa4eafb1b44ad98c6a70bd105f0376cffb2ba21bd2e doesn't run
Finished with the container
[+] Done, see the results Commits providing this feature: |
I see that README already mentions this, but I have some additional points on this, so I'll just put them here.
Kernel build allows to specify the compiler and the assembler separately. Ideally there's support for at least this three modes: compiler=GCC, assembler=GCC (the one that is implemented right now); compiler=Clang, assembler=GCC (the one I currently use with some hacks on top of the existing code); compiler=Clang, assembler=Clang (the one that eventually might also be useful; requires
LLVM_IAS=1
provided tomake
).There are also multiple different versions of GCC and Clang, which might need to be used in different combinations. E.g. initially I used Clang 10 + GCC 10, but recently switched to Clang 11 + GCC 10, as the kernel doesn't support Clang 10 anymore. Maybe this means that we need a single container with multiple different compilers installed and a way to choose between them.
The text was updated successfully, but these errors were encountered: