=====Status===== [[https://clang.llvm.org/cxx_status.html|C++ status]], [[https://libcxx.llvm.org/docs/index.html|libstdc++ status]] =====Installation===== ====Compilation==== Pour faire une compilation plus rapide, ajouter : Dossier source : ''llvm-project\llvm''. ''-DLLVM_TARGETS_TO_BUILD=X86'' pour compiler pour x86 et x64. ''-DCMAKE_INSTALL_PREFIX=install'' car ce dossier a besoin d'être accessible en écriture pendant la compilation. ''%%-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"%%''. ''clang-tools-extra'' est nécessaire pour ''ClangAST''. ''%%-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"%%'' ''-DLLVM_PARALLEL_LINK_JOBS=2'' pour éviter que le link plante. ''-DLLVM_INCLUDE_TESTS:BOOL=OFF -DCLANG_INCLUDE_TESTS:BOOL=OFF -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF -DLLVM_INCLUDE_UTILS:BOOL=OFF -DLLVM_INCLUDE_DOCS:BOOL=OFF -DLLVM_BUILD_UTILS:BOOL=OFF'' ====Ubuntu==== * Utilisation des derniers paquets Ajouté les clés de vérification de l'authenticité en exécutant : wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc [[https://askubuntu.com/questions/1403556/key-is-stored-in-legacy-trusted-gpg-keyring-after-ubuntu-22-04-update|Key is stored in legacy trusted.gpg keyring after Ubuntu 22.04 update]] {{ :prog:clang:apt_-_key_is_stored_in_legacy_trusted.gpg_keyring_after_ubuntu_22.04_update_-_ask_ubuntu_18_10_2022_15_03_19_.html |Archive du 21/04/2022 le 18/10/2022}} Ajouter à ''/etc/apt/sources.list'' : deb http://apt.llvm.org/mantic/ llvm-toolchain-mantic-17 main deb-src http://apt.llvm.org/mantic/ llvm-toolchain-mantic-17 main La première paire de lignes est globale et doit toujours être ajoutée. La seconde paire est pour ajouter la version précise. Puis faire un ''apt update'' / ''apt upgrade''. [[https://apt.llvm.org/|LLVM Debian/Ubuntu nightly packages]] {{ :prog:clang:llvm_debian_ubuntu_packages_18_10_2022_14_50_31_.html |Archive du 31/07/2022 le 18/10/2022}} [[https://linuxhint.com/install-llvm-ubuntu/|Install LLVM on Ubuntu 22.04]] {{ :prog:clang:install_llvm_on_ubuntu_22.04_18_10_2022_14_51_02_.html |Archive du 01/12/2017 le 18/10/2022}} * Installation en parallèle Ubuntu ne fournit pas de méthode 100% automatique. Il faut passer manuellement par ''update-alternatives''. #!/usr/bin/env bash update_alternatives() { local version=${1} local priority=${2} local master=${3} local slaves=${4} local path=${5} local cmdln cmdln="--verbose --install ${path}${master} ${master} ${path}${master}-${version} ${priority}" for slave in ${slaves}; do cmdln="${cmdln} --slave ${path}${slave} ${slave} ${path}${slave}-${version}" done sudo update-alternatives ${cmdln} } if [[ ${#} -ne 2 ]]; then echo usage: "${0}" clang_version priority exit 1 fi version=${1} priority=${2} path="/usr/bin/" master="llvm-config" slaves="llvm-addr2line llvm-ar llvm-as llvm-bcanalyzer llvm-bitcode-strip llvm-cat llvm-cfi-verify llvm-cov llvm-c-test llvm-cvtres llvm-cxxdump llvm-cxxfilt llvm-cxxmap llvm-debuginfod llvm-debuginfod-find llvm-diff llvm-dis llvm-dlltool llvm-dwarfdump llvm-dwarfutil llvm-dwp llvm-exegesis llvm-extract llvm-gsymutil llvm-ifs llvm-install-name-tool llvm-jitlink llvm-jitlink-executor llvm-lib llvm-libtool-darwin llvm-link llvm-lipo llvm-lto llvm-lto2 llvm-mc llvm-mca llvm-ml llvm-modextract llvm-mt llvm-nm llvm-objcopy llvm-objdump llvm-omp-device-info llvm-opt-report llvm-otool llvm-pdbutil llvm-PerfectShuffle llvm-profdata llvm-profgen llvm-ranlib llvm-rc llvm-readelf llvm-readobj llvm-reduce llvm-remark-size-diff llvm-rtdyld llvm-sim llvm-size llvm-split llvm-stress llvm-strings llvm-strip llvm-symbolizer llvm-tapi-diff llvm-tblgen llvm-tli-checker llvm-undname llvm-windres llvm-xray" update_alternatives "${version}" "${priority}" "${master}" "${slaves}" "${path}" master="clang" slaves="analyze-build asan_symbolize bugpoint c-index-test clang++ clang-apply-replacements clang-change-namespace clang-check clang-cl clang-cpp clangd clang-doc clang-extdef-mapping clang-format clang-format-diff clang-include-fixer clang-linker-wrapper clang-move clang-nvlink-wrapper clang-offload-bundler clang-offload-packager clang-offload-wrapper clang-pseudo clang-query clang-refactor clang-rename clang-reorder-fields clang-repl clang-scan-deps clang-tidy count diagtool dsymutil FileCheck find-all-symbols git-clang-format hmaptool hwasan_symbolize intercept-build ld64.lld ld.lld llc lld lldb lldb-argdumper lldb-instr lldb-server lldb-vscode lld-link lli lli-child-target modularize not obj2yaml opt pp-trace run-clang-tidy sancov sanstats scan-build scan-build-py scan-view split-file UnicodeNameMappingGenerator verify-uselistorder wasm-ld yaml2obj yaml-bench" update_alternatives "${version}" "${priority}" "${master}" "${slaves}" "${path}" Utilisation pour enregistrer les alternatives : ''./update-alternatives-clang.sh 16 16'' [[https://gist.github.com/junkdog/70231d6953592cd6f27def59fe19e50d|update-alternatives-clang.sh]] {{ :prog:clang:update-alternatives-clang.sh_18_10_2022_14_37_31_.html |Archive du 18/11/2017 le 18/10/2022}} Utiliser pour switcher entre les versions : sudo update-alternatives --config llvm-config sudo update-alternatives --config clang [[https://linuxhint.com/update_alternatives_ubuntu|How to Use update-alternatives Command on Ubuntu]] {{ :prog:clang:how_to_use_update-alternatives_command_on_ubuntu_18_10_2022_14_54_18_.html |Archive du 01/05/2022 le 18/10/2022}} =====Options===== * ''-ftime-trace'' Affiche où clang passe du temps pour compiler. Le fichier ''.json'' généré s'ouvre avec Chrome ''%%chrome://tracing%%'' [[https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/|time-trace: timeline / flame chart profiler for Clang]] {{ :prog:clang:time-trace_timeline_flame_chart_profiler_for_clang_aras_website_2019-11-11_18_52_11_.html |Archive du 16/01/2019 le 11/11/2019}} =====Erreurs===== * ''fatal error: 'iostream' file not found'' Les librairies standard ne sont pas trouvées. On peut commencer par vérifier si le paquet ''build-essential'' est installé. Ensuite, les librairies standard ne sont pas forcément celles du gcc par défaut qui sont utilisées. Lancer ''clang -v'' pour trouver laquelle est en cours (''Selected GCC installation''). $ clang -v Ubuntu clang version 14.0.6 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-14/bin Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 $ gcc -v gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) Il faut donc installer les entêtes de gcc-12. sudo apt install libstdc++-12-dev [[https://stackoverflow.com/questions/26333823/clang-doesnt-see-basic-headers|Clang doesn't see basic headers]] {{ :prog:clang:c_-_clang_doesn_t_see_basic_headers_-_stack_overflow_11_05_2023_11_53_28_.html |Archive du 13/10/2014 le 11/05/2023}}