Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 1 | .. _cross_compile_macos : |
| 2 | |
| 3 | Cross compilation on MacOS |
| 4 | ========================== |
| 5 | |
| 6 | This 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 Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 13 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 14 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 15 | $ pip3 install ply pyyaml jsonschema |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 16 | $ brew install gnu-sed pkg-config ninja crosstool-ng |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 17 | |
Nathan Skrzypczak | 2586bd6 | 2022-03-23 18:32:52 +0100 | [diff] [blame] | 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>` |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 19 | * You should link the binaries to make them available in your path with their original names e.g. : |
| 20 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 21 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 22 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 23 | $ ln -s $(which gsed) /usr/local/bin/sed |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 24 | |
| 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 | |
| 31 | For now we don't support e-build so dpdk, rdma, quicly won't be compiled as part of ``make build`` |
| 32 | |
| 33 | To build with the toolchain do: |
| 34 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 35 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 36 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 37 | $ $VPP_DIR/extras/scripts/cross_compile_macos.sh build |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 38 | |
| 39 | |
| 40 | To get the compile_commands.json do |
| 41 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 42 | .. code-block:: console |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 43 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 44 | $ $VPP_DIR/extras/scripts/cross_compile_macos.sh cc |
| 45 | $ >> ./build-root/build-vpp[_debug]-native/vpp/compile_commands.json |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 46 | |
| 47 | |
| 48 | |
| 49 | This should build vpp on MacOS |
| 50 | |
| 51 | |
| 52 | Good luck :) |
| 53 | |
Nathan Skrzypczak | 2586bd6 | 2022-03-23 18:32:52 +0100 | [diff] [blame] | 54 | .. _install_clang_format_11_0_0 : |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 55 | |
Nathan Skrzypczak | 2586bd6 | 2022-03-23 18:32:52 +0100 | [diff] [blame] | 56 | Installing clang-format 11.0.0 |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 57 | ------------------------------ |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 58 | |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 59 | In order to install clang-format on macos : |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 60 | |
| 61 | .. code-block:: bash |
| 62 | |
Nathan Skrzypczak | 2586bd6 | 2022-03-23 18:32:52 +0100 | [diff] [blame] | 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 |
| 69 | |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 70 | |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 71 | Source `Clang website <https://releases.llvm.org/download.html#git>`_ |