본문 바로가기

리눅스 커널의 구조와 원리/2. 라즈베리 파이 설정

[우분투/ubuntu] clang12 설치 및 clang 커널 빌드

이번 포스트에서는 우분투에서 clang12를 설치하는 방법을 소개합니다.
참고로 우분투 버전은 20.04입니다. 
 
'sudo apt install clang-12 --install-suggests' 명령어를 사용해 clang12를 설치합니다.
 
$ sudo apt install clang-12 --install-suggests
 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  clang-12-doc fonts-font-awesome fonts-mathjax fonts-mathjax-extras fonts-stix libjs-mathjax libjs-mathjax-doc libjs-modernizr
  libjs-sphinxdoc libjs-underscore libomp-12-doc llvm-12-doc sphinx-rtd-theme-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  clang-12-doc fonts-font-awesome fonts-mathjax fonts-mathjax-extras fonts-stix libclang-common-12-dev libclang-cpp12 libclang1-12
  libjs-mathjax libjs-mathjax-doc libjs-modernizr libjs-sphinxdoc libjs-underscore libomp-12-dev libomp-12-doc libomp5-12 llvm-12
  llvm-12-dev llvm-12-doc llvm-12-linker-tools llvm-12-runtime llvm-12-tools sphinx-rtd-theme-common
The following packages will be REMOVED:
...
etting up libjs-mathjax-doc (2.7+20171212-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for fontconfig (2.13.1-2ubuntu3) ...
 
커널을 빌드할 때 'make CC=clang' 구문을 추가하면 Clang으로 커널 빌드가 됩니다.
 
make CC=clang ARCH=arm64 O=$OUTPUT CROSS_COMPILE=aarch64-linux-gnu- allyesconfig  -j16 2>&1
make CC=clang ARCH=arm64 O=$OUTPUT CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs  -j16 2>&1 | tee $BUILD_LOG