blob: 0d9919874f7df80cbbdfece8a15a9ed4c28334aa [file] [log] [blame]
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +02001.. _cross_compile_macos :
2
3Cross compilation on MacOS
4==========================
5
6This is a first attempt to support Cross compilation of VPP on MacOS for development (linting, completion, compile_commands.json)
7
8
9**Prerequisites**
10
11* You'll need to install the following packages
12
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020013.. code-block:: console
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020014
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020015 $ pip3 install ply pyyaml jsonschema
Nathan Skrzypczak452cd7e2021-01-26 11:49:03 +010016 $ brew install gnu-sed pkg-config ninja crosstool-ng
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020017
Nathan Skrzypczak2586bd62022-03-23 18:32:52 +010018* 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>`
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020019* You should link the binaries to make them available in your path with their original names e.g. :
20
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020021.. code-block:: console
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020022
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020023 $ ln -s $(which gsed) /usr/local/bin/sed
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020024
25**Setup**
26
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``
30
31For now we don't support e-build so dpdk, rdma, quicly won't be compiled as part of ``make build``
32
33To build with the toolchain do:
34
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020035.. code-block:: console
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020036
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020037 $ $VPP_DIR/extras/scripts/cross_compile_macos.sh build
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020038
39
40To get the compile_commands.json do
41
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020042.. code-block:: console
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020043
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020044 $ $VPP_DIR/extras/scripts/cross_compile_macos.sh cc
45 $ >> ./build-root/build-vpp[_debug]-native/vpp/compile_commands.json
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020046
47
48
49This should build vpp on MacOS
50
51
52Good luck :)
53
Nathan Skrzypczak2586bd62022-03-23 18:32:52 +010054.. _install_clang_format_11_0_0 :
Nathan Skrzypczak66f2a882019-07-31 17:57:58 +020055
Nathan Skrzypczak2586bd62022-03-23 18:32:52 +010056Installing clang-format 11.0.0
Nathan Skrzypczak452cd7e2021-01-26 11:49:03 +010057------------------------------
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020058
Nathan Skrzypczak452cd7e2021-01-26 11:49:03 +010059In order to install clang-format on macos :
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020060
61.. code-block:: bash
62
Nathan Skrzypczak2586bd62022-03-23 18:32:52 +010063 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
69
Nathan Skrzypczakf681e9f2020-09-08 18:09:59 +020070
Nathan Skrzypczak452cd7e2021-01-26 11:49:03 +010071Source `Clang website <https://releases.llvm.org/download.html#git>`_