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 | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 18 | * You'll also need to install ``clang-format 10.0.0`` to be able to ``make checkstyle``. This can be done with :ref:`this doc<install_clang_format_10_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 | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 54 | .. _install_clang_format_10_0_0 : |
Nathan Skrzypczak | 66f2a88 | 2019-07-31 17:57:58 +0200 | [diff] [blame] | 55 | |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 56 | Installing clang-format 10.0.0 |
| 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 | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 63 | $ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang-10.0.0.src.tar.xz |
| 64 | $ tar -xvf clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz |
| 65 | $ mv clang+llvm-10.0.0-x86_64-apple-darwin /usr/local/Cellar/ |
| 66 | $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-format /usr/local/bin/clang-format |
| 67 | $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-format /usr/local/bin/clang-format-10 |
| 68 | $ sudo ln -s ../Cellar/clang+llvm-10.0.0-x86_64-apple-darwin/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff-10 |
Nathan Skrzypczak | f681e9f | 2020-09-08 18:09:59 +0200 | [diff] [blame] | 69 | |
Nathan Skrzypczak | 452cd7e | 2021-01-26 11:49:03 +0100 | [diff] [blame] | 70 | Source `Clang website <https://releases.llvm.org/download.html#git>`_ |