首页 > 系统相关 >Ubuntu 18.04 安装Clang/LLVM 11

Ubuntu 18.04 安装Clang/LLVM 11

时间:2022-12-24 17:33:29浏览次数:44  
标签:11 bin LLVM 18.04 -- clang llvm usr

从 APT 安装

Install the GPG Key for https://apt.llvm.org/

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

Add the repo for Clang 11 stable-old for Ubuntu 18.04 Bionic

echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update

Install practically everything (except python-clang-11 which for some reason doesn't work)

sudo apt-get install libllvm-11-ocaml-dev libllvm11 llvm-11 llvm-11-dev llvm-11-doc llvm-11-examples llvm-11-runtime \
clang-11 clang-tools-11 clang-11-doc libclang-common-11-dev libclang-11-dev libclang1-11 clang-format-11 clangd-11 \
libfuzzer-11-dev lldb-11 lld-11 libc++-11-dev libc++abi-11-dev libomp-11-dev -y

Make Clang 11 and everything related to it defaults

sudo update-alternatives \
  --install /usr/lib/llvm              llvm             /usr/lib/llvm-11         50 \
  --slave   /usr/bin/llvm-config       llvm-config      /usr/bin/llvm-config-11  \
  --slave   /usr/bin/llvm-ar           llvm-ar          /usr/bin/llvm-ar-11 \
  --slave   /usr/bin/llvm-as           llvm-as          /usr/bin/llvm-as-11 \
  --slave   /usr/bin/llvm-bcanalyzer   llvm-bcanalyzer  /usr/bin/llvm-bcanalyzer-11 \
  --slave   /usr/bin/llvm-cov          llvm-cov         /usr/bin/llvm-cov-11 \
  --slave   /usr/bin/llvm-diff         llvm-diff        /usr/bin/llvm-diff-11 \
  --slave   /usr/bin/llvm-dis          llvm-dis         /usr/bin/llvm-dis-11 \
  --slave   /usr/bin/llvm-dwarfdump    llvm-dwarfdump   /usr/bin/llvm-dwarfdump-11 \
  --slave   /usr/bin/llvm-extract      llvm-extract     /usr/bin/llvm-extract-11 \
  --slave   /usr/bin/llvm-link         llvm-link        /usr/bin/llvm-link-11 \
  --slave   /usr/bin/llvm-mc           llvm-mc          /usr/bin/llvm-mc-11 \
  --slave   /usr/bin/llvm-mcmarkup     llvm-mcmarkup    /usr/bin/llvm-mcmarkup-11 \
  --slave   /usr/bin/llvm-nm           llvm-nm          /usr/bin/llvm-nm-11 \
  --slave   /usr/bin/llvm-objdump      llvm-objdump     /usr/bin/llvm-objdump-11 \
  --slave   /usr/bin/llvm-ranlib       llvm-ranlib      /usr/bin/llvm-ranlib-11 \
  --slave   /usr/bin/llvm-readobj      llvm-readobj     /usr/bin/llvm-readobj-11 \
  --slave   /usr/bin/llvm-rtdyld       llvm-rtdyld      /usr/bin/llvm-rtdyld-11 \
  --slave   /usr/bin/llvm-size         llvm-size        /usr/bin/llvm-size-11 \
  --slave   /usr/bin/llvm-stress       llvm-stress      /usr/bin/llvm-stress-11 \
  --slave   /usr/bin/llvm-symbolizer   llvm-symbolizer  /usr/bin/llvm-symbolizer-11 \
  --slave   /usr/bin/llvm-tblgen       llvm-tblgen      /usr/bin/llvm-tblgen-11

sudo update-alternatives \
  --install /usr/bin/clang                 clang                  /usr/bin/clang-11    50 \
  --slave   /usr/bin/clang++               clang++                /usr/bin/clang++-11 \
  --slave   /usr/bin/lld                   lld                    /usr/bin/lld-11 \
  --slave   /usr/bin/clang-format          clang-format           /usr/bin/clang-format-11  \
  --slave   /usr/bin/clang-tidy            clang-tidy             /usr/bin/clang-tidy-11  \
  --slave   /usr/bin/clang-tidy-diff.py    clang-tidy-diff.py     /usr/bin/clang-tidy-diff-11.py \
  --slave   /usr/bin/clang-include-fixer   clang-include-fixer    /usr/bin/clang-include-fixer-11 \
  --slave   /usr/bin/clang-offload-bundler clang-offload-bundler  /usr/bin/clang-offload-bundler-11 \
  --slave   /usr/bin/clangd                clangd                 /usr/bin/clangd-11 \
  --slave   /usr/bin/clang-check           clang-check            /usr/bin/clang-check-11 \
  --slave   /usr/bin/scan-view             scan-view              /usr/bin/scan-view-11 \
  --slave   /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-11 \
  --slave   /usr/bin/clang-query           clang-query            /usr/bin/clang-query-11 \
  --slave   /usr/bin/modularize            modularize             /usr/bin/modularize-11 \
  --slave   /usr/bin/sancov                sancov                 /usr/bin/sancov-11 \
  --slave   /usr/bin/c-index-test          c-index-test           /usr/bin/c-index-test-11 \
  --slave   /usr/bin/clang-reorder-fields  clang-reorder-fields   /usr/bin/clang-reorder-fields-11 \
  --slave   /usr/bin/clang-change-namespace clang-change-namespace  /usr/bin/clang-change-namespace-11 \
  --slave   /usr/bin/clang-import-test     clang-import-test      /usr/bin/clang-import-test-11 \
  --slave   /usr/bin/scan-build            scan-build             /usr/bin/scan-build-11 \
  --slave   /usr/bin/scan-build-py         scan-build-py          /usr/bin/scan-build-py-11 \
  --slave   /usr/bin/clang-cl              clang-cl               /usr/bin/clang-cl-11 \
  --slave   /usr/bin/clang-rename          clang-rename           /usr/bin/clang-rename-11 \
  --slave   /usr/bin/find-all-symbols      find-all-symbols       /usr/bin/find-all-symbols-11 \
  --slave   /usr/bin/lldb                  lldb                   /usr/bin/lldb-11 \
  --slave   /usr/bin/lldb-server           lldb-server            /usr/bin/lldb-server-11

Installing CMake

Install Kitware's GPG Key

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null

Add repository

echo "deb https://apt.kitware.com/ubuntu/ bionic main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update

Install this optional package so you don't have to mess with GPG keys anymore

sudo apt-get install kitware-archive-keyring
sudo rm /etc/apt/trusted.gpg.d/kitware.gpg

Now upgrade cmake if you already have it installed with sudo apt-get upgrade -y or just install it using sudo apt-get install cmake -y

使用源码安装

# 更新软件包列表
sudo apt update

# 安装必要的依赖包
sudo apt install build-essential cmake python3-dev

# 下载 Clang/LLVM 11 的源代码
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz

# 解压源代码文件
tar xvf llvm-11.0.0.src.tar.xz

# 进入解压后的目录
cd llvm-11.0.0.src

# 创建一个新的目录,用于存放 Clang/LLVM 编译的结果
mkdir build
cd build

# 使用 cmake 编译 Clang/LLVM
cmake ..

# 编译 Clang/LLVM
make

# 安装 Clang/LLVM
sudo make install

标签:11,bin,LLVM,18.04,--,clang,llvm,usr
From: https://www.cnblogs.com/lifeislife/p/17003075.html

相关文章

  • P1003 [NOIP2011 提高组] 铺地毯
    P1003[NOIP2011提高组]铺地毯题目描述为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯。一共有$n$张地毯......
  • WIN11下的Linux子系统WSL2(hyperV)与VMware多虚拟机共存安装
    第一步,启用hyperV1, 管理员模式运行PowerShell;2, 复制如下命令,输入、回车:Enable-WindowsOptionalFeature-Online-FeatureNameMicrosoft-Hyper-V-All3,如果是第一次安......
  • springMVC11(SSM整合)
    一、框架二、整合流程:三、整合中.........`......
  • AcWing1134/洛谷P1144 最短路计数
    AcWing传送门洛谷传送门题目大意\(\qquad\)给一个无向图,边权都是\(1\),求出以\(1\)为源点,到各个点(\(1\simn\))的最短路数量解题思路\(\qquad\)边权都是\(1\)的图中最......
  • Linux驱动开发11——平台设备驱动
     module_platform_driver(xxx);该宏定义展开为:staticint__initxxx_init(void){returnplatform_driver_register(&xxx);}module_init(xxx_init);stat......
  • C++11:返回值类型后置(跟踪返回值类型)
    返回值类型后置语法,是为了解决函数返回值类型依赖于参数而导致难以确定返回值类型的问题。有了这种语法以后,对返回值类型的推导就可以用清晰的方式(直接通过参数做运算)描述......
  • 洛谷P1196 [NOI2002] 银河英雄传说
    slojP2577.食物链题目大意一个序列初始编号为1,2,3,,,30000有2个操作:mij合并第i列和第j列,将第i列头部接到第j列尾部cIj询问i号和j号之间的数量,若......
  • POJ 1159 Palindrome
    POJ1159Palindrome题意:给出一个字符串,求最少插入多少个字符可以让该字符串变成回文字符串思路1:思路1是卡过去的(用\(short\)换\(int\)和用了一个常数优化),所......
  • 省选11. 字符串
    P3426[POI2005]SZA-Template考虑dp,设\(f(i)\)表示前\(i\)字符所需要的最小印章。\(f(i)\)要么等于\(i\),要么等于\(f(nxt(i))\)。如果存在\(j\geqn-nxt(i)\),......
  • win11的常用设置
    win11休眠按钮显示win11右键显示风格注:以下操作是将win11风格改为win10风格。打开注册表编辑器,定位到HKEY_CURRENT_USER\SOFTWARE\CLASSES\CLSID;右键点击CLSID键......