blob: 0b0935b31eff62ae50cba4a00a96d9d1879ace3b [file] [log] [blame]
Olivier Deprez5ed0bee2023-06-08 10:55:05 +02001Building
J-Alves241c66c2023-10-19 13:59:29 +01002========
Olivier Deprez5ed0bee2023-06-08 10:55:05 +02003
J-Alves241c66c2023-10-19 13:59:29 +01004This page assumes the :ref:`Prerequisites` have been followed to install all project dependencies.
Olivier Deprez5ed0bee2023-06-08 10:55:05 +02005
J-Alves241c66c2023-10-19 13:59:29 +01006Hafnium
7^^^^^^^
Olivier Deprez5ed0bee2023-06-08 10:55:05 +02008
Olivier Deprez40d09d22023-11-20 17:46:21 +01009Most common options
10~~~~~~~~~~~~~~~~~~~
11
12By default, Hafnium builds all target platforms along with tests with clang.
13From Hafnium top level directory, use:
Olivier Deprez5ed0bee2023-06-08 10:55:05 +020014
15.. code:: shell
16
17 make
18
Olivier Deprez40d09d22023-11-20 17:46:21 +010019The resulting Hafnium images are located in `out/reference/<platform>/hafnium.bin`.
20
21It is possible to build Hafnium for a single platform target omitting tests,
22resulting in faster builds when the test suite is not required.
23For example to build the SPMC targeting FVP:
24
25.. code:: shell
26
27 make PLATFORM=secure_aem_v8a_fvp_vhe
28
Olivier Deprez5ed0bee2023-06-08 10:55:05 +020029The resulting FVP image is located in
30`out/reference/secure_aem_v8a_fvp_vhe_clang/hafnium.bin`.
31
Olivier Deprez40d09d22023-11-20 17:46:21 +010032Multiple platform names can be provided for building e.g.:
33
34.. code:: shell
35
36 make PLATFORM="secure_aem_v8a_fvp_vhe,secure_tc"
37
38To get a list of available platforms, you may use:
39
40.. code:: shell
41
42 make list
43
44resulting in:
45
46.. code:: shell
47
Karl Meakin11f05472025-03-27 15:04:39 +000048 Supported platforms: ['secure_rd_fremont', 'secure_rd_fremont_cfg1', 'secure_aem_v8a_fvp_vhe', 'aem_v8a_fvp_vhe', 'aem_v8a_fvp_vhe_ffa_v1_1', 'qemu_aarch64_vhe', 'secure_qemu_aarch64', 'rpi4', 'secure_tc']
Olivier Deprez40d09d22023-11-20 17:46:21 +010049
50Additional options
51~~~~~~~~~~~~~~~~~~
52
Olivier Deprez5ed0bee2023-06-08 10:55:05 +020053The presence of assertions in the final build can be set using the `ENABLE_ASSERTIONS`
54make variable, by default this is set to `true`, meaning asserts are included in the build.
55
56.. code:: shell
57
58 make ENABLE_ASSERTIONS=<true|false>
59
60Each project in the `project` directory specifies a root configurations of the
61build. Adding a project is the preferred way to extend support to new platforms.
62The target project that is built is selected by the `PROJECT` make variable, the
63default project is 'reference'.
64
65.. code:: shell
66
67 make PROJECT=<project_name>
68
69If you wish to change the value of the make variables you may need to first use:
70
71.. code:: shell
72
73 make clobber
74
75So the `args.gn` file will be regenerated with the new values.
76
Jayanth Dodderi Chidanand02a33932025-04-01 13:39:48 +010077Troubleshoot(Clean Up Artifacts)
78~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79Before building Hafnium, ensure the Clang toolchain is installed and available
80in your `PATH`. This is usually sufficient for a successful build.
81
82If you encounter errors related to missing or incompatible C library headers
83(e.g., after a failed build or toolchain update), clean up stale artifacts by running:
84
85.. code:: shell
86
87 make clobber
88
89This command removes previously generated build outputs, which can help resolve
90issues caused by outdated intermediate files. It's a useful troubleshooting step
91but not required for a fresh setup.
92
Karl Meakin0f6b5ce2025-02-25 11:26:09 +000093Using Docker
94^^^^^^^^^^^^
95
96We provide a Docker container to ensure a consistent development environment or
97to enable building on non-Linux platforms (eg MacOS). Build the container with
98`./build/docker/build.sh`. You can run commands in the container with
99`./build/run_in_container.sh -i bash`:
100
J-Alves3a75fa82025-03-28 17:46:59 +0000101.. code:: shell
102
Karl Meakin0f6b5ce2025-02-25 11:26:09 +0000103 ./build/docker/build.sh
104 ./build/run_in_container.sh -i bash
105 make
106
107Alternatively, the Makefile will automatically use the Docker container
108if the environment variable `HAFNIUM_HERMETIC_BUILD` is set to `true`:
109
J-Alves3a75fa82025-03-28 17:46:59 +0000110.. code:: shell
111
Karl Meakin0f6b5ce2025-02-25 11:26:09 +0000112 ./build/docker/build.sh
113 HAFNIUM_HERMETIC_BUILD=true make
114
J-Alves241c66c2023-10-19 13:59:29 +0100115Hafnium Documentation
116^^^^^^^^^^^^^^^^^^^^^
117
118If you have already sourced a virtual environment, Poetry will respect this and
119install dependencies there.
120
121.. code:: shell
122
123 poetry run make doc
124
Olivier Deprez5ed0bee2023-06-08 10:55:05 +0200125--------------
126
127*Copyright (c) 2023, Arm Limited. All rights reserved.*