Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 1 | Compilation and Installation Using Meson |
| 2 | ======================================== |
| 3 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 4 | 1. Introduction |
| 5 | --------------- |
| 6 | |
| 7 | For general information about Meson see the `Meson |
| 8 | website <https://mesonbuild.com/>`__. |
| 9 | |
| 10 | **Mesa's Meson build system is generally considered stable and ready for |
| 11 | production.** |
| 12 | |
Eric Engestrom | e94a122 | 2019-12-05 20:39:17 +0000 | [diff] [blame] | 13 | .. note:: |
| 14 | |
| 15 | Mesa requires Meson >= 0.52.0 to build. |
| 16 | |
| 17 | If your distribution doesn't have something recent enough in its |
| 18 | repositories, you can `try the methods suggested here |
| 19 | <https://mesonbuild.com/Getting-meson.html>`__ to install the |
| 20 | current version of Meson. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 21 | |
| 22 | The Meson build of Mesa is tested on Linux, macOS, Windows, Cygwin, |
| 23 | Haiku, FreeBSD, DragonflyBSD, NetBSD, and should work on OpenBSD. |
| 24 | |
| 25 | Unix-like OSes |
| 26 | ^^^^^^^^^^^^^^ |
| 27 | |
| 28 | If Meson is not already installed on your system, you can typically |
| 29 | install it with your package installer. For example: |
| 30 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 31 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 32 | |
| 33 | sudo apt-get install meson # Ubuntu |
| 34 | |
| 35 | or |
| 36 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 37 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 38 | |
| 39 | sudo dnf install meson # Fedora |
| 40 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 41 | Some older versions of Meson do not check that they are too old and will |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 42 | error out in odd ways. |
| 43 | |
| 44 | You'll also need `Ninja <https://ninja-build.org/>`__. If it's not |
| 45 | already installed, use apt-get or dnf to install the *ninja-build* |
| 46 | package. |
| 47 | |
| 48 | Windows |
| 49 | ^^^^^^^ |
| 50 | |
Erik Faye-Lund | d95e2e4 | 2020-09-29 18:22:55 +0200 | [diff] [blame^] | 51 | You will need to install Python 3 and Meson as a module using pip. This |
| 52 | is because we use Python for generating code, and rely on external |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 53 | modules (mako). You also need pkg-config (a hard dependency of Meson), |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 54 | flex, and bison. The easiest way to install everything you need is with |
| 55 | `chocolatey <https://chocolatey.org/>`__. |
| 56 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 57 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 58 | |
| 59 | choco install python3 winflexbison pkgconfiglite |
| 60 | |
| 61 | You can even use chocolatey to install mingw and ninja (ninja can be |
| 62 | used with MSVC as well) |
| 63 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 64 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 65 | |
| 66 | choco install ninja mingw |
| 67 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 68 | Then install Meson using pip |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 69 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 70 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 71 | |
| 72 | py -3 -m pip install meson mako |
| 73 | |
Erik Faye-Lund | d95e2e4 | 2020-09-29 18:22:55 +0200 | [diff] [blame^] | 74 | You may need to add the Python 3 scripts directory to your path for |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 75 | Meson. |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 76 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 77 | 2. Basic Usage |
| 78 | -------------- |
| 79 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 80 | The Meson program is used to configure the source directory and |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 81 | generates either a ninja build file or Visual Studio® build files. The |
| 82 | latter must be enabled via the ``--backend`` switch, as ninja is the |
| 83 | default backend on all operating systems. |
| 84 | |
| 85 | Meson only supports out-of-tree builds, and must be passed a directory |
| 86 | to put built and generated sources into. We'll call that directory |
| 87 | "build" here. It's recommended to create a `separate build |
| 88 | directory <https://mesonbuild.com/Using-multiple-build-directories.html>`__ |
| 89 | for each configuration you might want to use. |
| 90 | |
| 91 | Basic configuration is done with: |
| 92 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 93 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 94 | |
| 95 | meson build/ |
| 96 | |
| 97 | This will create the build directory. If any dependencies are missing, |
| 98 | you can install them, or try to remove the dependency with a Meson |
| 99 | configuration option (see below). |
| 100 | |
| 101 | To review the options which Meson chose, run: |
| 102 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 103 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 104 | |
| 105 | meson configure build/ |
| 106 | |
| 107 | Meson does not currently support listing configuration options before |
| 108 | running "meson build/" but this feature is being discussed upstream. For |
| 109 | now, we have a ``bin/meson-options.py`` script that prints the options |
| 110 | for you. If that script doesn't work for some reason, you can always |
| 111 | look in the |
| 112 | `meson_options.txt <https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/meson_options.txt>`__ |
| 113 | file at the root of the project. |
| 114 | |
| 115 | With additional arguments ``meson configure`` can be used to change |
| 116 | options for a previously configured build directory. All options passed |
| 117 | to this command are in the form ``-D "option"="value"``. For example: |
| 118 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 119 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 120 | |
| 121 | meson configure build/ -Dprefix=/tmp/install -Dglx=true |
| 122 | |
| 123 | Note that options taking lists (such as ``platforms``) are `a bit more |
| 124 | complicated <https://mesonbuild.com/Build-options.html#using-build-options>`__, |
| 125 | but the simplest form compatible with Mesa options is to use a comma to |
| 126 | separate values (``-D platforms=drm,wayland``) and brackets to represent |
| 127 | an empty list (``-D platforms=[]``). |
| 128 | |
| 129 | Once you've run the initial ``meson`` command successfully you can use |
| 130 | your configured backend to build the project in your build directory: |
| 131 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 132 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 133 | |
| 134 | ninja -C build/ |
| 135 | |
| 136 | The next step is to install the Mesa libraries, drivers, etc. This also |
| 137 | finishes up some final steps of the build process (such as creating |
| 138 | symbolic links for drivers). To install: |
| 139 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 140 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 141 | |
| 142 | ninja -C build/ install |
| 143 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 144 | Windows specific instructions |
| 145 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 146 | |
| 147 | On windows you have a couple of choices for compilers. If you installed |
| 148 | mingw with chocolatey and want to use ninja you should be able to open |
| 149 | any shell and follow the instructions above. If you want to you MSVC, |
| 150 | clang-cl, or ICL (the Intel Compiler), read on. |
| 151 | |
| 152 | Both ICL and MSVC come with shell environments, the easiest way to use |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 153 | Meson with these it to open a shell. For clang-cl you will need to open |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 154 | an MSVC shell, and then override the compilers, either using a `native |
| 155 | file <https://mesonbuild.com/Native-environments.html>`__, or with the |
| 156 | CC and CXX environment variables. |
| 157 | |
| 158 | All of these compilers are tested and work with ninja, but if you want |
| 159 | visual studio integration or you just like msbuild, passing |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 160 | ``--backend=vs`` to Meson will generate a visual studio solution. If you |
| 161 | want to use ICL or clang-cl with the vsbackend you will need Meson |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 162 | 0.52.0 or greater. Older versions always use the microsoft compiler. |
| 163 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 164 | 3. Advanced Usage |
| 165 | ----------------- |
| 166 | |
| 167 | Installation Location |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 168 | ^^^^^^^^^^^^^^^^^^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 169 | |
| 170 | Meson default to installing libGL.so in your system's main lib/ |
| 171 | directory and DRI drivers to a dri/ subdirectory. |
| 172 | |
| 173 | Developers will often want to install Mesa to a testing directory rather |
| 174 | than the system library directory. This can be done with the --prefix |
| 175 | option. For example: |
| 176 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 177 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 178 | |
| 179 | meson --prefix="${PWD}/build/install" build/ |
| 180 | |
| 181 | will put the final libraries and drivers into the build/install/ |
| 182 | directory. Then you can set LD_LIBRARY_PATH and LIBGL_DRIVERS_PATH to |
| 183 | that location to run/test the driver. |
| 184 | |
| 185 | Meson also honors ``DESTDIR`` for installs. |
| 186 | |
| 187 | Compiler Options |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 188 | ^^^^^^^^^^^^^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 189 | |
| 190 | Meson supports the common CFLAGS, CXXFLAGS, etc. environment variables |
| 191 | but their use is discouraged because of the many caveats in using them. |
| 192 | |
Eric Engestrom | 9497a1f | 2020-07-09 00:52:27 +0200 | [diff] [blame] | 193 | Instead, it is recommended to use ``-D${lang}_args`` and |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 194 | ``-D${lang}_link_args``. Among the benefits of these options is that |
| 195 | they are guaranteed to persist across rebuilds and reconfigurations. |
| 196 | |
| 197 | This example sets -fmax-errors for compiling C sources and -DMAGIC=123 |
| 198 | for C++ sources: |
| 199 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 200 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 201 | |
| 202 | meson builddir/ -Dc_args=-fmax-errors=10 -Dcpp_args=-DMAGIC=123 |
| 203 | |
| 204 | Compiler Specification |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 205 | ^^^^^^^^^^^^^^^^^^^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 206 | |
| 207 | Meson supports the standard CC and CXX environment variables for |
| 208 | changing the default compiler. Note that Meson does not allow changing |
| 209 | the compilers in a configured builddir so you will need to create a new |
| 210 | build dir for a different compiler. |
| 211 | |
| 212 | This is an example of specifying the clang compilers and cleaning the |
| 213 | build directory before reconfiguring with an extra C option: |
| 214 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 215 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 216 | |
| 217 | CC=clang CXX=clang++ meson build-clang |
| 218 | ninja -C build-clang |
| 219 | ninja -C build-clang clean |
| 220 | meson configure build -Dc_args="-Wno-typedef-redefinition" |
| 221 | ninja -C build-clang |
| 222 | |
| 223 | The default compilers depends on your operating system. Meson supports |
| 224 | most of the popular compilers, a complete list is available |
| 225 | `here <https://mesonbuild.com/Reference-tables.html#compiler-ids>`__. |
| 226 | |
| 227 | LLVM |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 228 | ^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 229 | |
| 230 | Meson includes upstream logic to wrap llvm-config using its standard |
| 231 | dependency interface. |
| 232 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 233 | As of Meson 0.51.0 Meson can use cmake to find LLVM (the cmake finder |
| 234 | was added in Meson 0.49.0, but LLVM cannot be found until 0.51) Due to |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 235 | the way LLVM implements its cmake finder it will only find static |
| 236 | libraries, it will never find libllvm.so. There is also a |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 237 | ``-Dcmake_module_path`` option in this Meson version, which points to |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 238 | the root of an alternative installation (the prefix). For example: |
| 239 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 240 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 241 | |
| 242 | meson builddir -Dcmake_module_path=/home/user/mycmake/prefix |
| 243 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 244 | As of Meson 0.49.0 Meson also has the concept of a `"native |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 245 | file" <https://mesonbuild.com/Native-environments.html>`__, these files |
| 246 | provide information about the native build environment (as opposed to a |
| 247 | cross build environment). They are ini formatted and can override where |
| 248 | to find llvm-config: |
| 249 | |
| 250 | custom-llvm.ini |
| 251 | |
| 252 | :: |
| 253 | |
| 254 | [binaries] |
| 255 | llvm-config = '/usr/local/bin/llvm/llvm-config' |
| 256 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 257 | Then configure Meson: |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 258 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 259 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 260 | |
| 261 | meson builddir/ --native-file custom-llvm.ini |
| 262 | |
| 263 | Meson < 0.49 doesn't support native files, so to specify a custom |
| 264 | ``llvm-config`` you need to modify your ``$PATH`` (or ``%PATH%`` on |
| 265 | windows), which will be searched for ``llvm-config``, |
| 266 | ``llvm-config$version``, and ``llvm-config-$version``: |
| 267 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 268 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 269 | |
| 270 | PATH=/path/to/folder/with/llvm-config:$PATH meson build |
| 271 | |
| 272 | For selecting llvm-config for cross compiling a `"cross |
| 273 | file" <https://mesonbuild.com/Cross-compilation.html#defining-the-environment>`__ |
| 274 | should be used. It uses the same format as the native file above: |
| 275 | |
| 276 | cross-llvm.ini |
| 277 | |
| 278 | :: |
| 279 | |
| 280 | [binaries] |
| 281 | ... |
| 282 | llvm-config = '/usr/lib/llvm-config-32' |
| 283 | cmake = '/usr/bin/cmake-for-my-arch' |
| 284 | |
| 285 | Obviously, only cmake or llvm-config is required. |
| 286 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 287 | Then configure Meson: |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 288 | |
Erik Faye-Lund | d6be994 | 2019-06-04 14:14:13 +0200 | [diff] [blame] | 289 | .. code-block:: console |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 290 | |
| 291 | meson builddir/ --cross-file cross-llvm.ini |
| 292 | |
Erik Faye-Lund | b1c16e5 | 2020-06-27 10:00:10 +0200 | [diff] [blame] | 293 | See the :ref:`Cross Compilation <cross-compilation>` section for more |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 294 | information. |
| 295 | |
| 296 | On windows (and in other cases), using llvm-config or cmake may be |
| 297 | either undesirable or impossible. Meson's solution for this is a |
| 298 | `wrap <https://mesonbuild.com/Wrap-dependency-system-manual.html>`__, in |
| 299 | this case a "binary wrap". Follow the steps below: |
| 300 | |
| 301 | - Install the binaries and headers into the |
| 302 | ``$mesa_src/subprojects/llvm`` |
Erik Faye-Lund | 0835ee9 | 2020-09-29 18:18:37 +0200 | [diff] [blame] | 303 | - Add a meson.build file to that directory (more on that later) |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 304 | |
| 305 | The wrap file must define the following: |
| 306 | |
| 307 | - ``dep_llvm``: a ``declare_dependency()`` object with |
| 308 | include_directories, dependencies, and version set) |
| 309 | |
| 310 | It may also define: |
| 311 | |
| 312 | - ``irbuilder_h``: a ``files()`` object pointing to llvm/IR/IRBuilder.h |
Eric Engestrom | 9497a1f | 2020-07-09 00:52:27 +0200 | [diff] [blame] | 313 | (this is required for SWR) |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 314 | - ``has_rtti``: a ``bool`` that declares whether LLVM was built with |
| 315 | RTTI. Defaults to true |
| 316 | |
| 317 | such a meson.build file might look like: |
| 318 | |
| 319 | :: |
| 320 | |
| 321 | project('llvm', ['cpp']) |
| 322 | |
| 323 | cpp = meson.get_compiler('cpp') |
| 324 | |
| 325 | _deps = [] |
| 326 | _search = join_paths(meson.current_source_dir(), 'lib') |
| 327 | foreach d : ['libLLVMCodeGen', 'libLLVMScalarOpts', 'libLLVMAnalysis', |
| 328 | 'libLLVMTransformUtils', 'libLLVMCore', 'libLLVMX86CodeGen', |
| 329 | 'libLLVMSelectionDAG', 'libLLVMipo', 'libLLVMAsmPrinter', |
| 330 | 'libLLVMInstCombine', 'libLLVMInstrumentation', 'libLLVMMC', |
| 331 | 'libLLVMGlobalISel', 'libLLVMObjectYAML', 'libLLVMDebugInfoPDB', |
| 332 | 'libLLVMVectorize', 'libLLVMPasses', 'libLLVMSupport', |
| 333 | 'libLLVMLTO', 'libLLVMObject', 'libLLVMDebugInfoCodeView', |
| 334 | 'libLLVMDebugInfoDWARF', 'libLLVMOrcJIT', 'libLLVMProfileData', |
| 335 | 'libLLVMObjCARCOpts', 'libLLVMBitReader', 'libLLVMCoroutines', |
| 336 | 'libLLVMBitWriter', 'libLLVMRuntimeDyld', 'libLLVMMIRParser', |
| 337 | 'libLLVMX86Desc', 'libLLVMAsmParser', 'libLLVMTableGen', |
| 338 | 'libLLVMFuzzMutate', 'libLLVMLinker', 'libLLVMMCParser', |
| 339 | 'libLLVMExecutionEngine', 'libLLVMCoverage', 'libLLVMInterpreter', |
| 340 | 'libLLVMTarget', 'libLLVMX86AsmParser', 'libLLVMSymbolize', |
| 341 | 'libLLVMDebugInfoMSF', 'libLLVMMCJIT', 'libLLVMXRay', |
| 342 | 'libLLVMX86AsmPrinter', 'libLLVMX86Disassembler', |
| 343 | 'libLLVMMCDisassembler', 'libLLVMOption', 'libLLVMIRReader', |
| 344 | 'libLLVMLibDriver', 'libLLVMDlltoolDriver', 'libLLVMDemangle', |
| 345 | 'libLLVMBinaryFormat', 'libLLVMLineEditor', |
| 346 | 'libLLVMWindowsManifest', 'libLLVMX86Info', 'libLLVMX86Utils'] |
| 347 | _deps += cpp.find_library(d, dirs : _search) |
| 348 | endforeach |
| 349 | |
| 350 | dep_llvm = declare_dependency( |
| 351 | include_directories : include_directories('include'), |
| 352 | dependencies : _deps, |
| 353 | version : '6.0.0', |
| 354 | ) |
| 355 | |
| 356 | has_rtti = false |
| 357 | irbuilder_h = files('include/llvm/IR/IRBuilder.h') |
| 358 | |
| 359 | It is very important that version is defined and is accurate, if it is |
| 360 | not, workarounds for the wrong version of LLVM might be used resulting |
| 361 | in build failures. |
| 362 | |
| 363 | ``PKG_CONFIG_PATH`` |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 364 | ^^^^^^^^^^^^^^^^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 365 | |
| 366 | The ``pkg-config`` utility is a hard requirement for configuring and |
| 367 | building Mesa on Unix-like systems. It is used to search for external |
| 368 | libraries on the system. This environment variable is used to control |
| 369 | the search path for ``pkg-config``. For instance, setting |
| 370 | ``PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig`` will search for package |
| 371 | metadata in ``/usr/X11R6`` before the standard directories. |
| 372 | |
| 373 | Options |
Erik Faye-Lund | 0841da2 | 2020-04-18 12:38:05 +0200 | [diff] [blame] | 374 | ^^^^^^^ |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 375 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 376 | One of the oddities of Meson is that some options are different when |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 377 | passed to the ``meson`` than to ``meson configure``. These options are |
| 378 | passed as --option=foo to ``meson``, but -Doption=foo to |
| 379 | ``meson configure``. Mesa defined options are always passed as |
| 380 | -Doption=foo. |
| 381 | |
| 382 | For those coming from autotools be aware of the following: |
| 383 | |
| 384 | ``--buildtype/-Dbuildtype`` |
| 385 | This option will set the compiler debug/optimisation levels to aid |
| 386 | debugging the Mesa libraries. |
| 387 | |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 388 | Note that in Meson this defaults to ``debugoptimized``, and not |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 389 | setting it to ``release`` will yield non-optimal performance and |
| 390 | binary size. Not using ``debug`` may interfere with debugging as some |
| 391 | code and validation will be optimized away. |
| 392 | |
| 393 | For those wishing to pass their own optimization flags, use the |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 394 | ``plain`` buildtype, which causes Meson to inject no additional |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 395 | compiler arguments, only those in the C/CXXFLAGS and those that mesa |
| 396 | itself defines. |
| 397 | |
| 398 | ``-Db_ndebug`` |
Erik Faye-Lund | e198fb6 | 2020-09-29 18:20:24 +0200 | [diff] [blame] | 399 | This option controls assertions in Meson projects. When set to |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 400 | ``false`` (the default) assertions are enabled, when set to true they |
| 401 | are disabled. This is unrelated to the ``buildtype``; setting the |
| 402 | latter to ``release`` will not turn off assertions. |
| 403 | |
Erik Faye-Lund | 1d250bf | 2020-06-27 09:48:48 +0200 | [diff] [blame] | 404 | .. _cross-compilation: |
| 405 | |
Erik Faye-Lund | 4d06683 | 2020-06-12 20:09:42 +0200 | [diff] [blame] | 406 | 4. Cross-compilation and 32-bit builds |
| 407 | -------------------------------------- |
| 408 | |
| 409 | `Meson supports |
| 410 | cross-compilation <https://mesonbuild.com/Cross-compilation.html>`__ by |
| 411 | specifying a number of binary paths and settings in a file and passing |
| 412 | this file to ``meson`` or ``meson configure`` with the ``--cross-file`` |
| 413 | parameter. |
| 414 | |
| 415 | This file can live at any location, but you can use the bare filename |
| 416 | (without the folder path) if you put it in $XDG_DATA_HOME/meson/cross or |
| 417 | ~/.local/share/meson/cross |
| 418 | |
| 419 | Below are a few example of cross files, but keep in mind that you will |
| 420 | likely have to alter them for your system. |
| 421 | |
| 422 | Those running on ArchLinux can use the AUR-maintained packages for some |
| 423 | of those, as they'll have the right values for your system: |
| 424 | |
| 425 | - `meson-cross-x86-linux-gnu <https://aur.archlinux.org/packages/meson-cross-x86-linux-gnu>`__ |
| 426 | - `meson-cross-aarch64-linux-gnu <https://aur.archlinux.org/packages/meson-cross-aarch64-linux-gnu>`__ |
| 427 | |
| 428 | 32-bit build on x86 linux: |
| 429 | |
| 430 | :: |
| 431 | |
| 432 | [binaries] |
| 433 | c = '/usr/bin/gcc' |
| 434 | cpp = '/usr/bin/g++' |
| 435 | ar = '/usr/bin/gcc-ar' |
| 436 | strip = '/usr/bin/strip' |
| 437 | pkgconfig = '/usr/bin/pkg-config-32' |
| 438 | llvm-config = '/usr/bin/llvm-config32' |
| 439 | |
| 440 | [properties] |
| 441 | c_args = ['-m32'] |
| 442 | c_link_args = ['-m32'] |
| 443 | cpp_args = ['-m32'] |
| 444 | cpp_link_args = ['-m32'] |
| 445 | |
| 446 | [host_machine] |
| 447 | system = 'linux' |
| 448 | cpu_family = 'x86' |
| 449 | cpu = 'i686' |
| 450 | endian = 'little' |
| 451 | |
| 452 | 64-bit build on ARM linux: |
| 453 | |
| 454 | :: |
| 455 | |
| 456 | [binaries] |
| 457 | c = '/usr/bin/aarch64-linux-gnu-gcc' |
| 458 | cpp = '/usr/bin/aarch64-linux-gnu-g++' |
| 459 | ar = '/usr/bin/aarch64-linux-gnu-gcc-ar' |
| 460 | strip = '/usr/bin/aarch64-linux-gnu-strip' |
| 461 | pkgconfig = '/usr/bin/aarch64-linux-gnu-pkg-config' |
| 462 | exe_wrapper = '/usr/bin/qemu-aarch64-static' |
| 463 | |
| 464 | [host_machine] |
| 465 | system = 'linux' |
| 466 | cpu_family = 'aarch64' |
| 467 | cpu = 'aarch64' |
| 468 | endian = 'little' |
| 469 | |
| 470 | 64-bit build on x86 windows: |
| 471 | |
| 472 | :: |
| 473 | |
| 474 | [binaries] |
| 475 | c = '/usr/bin/x86_64-w64-mingw32-gcc' |
| 476 | cpp = '/usr/bin/x86_64-w64-mingw32-g++' |
| 477 | ar = '/usr/bin/x86_64-w64-mingw32-ar' |
| 478 | strip = '/usr/bin/x86_64-w64-mingw32-strip' |
| 479 | pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config' |
| 480 | exe_wrapper = 'wine' |
| 481 | |
| 482 | [host_machine] |
| 483 | system = 'windows' |
| 484 | cpu_family = 'x86_64' |
| 485 | cpu = 'i686' |
| 486 | endian = 'little' |