• Home
Name
Date
Size
#Lines
LOC

..--

assembler/12-May-2024-17,99514,131

bytecode_optimizer/12-May-2024-13,27410,553

cmake/12-May-2024-4,2313,718

compiler/12-May-2024-207,370166,700

cross_values/12-May-2024-521411

disassembler/12-May-2024-4,9333,877

docs/12-May-2024-9,9237,804

dprof/12-May-2024-1,6951,206

extras/12-May-2024-3228

gn/12-May-2024-1,105905

irtoc/12-May-2024-13,26910,325

isa/12-May-2024-4,2823,810

ldscripts/12-May-2024-457418

libllvmbackend/12-May-2024-8,1295,869

libpandabase/12-May-2024-36,22325,609

libpandafile/12-May-2024-21,08115,946

libziparchive/12-May-2024-1,297941

models/12-May-2024-1,3051,168

panda/12-May-2024-300231

pandastdlib/12-May-2024-754586

patches/12-May-2024-14,04213,892

platforms/12-May-2024-5,9634,029

plugins/12-May-2024-375,066297,782

quickener/12-May-2024-600456

runtime/12-May-2024-163,528118,767

scripts/12-May-2024-5,9214,342

static_linker/12-May-2024-3,7703,029

templates/12-May-2024-977756

tests/12-May-2024-257,218237,142

tools/12-May-2024-1,088747

verification/12-May-2024-22,83917,481

.clang-formatD12-May-20243.2 KiB115113

.clang-tidyD12-May-20245.8 KiB157155

.gnD12-May-2024924 2419

AUTHORSD12-May-20242.5 KiB190189

BUILD.gnD12-May-202411.2 KiB393360

CMakeLists.txtD12-May-202414.9 KiB399309

LICENSED12-May-20249.9 KiB178150

OAT.xmlD12-May-20244.3 KiB6921

README.mdD12-May-20246.9 KiB205143

ark_config.gniD12-May-202410.2 KiB348297

ark_root.gniD12-May-20241,002 3227

README.md

