Forked from junkdog/update-alternatives-clang.sh
Last active
January 16, 2022 16:13
-
-
Save BeErikk/53d771d7ffe781b15d11a952a1800d84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# shellcheck shell=sh | |
# This code is free for any use by anyone under the terms of | |
# Creative Commons Attribution-NonCommercial 4.0 International Public License | |
# See the the file license.txt and https://creativecommons.org | |
# Jerker Bäck 2021, based on work by Jesse Cooke | |
# How to use: | |
# sudo ./update-alternatives-clang.sh 12 120 | |
llvm_update_alternatives() { | |
local version=$1 | |
local priority=$2 | |
update-alternatives \ | |
--verbose \ | |
--install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-"${version}" "${priority}" \ | |
--slave /usr/bin/analyze-build analyze-build /usr/bin/analyze-build-"${version}" \ | |
--slave /usr/bin/asan_symbolize asan_symbolize /usr/bin/asan_symbolize-"${version}" \ | |
--slave /usr/bin/bugpoint bugpoint /usr/bin/bugpoint-"${version}" \ | |
--slave /usr/bin/c-index-test c-index-test /usr/bin/c-index-test-"${version}" \ | |
--slave /usr/bin/clang clang /usr/bin/clang-"${version}" \ | |
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-"${version}" \ | |
--slave /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-"${version}" \ | |
--slave /usr/bin/clang-change-namespace clang-change-namespace /usr/bin/clang-change-namespace-"${version}" \ | |
--slave /usr/bin/clang-check clang-check /usr/bin/clang-check-"${version}" \ | |
--slave /usr/bin/clang-cl clang-cl /usr/bin/clang-cl-"${version}" \ | |
--slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-"${version}" \ | |
--slave /usr/bin/clangd clangd /usr/bin/clangd-"${version}" \ | |
--slave /usr/bin/clang-doc clang-doc /usr/bin/clang-doc-"${version}" \ | |
--slave /usr/bin/clang-extdef-mapping clang-extdef-mapping /usr/bin/clang-extdef-mapping-"${version}" \ | |
--slave /usr/bin/clang-format clang-format /usr/bin/clang-format-"${version}" \ | |
--slave /usr/bin/clang-format-diff clang-format-diff /usr/bin/clang-format-diff-"${version}" \ | |
--slave /usr/bin/clang-include-fixer clang-include-fixer /usr/bin/clang-include-fixer-"${version}" \ | |
--slave /usr/bin/clang-move clang-move /usr/bin/clang-move-"${version}" \ | |
--slave /usr/bin/clang-nvlink-wrapper clang-nvlink-wrapper /usr/bin/clang-nvlink-wrapper-"${version}" \ | |
--slave /usr/bin/clang-offload-bundler clang-offload-bundler /usr/bin/clang-offload-bundler-"${version}" \ | |
--slave /usr/bin/clang-offload-wrapper clang-offload-wrapper /usr/bin/clang-offload-wrapper-"${version}" \ | |
--slave /usr/bin/clang-query clang-query /usr/bin/clang-query-"${version}" \ | |
--slave /usr/bin/clang-refactor clang-refactor /usr/bin/clang-refactor-"${version}" \ | |
--slave /usr/bin/clang-rename clang-rename /usr/bin/clang-rename-"${version}" \ | |
--slave /usr/bin/clang-reorder-fields clang-reorder-fields /usr/bin/clang-reorder-fields-"${version}" \ | |
--slave /usr/bin/clang-repl clang-repl /usr/bin/clang-repl-"${version}" \ | |
--slave /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-"${version}" \ | |
--slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-"${version}" \ | |
--slave /usr/bin/clang-tidy-diff.py clang-tidy-diff.py /usr/bin/clang-tidy-diff-"${version}".py \ | |
--slave /usr/bin/count count /usr/bin/count-"${version}" \ | |
--slave /usr/bin/diagtool diagtool /usr/bin/diagtool-"${version}" \ | |
--slave /usr/bin/dsymutil dsymutil /usr/bin/dsymutil-"${version}" \ | |
--slave /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-"${version}" \ | |
--slave /usr/bin/find-all-symbols find-all-symbols /usr/bin/find-all-symbols-"${version}" \ | |
--slave /usr/bin/git-clang-format git-clang-format /usr/bin/git-clang-format-"${version}" \ | |
--slave /usr/bin/hmaptool hmaptool /usr/bin/hmaptool-"${version}" \ | |
--slave /usr/bin/hwasan_symbolize hwasan_symbolize /usr/bin/hwasan_symbolize-"${version}" \ | |
--slave /usr/bin/intercept-build intercept-build /usr/bin/intercept-build-"${version}" \ | |
--slave /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-"${version}" \ | |
--slave /usr/bin/ld64.lld ld64.lld /usr/bin/ld64.lld-"${version}" \ | |
--slave /usr/bin/llc llc /usr/bin/llc-"${version}" \ | |
--slave /usr/bin/lld lld /usr/bin/lld-"${version}" \ | |
--slave /usr/bin/lld-link lld-link /usr/bin/lld-link-"${version}" \ | |
--slave /usr/bin/lli lli /usr/bin/lli-"${version}" \ | |
--slave /usr/bin/lli-child-target lli-child-target /usr/bin/lli-child-target-"${version}" \ | |
--slave /usr/bin/llvm-addr2line llvm-addr2line /usr/bin/llvm-addr2line-"${version}" \ | |
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-"${version}" \ | |
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-"${version}" \ | |
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-"${version}" \ | |
--slave /usr/bin/llvm-bitcode-strip llvm-bitcode-strip /usr/bin/llvm-bitcode-strip-"${version}" \ | |
--slave /usr/bin/llvm-cat llvm-cat /usr/bin/llvm-cat-"${version}" \ | |
--slave /usr/bin/llvm-cfi-verify llvm-cfi-verify /usr/bin/llvm-cfi-verify-"${version}" \ | |
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-"${version}" \ | |
--slave /usr/bin/llvm-c-test llvm-c-test /usr/bin/llvm-c-test-"${version}" \ | |
--slave /usr/bin/llvm-cvtres llvm-cvtres /usr/bin/llvm-cvtres-"${version}" \ | |
--slave /usr/bin/llvm-cxxdump llvm-cxxdump /usr/bin/llvm-cxxdump-"${version}" \ | |
--slave /usr/bin/llvm-cxxfilt llvm-cxxfilt /usr/bin/llvm-cxxfilt-"${version}" \ | |
--slave /usr/bin/llvm-cxxmap llvm-cxxmap /usr/bin/llvm-cxxmap-"${version}" \ | |
--slave /usr/bin/llvm-debuginfod-find llvm-debuginfod-find /usr/bin/llvm-debuginfod-find-"${version}" \ | |
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-"${version}" \ | |
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-"${version}" \ | |
--slave /usr/bin/llvm-dlltool llvm-dlltool /usr/bin/llvm-dlltool-"${version}" \ | |
--slave /usr/bin/llvm-dwarfdump llvm-dwarfdump /usr/bin/llvm-dwarfdump-"${version}" \ | |
--slave /usr/bin/llvm-dwp llvm-dwp /usr/bin/llvm-dwp-"${version}" \ | |
--slave /usr/bin/llvm-exegesis llvm-exegesis /usr/bin/llvm-exegesis-"${version}" \ | |
--slave /usr/bin/llvm-extract llvm-extract /usr/bin/llvm-extract-"${version}" \ | |
--slave /usr/bin/llvm-gsymutil llvm-gsymutil /usr/bin/llvm-gsymutil-"${version}" \ | |
--slave /usr/bin/llvm-ifs llvm-ifs /usr/bin/llvm-ifs-"${version}" \ | |
--slave /usr/bin/llvm-install-name-tool llvm-install-name-tool /usr/bin/llvm-install-name-tool-"${version}" \ | |
--slave /usr/bin/llvm-jitlink llvm-jitlink /usr/bin/llvm-jitlink-"${version}" \ | |
--slave /usr/bin/llvm-jitlink-executor llvm-jitlink-executor /usr/bin/llvm-jitlink-executor-"${version}" \ | |
--slave /usr/bin/llvm-lib llvm-lib /usr/bin/llvm-lib-"${version}" \ | |
--slave /usr/bin/llvm-libtool-darwin llvm-libtool-darwin /usr/bin/llvm-libtool-darwin-"${version}" \ | |
--slave /usr/bin/llvm-link llvm-link /usr/bin/llvm-link-"${version}" \ | |
--slave /usr/bin/llvm-lipo llvm-lipo /usr/bin/llvm-lipo-"${version}" \ | |
--slave /usr/bin/llvm-lto llvm-lto /usr/bin/llvm-lto-"${version}" \ | |
--slave /usr/bin/llvm-lto2 llvm-lto2 /usr/bin/llvm-lto2-"${version}" \ | |
--slave /usr/bin/llvm-mc llvm-mc /usr/bin/llvm-mc-"${version}" \ | |
--slave /usr/bin/llvm-mca llvm-mca /usr/bin/llvm-mca-"${version}" \ | |
--slave /usr/bin/llvm-ml llvm-ml /usr/bin/llvm-ml-"${version}" \ | |
--slave /usr/bin/llvm-modextract llvm-modextract /usr/bin/llvm-modextract-"${version}" \ | |
--slave /usr/bin/llvm-mt llvm-mt /usr/bin/llvm-mt-"${version}" \ | |
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-"${version}" \ | |
--slave /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-"${version}" \ | |
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-"${version}" \ | |
--slave /usr/bin/llvm-opt-report llvm-opt-report /usr/bin/llvm-opt-report-"${version}" \ | |
--slave /usr/bin/llvm-otool llvm-otool /usr/bin/llvm-otool-"${version}" \ | |
--slave /usr/bin/llvm-pdbutil llvm-pdbutil /usr/bin/llvm-pdbutil-"${version}" \ | |
--slave /usr/bin/llvm-PerfectShuffle llvm-PerfectShuffle /usr/bin/llvm-PerfectShuffle-"${version}" \ | |
--slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-"${version}" \ | |
--slave /usr/bin/llvm-profgen llvm-profgen /usr/bin/llvm-profgen-"${version}" \ | |
--slave /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-"${version}" \ | |
--slave /usr/bin/llvm-rc llvm-rc /usr/bin/llvm-rc-"${version}" \ | |
--slave /usr/bin/llvm-readelf llvm-readelf /usr/bin/llvm-readelf-"${version}" \ | |
--slave /usr/bin/llvm-readobj llvm-readobj /usr/bin/llvm-readobj-"${version}" \ | |
--slave /usr/bin/llvm-reduce llvm-reduce /usr/bin/llvm-reduce-"${version}" \ | |
--slave /usr/bin/llvm-rtdyld llvm-rtdyld /usr/bin/llvm-rtdyld-"${version}" \ | |
--slave /usr/bin/llvm-sim llvm-sim /usr/bin/llvm-sim-"${version}" \ | |
--slave /usr/bin/llvm-size llvm-size /usr/bin/llvm-size-"${version}" \ | |
--slave /usr/bin/llvm-split llvm-split /usr/bin/llvm-split-"${version}" \ | |
--slave /usr/bin/llvm-stress llvm-stress /usr/bin/llvm-stress-"${version}" \ | |
--slave /usr/bin/llvm-strings llvm-strings /usr/bin/llvm-strings-"${version}" \ | |
--slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-"${version}" \ | |
--slave /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-"${version}" \ | |
--slave /usr/bin/llvm-tapi-diff llvm-tapi-diff /usr/bin/llvm-tapi-diff-"${version}" \ | |
--slave /usr/bin/llvm-tblgen llvm-tblgen /usr/bin/llvm-tblgen-"${version}" \ | |
--slave /usr/bin/llvm-tli-checker llvm-tli-checker /usr/bin/llvm-tli-checker-"${version}" \ | |
--slave /usr/bin/llvm-undname llvm-undname /usr/bin/llvm-undname-"${version}" \ | |
--slave /usr/bin/llvm-windres llvm-windres /usr/bin/llvm-windres-"${version}" \ | |
--slave /usr/bin/llvm-xray llvm-xray /usr/bin/llvm-xray-"${version}" \ | |
--slave /usr/bin/modularize modularize /usr/bin/modularize-"${version}" \ | |
--slave /usr/bin/not not /usr/bin/not-"${version}" \ | |
--slave /usr/bin/obj2yaml obj2yaml /usr/bin/obj2yaml-"${version}" \ | |
--slave /usr/bin/opt opt /usr/bin/opt-"${version}" \ | |
--slave /usr/bin/pp-trace pp-trace /usr/bin/pp-trace-"${version}" \ | |
--slave /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-"${version}" \ | |
--slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-"${version}".py \ | |
--slave /usr/bin/sancov sancov /usr/bin/sancov-"${version}" \ | |
--slave /usr/bin/sanstats sanstats /usr/bin/sanstats-"${version}" \ | |
--slave /usr/bin/scan-build scan-build /usr/bin/scan-build-"${version}" \ | |
--slave /usr/bin/scan-build-py scan-build-py /usr/bin/scan-build-py-"${version}" \ | |
--slave /usr/bin/scan-view scan-view /usr/bin/scan-view-"${version}" \ | |
--slave /usr/bin/split-file split-file /usr/bin/split-file-"${version}" \ | |
--slave /usr/bin/verify-uselistorder verify-uselistorder /usr/bin/verify-uselistorder-"${version}" \ | |
--slave /usr/bin/wasm-ld wasm-ld /usr/bin/wasm-ld-"${version}" \ | |
--slave /usr/bin/yaml2obj yaml2obj /usr/bin/yaml2obj-"${version}" \ | |
--slave /usr/bin/yaml-bench yaml-bench /usr/bin/yaml-bench-"${version}" | |
update-alternatives --config llvm-config | |
unset version priority | |
} | |
# run the llvm_update_alternatives function with two parameters supplied frpm the console | |
llvm_update_alternatives "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will work with a full installation of LLVM 14 on WSL ubuntu 20.04