1 .. _cross_compile_macos :
3 Cross compilation on MacOS
4 ==========================
6 This is a first attempt to support Cross compilation of VPP on MacOS for development (linting, completion, compile_commands.json)
11 * You'll need to install the following packages
13 .. code-block:: console
15 $ pip3 install ply pyyaml jsonschema
16 $ brew install gnu-sed pkg-config ninja crosstool-ng
18 * You'll also need to install ``clang-format 11.0.0`` to be able to ``make checkstyle``. This can be done with :ref:`this doc<install_clang_format_11_0_0>`
19 * You should link the binaries to make them available in your path with their original names e.g. :
21 .. code-block:: console
23 $ ln -s $(which gsed) /usr/local/bin/sed
27 * Create a `cross compile toolchain <https://crosstool-ng.github.io/>`_
28 * Create a case sensitive volume and mount the toolchain in it e.g. in ``/Volumes/xchain``
29 * Create a xchain.toolchain file with ``$VPP_DIR/extras/scripts/cross_compile_macos.sh conf /Volumes/xchan``
31 For now we don't support e-build so dpdk, rdma, quicly won't be compiled as part of ``make build``
33 To build with the toolchain do:
35 .. code-block:: console
37 $ $VPP_DIR/extras/scripts/cross_compile_macos.sh build
40 To get the compile_commands.json do
42 .. code-block:: console
44 $ $VPP_DIR/extras/scripts/cross_compile_macos.sh cc
45 $ >> ./build-root/build-vpp[_debug]-native/vpp/compile_commands.json
49 This should build vpp on MacOS
54 .. _install_clang_format_11_0_0 :
56 Installing clang-format 11.0.0
57 ------------------------------
59 In order to install clang-format on macos :
63 brew install clang-format@11
64 wget https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-11.0.0/clang/tools/clang-format/clang-format-diff.py \
65 -O /usr/local/Cellar/clang-format@11/11.1.0/bin/clang-format-diff.py
66 chmod +x /usr/local/Cellar/clang-format@11/11.1.0/bin/clang-format-diff.py
67 ln -s /usr/local/Cellar/clang-format@11/11.1.0/bin/clang-format-diff.py /usr/local/bin/clang-format-diff-11
68 ln -s /usr/local/Cellar/clang-format@11/11.1.0/bin/clang-format-11 /usr/local/bin/clang-format
71 Source `Clang website <https://releases.llvm.org/download.html#git>`_