1# Bootstrapping
2
3Currently an officially supported host OS for development, building and testing is Ubuntu 18.04 and Ubuntu 20.04.
4The full list of packages required for building and testing the project is specified in
5`scripts/deps-lists` files. These packages can be installed either manually or by running
6a bootstrap script:
7
8```
9$ sudo ./scripts/install-deps-ubuntu
10```
11
12For more bootstrapping options, run:
13
14```
15$ sudo ./scripts/install-deps-ubuntu --help
16```
17
18E.g. for development purposes you should run:
19
20```
21$ sudo ./scripts/install-deps-ubuntu -i=dev
22```
23
24If you want additionally to install python dependencies for running tests add a parameter `-i=test`:
25
26```
27$ sudo ./scripts/install-deps-ubuntu -i=dev -i=test
28```
29It creates a virtual environment .venv-panda in your home directory with all required dependencies.
30Later, tests python scripts can activate this environment. If you already have run with the parameter `-i=test`
31the second time it might be skipped.
32
33# Third party
34
35Panda uses third party libraries. To install the libraries and apply patches, run:
36
37```
38$ ./scripts/install-third-party --force-clone
39```
40
41# Building
42
43Assuming your system is bootstrapped, please run the following commands in the root of the project:
44
45```
46$ mkdir panda-build
47$ cd panda-build
48$ cmake /path/to/panda/repository -GNinja
49$ ninja
50```
51
52This will build Panda in debug mode with your default C++ compiler. All supported compilers can be
53found in `cmake/toolchain`. E.g., to build with Clang 14, pass a path to the corresponding toolchain
54file during configuration:
55
56```
57$ cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/panda/repository/cmake/toolchain/host_clang_14.cmake /path/to/panda/repository
58```
59
60## Explicitly setting build types
61
62Recommended way to build Panda is to set `CMAKE_BUILD_TYPE` variable explicitly during configurations. Supported values are:
63
64| Mode         | Assertions | Optimizations         | Debug info           |
65| ----         | ---------- | -------------         | ----------           |
66| `Debug `     | Yes        | None (CMake default)  | `-g` (CMake default) |
67| `Release`    | No         | `-O3` (CMake default) | None (CMake default) |
68| `FastVerify` | Yes        | `-O2`                 | `-ggdb3`             |
69
70Notes:
71
72* Other common modes (`RelWithDebInfo`, `MinSizeRel`, `DebugDetailed`) should work but they are not tested in CI.
73* Unlike `RelWithDebInfo`, `FastVerify` preserves assertions (and provides more verbose debug information).
74  Use this build type for running heavy test suites when you want both fast-running code and debuggability.
75* `DebugDetailed` gives more debug information than `Debug`, it can be usefull for debugging unit tests for example.
76
77Example:
78
79```
80$ cmake -DCMAKE_BUILD_TYPE=Release ...
81```
82
83## Building with LLVM Backend
84
85If you want to build Ark with LLVM Backend you need to build first special modified LLVM 15 binaries.
86  * Clone repository from [gitee.com](https://gitee.com/openharmony/third_party_llvm-project)
87  * Check [README](scripts/llvm/README.md) file about build process
88  * Use build [script](scripts/llvm/build_llvm.sh)
89
90If modified LLVM available in `/opt`, the following two options are necessary
91to build Ark with LLVM Backend functions.
92
93```cmake
94cmake -DPANDA_LLVM_BACKEND=true -DLLVM_TARGET_PATH=/opt/llvm-15-{type}-{arch} ...
95```
96
97The `PANDA_LLVM_BACKEND` enables:
98
991. LLVM Irtoc Interpreter. Use `-DPANDA_LLVM_INTERPRETER=OFF` to disable.
1002. LLVM Fastpaths compilation. Use `-DPANDA_LLVM_FASTPATH=OFF` to disable.
1013. LLVM Interpreter inlining. Use `-DPANDA_LLVM_INTERPRETER_INLINING=OFF` to disable.
102
103LLVM AOT compiler is temporarily disabled in all builds.
104
105`PANDA_LLVM_INTERPRETER` and `PANDA_LLVM_FASTPATH` are `ON` if `PANDA_LLVM_BACKEND` is turned on.
106
107It is recommended to choose `clang` compiler using toolchain files: `-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/host_clang_14.cmake`.
108By default GNU compiler `c++` is used, but some features are not available in such `gcc` builds.
109
110## Cross ARM64 build with LLVM Backend
111
112For cross-build, when e.g. `-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/cross-clang-14-qemu-aarch64.cmake` is used, LLVM-path should passed using another option when LLVM Backend is enabled: `-DLLVM_HOST_PATH=/opt/llvm-15-debug-x86_64`.
113
114## Running tests with QEMU for cross-compiled aarch64/arm builds
115
116Recommended QEMU version for running tests is 6.2.0 (but 5.1+ should be ok, too). By default, it is downloaded and installed during environment bootstrap. Any system-installed package is left intact. If recommended QEMU version is not accessible via $PATH it can be specified during configuration time:
117
118```
119# If QEMU is available as /opt/qemu-6.2.0/bin/qemu-aarch64
120$ cmake -DQEMU_PREFIX=/opt/qemu-6.2.0 ...
121```
122
123## Building with GN
124
1251. Getting GN binary
126
127```
128$ git clone https://gn.googlesource.com/gn
129$ cd gn
130$ python build/gen.py
131$ ninja -C out
132```
133
1342. Build panda using gn (`ark_asm`, `ark_disasm`, `ark_aot`, `ark_aotdump`, `c2abc`, `ark_bin`, `es2panda`, `verifier_bin` and `ark` targets are supported)
135
136```
137$ cd /path/to/panda/repository
138$ /path/to/gn/repository/out/gn gen out
139$ ninja -C out ark
140```
141When standard system, use
142```
143$ cd /path/to/panda/repository
144$ /path/to/gn/repository/out/gn --args=-is_standard_system=true gen out
145$ ninja -C out <target name>
146```
147To use LLVM Backend add the following arguments:
148```
149$ /path/to/gn/repository/out/gn out is_llvmbackend=true llvm_dir="/opt/llvm-15-{type}-{arch}" ...
150```
151Setting `is_llvmbackend=true` option enables the same scenarios as `-DPANDA_LLVM_BACKEND=true` option in cmake builds
152
153## Further reading
154
155* For more details, please see [build system readme](cmake/README.md).
156
157# Testing
158
159For testing, the following umbrella targets that guarantee building prior to running may be used:
160
161* `tests`, for running all testing suites.
162* `tests_full`, for running all testing suites and various code linters.
163
164# Clang tools
165
166`clang-format` and `clang-tidy` checks are integrated into build system and can be called by target of build system:
167```
168$ ninja code-style-check # clang-format
169$ ninja clang-tidy-check # clang-tidy
170```
171
172# Test coverage
173
174In order to measure bytecode optimizer coverage, configure your build with -DENABLE_BYTECODE_OPTIMIZER_COVERAGE=true. Then run:
175```
176$ ninja bytecode_optimizer_coverage
177```
178
179# Benchmarking
180
181To build and run benchmarks, please use the umbrella target `benchmarks` or any of its
182dependencies. Please see the root `CMakeLists.txt` for more details.
183
184NB! Make sure that you configure your build with `-DCMAKE_BUILD_TYPE=Release`, otherwise
185your run will most likely be dead slow.
186
187# Running
188
189## Running assembler
190
191Assuming that you are in `panda-build` directory, please run:
192
193```
194$ ./bin/ark_asm /path/to/panda-assembly.pa /path/to/binary/output.abc
195```
196
197## Running interpreter
198
199Assuming that your main function is defined as `.function main(...)` in the assembly listing,
200and `/path/to/binary/output.abc` is the result of the assembler, please run:
201
202```
203$ ./bin/ark /path/to/binary/output.abc _GLOBAL::main
204```
205