CentOS9的yum安装llvm/clang与测试简述

  1. 查看源中最新的llvm:
[root@LAPTOP-UKGHM5UJ ~]# yum list |grep llvm
llvm.x86_64                                          15.0.1-1.el9                        @appstream
llvm-libs.x86_64                                     15.0.1-1.el9                        @appstream
llvm-toolset.x86_64                                  15.0.1-1.el9                        @appstream
llvm.i686                                            15.0.1-1.el9                        appstream
llvm-devel.i686                                      15.0.1-1.el9                        appstream
llvm-devel.x86_64                                    15.0.1-1.el9                        appstream
llvm-doc.noarch                                      15.0.1-1.el9                        appstream
llvm-googletest.x86_64                               15.0.1-1.el9                        appstream
llvm-libs.i686                                       15.0.1-1.el9                        appstream
llvm-static.i686                                     15.0.1-1.el9                        appstream
llvm-static.x86_64                                   15.0.1-1.el9                        appstream
llvm-test.i686                                       15.0.1-1.el9                        appstream
llvm-test.x86_64                                     15.0.1-1.el9                        appstream
  1. 安装
[root@LAPTOP-UKGHM5UJ ~]# yum install llvm-toolset.x86_64 -y
.
.
.
Installed:
  clang-15.0.1-2.el9.x86_64                                      clang-libs-15.0.1-2.el9.x86_64
  clang-resource-filesystem-15.0.1-2.el9.x86_64                  compiler-rt-15.0.1-1.el9.x86_64
  gcc-toolset-12-gcc-12.1.1-3.2.el9.x86_64                       gcc-toolset-12-gcc-c++-12.1.1-3.2.el9.x86_64
  gcc-toolset-12-libstdc++-devel-12.1.1-3.2.el9.x86_64           libatomic-11.3.1-4.el9.x86_64
  libomp-15.0.1-2.el9.x86_64                                     libomp-devel-15.0.1-2.el9.x86_64
  lld-15.0.1-2.el9.x86_64                                        lld-libs-15.0.1-2.el9.x86_64
  llvm-toolset-15.0.1-1.el9.x86_64

Complete!
  1. clang与llvm的版本与使用测试

版本查看

[root@LAPTOP-UKGHM5UJ ~]# clang --version
clang version 15.0.1 (Red Hat 15.0.1-2.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

[root@LAPTOP-UKGHM5UJ ~]# yum info llvm
Last metadata expiration check: 0:12:29 ago on Thu 08 Dec 2022 04:18:09 PM CST.
Installed Packages
Name         : llvm
Version      : 15.0.1


Available Packages
Name         : llvm
Version      : 15.0.1
Release      : 1.el9

clang与llvm的IR文件测试:

[root@LAPTOP-UKGHM5UJ llvm]# vim test.c
int main(){
        return 0;
}
[root@LAPTOP-UKGHM5UJ llvm]# clang test.c -o test
[root@LAPTOP-UKGHM5UJ llvm]# clang -S -emit-llvm test.c
[root@LAPTOP-UKGHM5UJ llvm]# llvm-as test.ll

[root@LAPTOP-UKGHM5UJ llvm]# ls
test  test.bc  test.c  test.ll

[root@LAPTOP-UKGHM5UJ llvm]# cat test.ll
; ModuleID = 'test.c'
source_filename = "test.c"

[root@LAPTOP-UKGHM5UJ llvm]# file test.bc
test.bc: LLVM IR bitcode

你可能感兴趣的:(编程,程序career,linux,bash,运维,CentOS,llvm)