-
Mailing lists:
-
IRC: irc.oftc.net #llvm
Building:
- Clone: git clone --depth 1 https://github.com/llvm/llvm-project.git
- Go to: Clion > Preferences > search "CMake"
- Cmake options: -DLLVM_ENABLE_PROJECTS=clang
- Generation path: [path]/build
- In project tree: llvm/CMakeLists.txt > right-click > Load CMake Project
Debugging:
- Find the right binary and arguments with
clang -v [arguments]
- Change target configuration
- Set breakpoints and run debug
git show HEAD -U999999 > mypatch.patch
source: https://systemundertest.org/llvm/
make check-llvm
make check-clang
make clang-test // legacy
// single test
~/src/llvm/build/bin/llvm-lit -v ~/src/llvm/tools/clang/test/
python ~/src/llvm/utils/lit/lit.py -sv --param=build_config=Debug ~/src/llvm/build/test
make check-llvm-unit
make check-clang-unit
- clang-check: diagnostics
- clang-format: formatting
- clang-tidy: linter
clang -ccc-print-phases a.c -o a
0: input, "a.c", c
1: preprocessor, {0}, cpp-output
2: compiler, {1}, ir
3: backend, {2}, assembler
4: assembler, {3}, object
5: linker, {4}, image
6: bind-arch, "x86_64", {5}, image
clang -ast-dump
-
interfacing:
- libclang: low-level access to AST
- plugins (PluginASTAction): add actions to clang
- libtooling (FrontendActions): for building individual tools
-
reformat (libformat)
-
RecursiveASTVisitor: visit AST
-
AST matchers: match AST nodes
llvm-config --cxxflags --ldflags --libs
$LLVM/build/bin/clang stat.cpp -o stat \
\
-I$LLVM/include \
-I$LLVM/build/include \
-L$LLVM/build/lib \
\
-I$LLVM/tools/clang/include \
-I$LLVM/build/tools/clang/include \
-L$LLVM/build/tools/clang/lib \
-lclangAST \
-lclangASTMatchers \
-lclangAnalysis \
-lclangBasic \
-lclangCodeGen \
-lclangDriver \
-lclangEdit \
-lclangFormat \
-lclangFrontend \
-lclangFrontendTool \
-lclangIndex \
-lclangLex \
-lclangParse \
-lclangRewrite \
-lclangSema \
-lclangSerialization \
-lclangTooling
Compiling on mac: lldb codesigning issue
Run the build:
~/src/llvm/cmake-build-debug/bin/lldb ~/src/test
Attach:
lldb -n lldb
- Translation Unit: roughly a source file, after preprocessor includes.
- PGO: profile-guided feedback, or FGO feedback-directed optimization. Improve performance through app profiling.
- LTO: link-time optimization
- thinLTO: parallelized LTO (doc, blog)