1.. _target-host: 2 3==== 4host 5==== 6The Pigweed host target is used for unit testing and some host side tooling. 7 8---------- 9Toolchains 10---------- 11Pigweed several toolchains preconfigured for compiling for the host. 12 13.. list-table:: 14 15 * - Toolchain name 16 - GN path 17 - Compiler 18 - Optimization 19 * - ``host_clang_debug`` 20 - ``//targets/host:host_clang_debug`` 21 - Clang 22 - ``-Og`` 23 * - ``host_clang_size_optimized`` 24 - ``//targets/host:host_clang_size_optimized`` 25 - Clang 26 - ``-Os`` 27 * - ``host_clang_speed_optimized`` 28 - ``//targets/host:host_clang_speed_optimized`` 29 - Clang 30 - ``-O2`` 31 * - ``host_gcc_debug`` 32 - ``//targets/host:host_gcc_debug`` 33 - GCC 34 - ``-Og`` 35 * - ``host_gcc_size_optimized`` 36 - ``//targets/host:host_gcc_size_optimized`` 37 - GCC 38 - ``-Os`` 39 * - ``host_gcc_speed_optimized`` 40 - ``//targets/host:host_gcc_speed_optimized`` 41 - GCC 42 - ``-O2`` 43 44These toolchains may be used directly by downstream projects if desired. For 45upstream builds, Pigweed uses internal-only variants of these toolchains. The 46upstream toolchains are defined in ``//targets/host/pigweed_internal`` and are 47prefixed with ``pw_strict_``. The upstream toolchains may not be used by 48downstream projects. 49 50Toolchains for other C++ standards 51================================== 52Pigweed code requires C++17 or newer and is fully compatible with C++20. Pigweed 53defines a toolchain for testing with C++20. 54 55* ``pw_strict_host_clang_size_optimized_cpp20`` -- Builds with ``-std=c++20``. 56 57This toolchains is only permitted for use in upstream pigweed, but downstream 58users may create similar toolchains as needed. 59 60-------- 61Building 62-------- 63To build for the host with a default configuration, invoke Ninja with the 64top-level ``host`` group as the target to build. 65 66.. code-block:: sh 67 68 $ ninja -C out host 69 70 71``host`` may be replaced with ``host_clang``, ``host_gcc``, 72``host_clang_debug``, etc. to build with a more specific host toolchain. Not all 73toolchains are supported on all platforms. Unless working specifically on one 74toolchain, it is recommended to use the default. 75 76------------- 77Running Tests 78------------- 79Tests are automatically run as part of the host build, but if you desire to 80manually run tests, you may invoke them from a shell directly. 81 82Example: 83 84.. code-block:: sh 85 86 $ ./out/host_[compiler]_debug/obj/pw_status/status_test 87 88---------- 89RPC server 90---------- 91The host target implements a system RPC server that runs over a local socket, 92defaulting to port 33000. To communicate with a process running the host RPC 93server, use ``pw rpc -s localhost:33000 <protos>``. 94