Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BUILD.md - github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8c69cf6791c2800f5c7a29536a8869e1114462b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# Build Instructions

Instructions for building this repository on Linux, Windows, and MacOS.

## Table Of Contents

- [Build Instructions](#build-instructions)
  - [Table Of Contents](#table-of-contents)
  - [Contributing to the Repository](#contributing-to-the-repository)
  - [Repository Content](#repository-content)
    - [Installed Files](#installed-files)
  - [Repository Set-Up](#repository-set-up)
    - [Display Drivers](#display-drivers)
    - [Download the Repository](#download-the-repository)
    - [Repository Dependencies](#repository-dependencies)
      - [Vulkan-Headers](#vulkan-headers)
      - [Test Dependencies](#test-dependencies)
    - [Build and Install Directories](#build-and-install-directories)
    - [Building Dependent Repositories with Known-Good Revisions](#building-dependent-repositories-with-known-good-revisions)
      - [Manually](#manually)
        - [Notes About the Manual Option](#notes-about-the-manual-option)
      - [Automatically](#automatically)
        - [Notes About the Automatic Option](#notes-about-the-automatic-option)
    - [Generated source code](#generated-source-code)
    - [Build Options](#build-options)
  - [Building On Windows](#building-on-windows)
    - [Windows Development Environment Requirements](#windows-development-environment-requirements)
    - [Windows Build - Microsoft Visual Studio](#windows-build---microsoft-visual-studio)
      - [Windows Quick Start](#windows-quick-start)
      - [Use `CMake` to Create the Visual Studio Project Files](#use-cmake-to-create-the-visual-studio-project-files)
      - [Build the Solution From the Command Line](#build-the-solution-from-the-command-line)
      - [Build the Solution With Visual Studio](#build-the-solution-with-visual-studio)
      - [Windows Install Target](#windows-install-target)
    - [Windows Notes](#windows-notes)
      - [Using The Vulkan Loader Library in this Repository on Windows](#using-the-vulkan-loader-library-in-this-repository-on-windows)
  - [Building On Linux](#building-on-linux)
    - [Linux Development Environment Requirements](#linux-development-environment-requirements)
      - [Required Package List](#required-package-list)
    - [Linux Build](#linux-build)
      - [Linux Quick Start](#linux-quick-start)
      - [Use CMake to Create the Make Files](#use-cmake-to-create-the-make-files)
      - [Build the Project](#build-the-project)
    - [Linux Notes](#linux-notes)
      - [Using The Vulkan Loader Library in this Repository on Linux](#using-the-vulkan-loader-library-in-this-repository-on-linux)
      - [WSI Support Build Options](#wsi-support-build-options)
      - [Linux Install to System Directories](#linux-install-to-system-directories)
      - [Linux Uninstall](#linux-uninstall)
      - [Linux 32-bit support](#linux-32-bit-support)
  - [Building on MacOS](#building-on-macos)
    - [MacOS Development Environment Requirements](#macos-development-environment-requirements)
    - [Clone the Repository](#clone-the-repository)
    - [MacOS build](#macos-build)
      - [CMake Generators](#cmake-generators)
      - [Building with the Unix Makefiles Generator](#building-with-the-unix-makefiles-generator)
      - [Building with the Xcode Generator](#building-with-the-xcode-generator)
    - [Using the new macOS loader](#using-the-new-macos-loader)
  - [Building on Fuchsia](#building-on-fuchsia)
  - [Building on QNX](#building-on-qnx)
    - [SDK Symbols](#sdk-symbols)
  - [Cross Compilation](#cross-compilation)
    - [Unknown function handling which requires explicit assembly implementations](#unknown-function-handling-which-requires-explicit-assembly-implementations)
      - [Platforms which fully support unknown function handling](#platforms-which-fully-support-unknown-function-handling)
    - [Link Time Optimization](#link-time-optimization)
  - [Tests](#tests)


## Contributing to the Repository

If you intend to contribute, the preferred work flow is for you to develop
your contribution in a fork of this repository in your GitHub account and then
submit a pull request. Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file
in this repository for more details.

## Repository Content

This repository contains the source code necessary to build the desktop Vulkan
loader and its tests.

### Installed Files

The `install` target installs the following files under the directory
indicated by *install_dir*:

- *install_dir*`/lib` : The Vulkan loader library
- *install_dir*`/bin` : The Vulkan loader library DLL (Windows)

The `uninstall` target can be used to remove the above files from the install
directory.

## Repository Set-Up

### Display Drivers

This repository does not contain a Vulkan-capable driver. You will need to
obtain and install a Vulkan driver from your graphics hardware vendor or from
some other suitable source if you intend to run Vulkan applications.

### Download the Repository

To create your local git repository:

    git clone https://github.com/KhronosGroup/Vulkan-Loader.git

### Repository Dependencies

This repository attempts to resolve some of its dependencies by using
components found from the following places, in this order:

1. CMake or Environment variable overrides (e.g., -DVULKAN_HEADERS_INSTALL_DIR)
1. LunarG Vulkan SDK, located by the `VULKAN_SDK` environment variable
1. System-installed packages, mostly applicable on Linux

Dependencies that cannot be resolved by the SDK or installed packages must be
resolved with the "install directory" override and are listed below. The
"install directory" override can also be used to force the use of a specific
version of that dependency.

#### Vulkan-Headers

This repository has a required dependency on the [Vulkan Headers repository](https://github.com/KhronosGroup/Vulkan-Headers).
You must clone the headers repository and build its `install` target before
building this repository. The Vulkan-Headers repository is required because it
contains the Vulkan API definition files (registry) that are required to build
the loader. You must also take note of the headers install directory and pass
it on the CMake command line for building this repository, as described below.

#### Test Dependencies

The loader tests depend on the [Google Test](https://github.com/google/googletest) library and
on Windows platforms depends on the [Microsoft Detours](https://github.com/microsoft/Detours) library.

To build the tests, pass the `-DUPDATE_DEPS=ON` and `-DBUILD_TESTS=ON` options when generating the project:
```bash
cmake ... -DUPDATE_DEPS=ON -DBUILD_TESTS=ON ...
```
This will ensure googletest and detours is downloaded and the appropriate version is used.

### Build and Install Directories

A common convention is to place the `build` directory in the top directory of
the repository and place the `install` directory as a child of the `build`
directory. The remainder of these instructions follow this convention,
although you can place these directories in any location.

### Building Dependent Repositories with Known-Good Revisions

There is a Python utility script, `scripts/update_deps.py`, that you can use
to gather and build the dependent repositories mentioned above.
This program also uses information stored in the `scripts/known-good.json` file
to checkout dependent repository revisions that are known to be compatible with
the revision of this repository that you currently have checked out.

You can choose to do this manually or automatically.
The first step to either is cloning the Vulkan-Loader repo and stepping into
that newly cloned folder:

```
  git clone git@github.com:KhronosGroup/Vulkan-Loader.git
  cd Vulkan-Loader
```

#### Manually

To manually update the dependencies you now must create the build folder, and
run the update deps script followed by the necessary CMake build commands:

```
  mkdir build
  cd build
  ../scripts/update_deps.py
  cmake -C helper.cmake ..
  cmake --build .
```

##### Notes About the Manual Option

- You may need to adjust some of the CMake options based on your platform. See
  the platform-specific sections later in this document.
- The `update_deps.py` script fetches and builds the dependent repositories in
  the current directory when it is invoked. In this case, they are built in
  the `build` directory.
- The `build` directory is also being used to build this
  (Vulkan-ValidationLayers) repository. But there shouldn't be any conflicts
  inside the `build` directory between the dependent repositories and the
  build files for this repository.
- The `--dir` option for `update_deps.py` can be used to relocate the
  dependent repositories to another arbitrary directory using an absolute or
  relative path.
- The `update_deps.py` script generates a file named `helper.cmake` and places
  it in the same directory as the dependent repositories (`build` in this
  case). This file contains CMake commands to set the CMake `*_INSTALL_DIR`
  variables that are used to point to the install artifacts of the dependent
  repositories. You can use this file with the `cmake -C` option to set these
  variables when you generate your build files with CMake. This lets you avoid
  entering several `*_INSTALL_DIR` variable settings on the CMake command line.
- If using "MINGW" (Git For Windows), you may wish to run
  `winpty update_deps.py` in order to avoid buffering all of the script's
  "print" output until the end and to retain the ability to interrupt script
  execution.
- Please use `update_deps.py --help` to list additional options and read the
  internal documentation in `update_deps.py` for further information.


#### Automatically

On the other hand, if you choose to let the CMake scripts do all the
heavy-lifting, you may just trigger the following CMake commands:

```
  cmake -S. -Bbuild -DUPDATE_DEPS=On
  cmake --build build
```

##### Notes About the Automatic Option

- You may need to adjust some of the CMake options based on your platform. See
  the platform-specific sections later in this document.
- The `build` directory is also being used to build this
  (Vulkan-ValidationLayers) repository. But there shouldn't be any conflicts
  inside the `build` directory between the dependent repositories and the
  build files for this repository.


### Generated source code

This repository contains generated source code in the `loader/generated`
directory which is not intended to be modified directly. Instead, changes should be
made to the corresponding generator in the `scripts` directory. The source files can
then be regenerated using `scripts/generate_source.py`:

    python3 scripts/generate_source.py PATH_TO_VULKAN_HEADERS_REGISTRY_DIR

A helper CMake target `VulkanLoader_generated_source` is also provided to simplify
the invocation of `scripts/generate_source.py` from the build directory:

    cmake --build . --target VulkanLoader_generated_source

### Build Options

When generating native platform build files through CMake, several options can
be specified to customize the build. Some of the options are binary on/off
options, while others take a string as input. The following is a table of all
on/off options currently supported by this repository:

| Option                       | Platform | Default | Description                                                                                                                                                                       |
| ---------------------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| BUILD_TESTS                  | All      | `OFF`   | Controls whether or not the loader tests are built.                                                                                                                               |
| BUILD_WSI_XCB_SUPPORT        | Linux    | `ON`    | Build the loader with the XCB entry points enabled. Without this, the XCB headers should not be needed, but the extension `VK_KHR_xcb_surface` won't be available.                |
| BUILD_WSI_XLIB_SUPPORT       | Linux    | `ON`    | Build the loader with the Xlib entry points enabled. Without this, the X11 headers should not be needed, but the extension `VK_KHR_xlib_surface` won't be available.              |
| BUILD_WSI_WAYLAND_SUPPORT    | Linux    | `ON`    | Build the loader with the Wayland entry points enabled. Without this, the Wayland headers should not be needed, but the extension `VK_KHR_wayland_surface` won't be available.    |
| BUILD_WSI_DIRECTFB_SUPPORT   | Linux    | `OFF`   | Build the loader with the DirectFB entry points enabled. Without this, the DirectFB headers should not be needed, but the extension `VK_EXT_directfb_surface` won't be available. |
| BUILD_WSI_SCREEN_QNX_SUPPORT | QNX      | `OFF`   | Build the loader with the QNX Screen entry points enabled. Without this the extension `VK_QNX_screen_surface` won't be available.                                                 |
| ENABLE_WIN10_ONECORE         | Windows  | `OFF`   | Link the loader to the [OneCore](https://msdn.microsoft.com/en-us/library/windows/desktop/mt654039.aspx) umbrella library, instead of the standard Win32 ones.                    |
| USE_GAS                      | Linux    | `ON`    | Controls whether to build assembly files with the GNU assembler, else fallback to C code.                                                                                         |
| USE_MASM                     | Windows  | `ON`    | Controls whether to build assembly files with MS assembler, else fallback to C code                                                                                               |
| BUILD_STATIC_LOADER          | macOS    | `OFF`   | This allows the loader to be built as a static library on macOS. Not tested, use at your own risk.                                                                                |
The following is a table of all string options currently supported by this repository:

| Option                | Platform    | Default                       | Description                                                                                                                                          |
| --------------------- | ----------- | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| FALLBACK_CONFIG_DIRS  | Linux/MacOS | `/etc/xdg`                    | Configuration path(s) to use instead of `XDG_CONFIG_DIRS` if that environment variable is unavailable. The default setting is freedesktop compliant. |
| FALLBACK_DATA_DIRS    | Linux/MacOS | `/usr/local/share:/usr/share` | Configuration path(s) to use instead of `XDG_DATA_DIRS` if that environment variable is unavailable. The default setting is freedesktop compliant.   |
| BUILD_DLL_VERSIONINFO | Windows     | `""` (empty string)           | Allows setting the Windows specific version information for the Loader DLL. Format is "major.minor.patch.build".                                     |

These variables should be set using the `-D` option when invoking CMake to generate the native platform files.

### CCACHE

There are 2 methods to enable CCACHE:

1.) Set environment variables

```bash
# Requires CMake 3.17 (https://cmake.org/cmake/help/latest/envvar/CMAKE_LANG_COMPILER_LAUNCHER.html)
export CMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/ccache
export CMAKE_C_COMPILER_LAUNCHER=/usr/bin/ccache
```

2.) Pass in cache variables

```
cmake ... -D CMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/ccache -D CMAKE_C_COMPILER_LAUNCHER=/usr/bin/ccache
```



## Building On Windows

### Windows Development Environment Requirements

- Windows
  - Any Personal Computer version supported by Microsoft
- Microsoft [Visual Studio](https://www.visualstudio.com/)
  - Versions
    - [2022](https://www.visualstudio.com/vs/downloads/)
    - [2017 & 2019](https://www.visualstudio.com/vs/older-downloads/)
  - The Community Edition of each of the above versions is sufficient, as
    well as any more capable edition.
- [CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.zip) is recommended.
  - Use the installer option to add CMake to the system PATH
- Git Client Support
  - [Git for Windows](http://git-scm.com/download/win) is a popular solution
    for Windows
  - Some IDEs (e.g., [Visual Studio](https://www.visualstudio.com/),
    [GitHub Desktop](https://desktop.github.com/)) have integrated
    Git client support

### Windows Build - Microsoft Visual Studio

The general approach is to run CMake to generate the Visual Studio project
files. Then either run CMake with the `--build` option to build from the
command line or use the Visual Studio IDE to open the generated solution and
work with the solution interactively.

#### Windows Quick Start

Open a developer command prompt and enter:

    cd Vulkan-Loader
    mkdir build
    cd build
    cmake -A x64 -DUPDATE_DEPS=ON ..
    cmake --build .

The above commands instruct CMake to find and use the default Visual Studio
installation to generate a Visual Studio solution and projects for the x64
architecture. The second CMake command builds the Debug (default)
configuration of the solution.

#### Use `CMake` to Create the Visual Studio Project Files

Change your current directory to the top of the cloned repository directory,
create a build directory and generate the Visual Studio project files:

    cd Vulkan-Loader
    mkdir build
    cd build
    cmake -DUPDATE_DEPS=ON -G "Visual Studio 16 2019" -A x64 ..

> Note: The `..` parameter tells `cmake` the location of the top of the
> repository. If you place your build directory someplace else, you'll need to
> specify the location of the repository differently.

The `-G` option is used to select the generator

Supported Visual Studio generators:
* `Visual Studio 17 2022`
* `Visual Studio 16 2019`
* `Visual Studio 15 2017`

The `-A` option is used to select either the "Win32", "x64", or "ARM64 architecture.

When generating the project files, the absolute path to a Vulkan-Headers
install directory must be provided. This can be done automatically by the
`-DUPDATE_DEPS=ON` option, by directly setting the
`VULKAN_HEADERS_INSTALL_DIR` environment variable, or by setting the
`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
either case, the variable should point to the installation directory of a
Vulkan-Headers repository built with the install target.

The above steps create a Windows solution file named `Vulkan-Loader.sln` in
the build directory.

At this point, you can build the solution from the command line or open the
generated solution with Visual Studio.

#### Build the Solution From the Command Line

While still in the build directory:

    cmake --build .

to build the Debug configuration (the default), or:

    cmake --build . --config Release

to make a Release build.

#### Build the Solution With Visual Studio

Launch Visual Studio and open the "Vulkan-Loader.sln" solution file in the
build folder. You may select "Debug" or "Release" from the Solution
Configurations drop-down list. Start a build by selecting the Build->Build
Solution menu item.

#### Windows Install Target

The CMake project also generates an "install" target that you can use to copy
the primary build artifacts to a specific location using a "bin, include, lib"
style directory structure. This may be useful for collecting the artifacts and
providing them to another project that is dependent on them.

The default location is `$CMAKE_BINARY_DIR\install`, but can be changed with
the `CMAKE_INSTALL_PREFIX` variable when first generating the project build
files with CMake.

You can build the install target from the command line with:

    cmake --build . --config Release --target install

or build the `INSTALL` target from the Visual Studio solution explorer.


### Windows Notes

#### Using The Vulkan Loader Library in this Repository on Windows

Vulkan programs must be able to find and use the Vulkan loader
(`vulkan-1.dll`) library as well as any other libraries the program requires.
One convenient way to do this is to copy the required libraries into the same
directory as the program. The projects in this solution copy the Vulkan loader
library and the "googletest" libraries to the `build\tests\Debug` or the
`build\tests\Release` directory, which is where the
`vk_loader_validation_test.exe` executable is found, depending on what
configuration you built.

Other techniques include placing the library in a system folder
(C:\Windows\System32) or in a directory that appears in the `PATH` environment
variable.

See the documentation in the `docs` folder in this
repository for more information on how the loader finds driver libraries and
layer libraries. The document also describes both how ICDs and layers should
be packaged, and how developers can point to ICDs and layers within their
builds.

## Building On Linux

### Linux Development Environment Requirements

This repository has been built and tested on the two most recent Ubuntu LTS
versions. Currently, the oldest supported version is Ubuntu 18.04, meaning
that the minimum officially supported C++11 compiler version is GCC 5.4.0,
although earlier versions may work. It should be straightforward to adapt this
repository to other Linux distributions.

[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz) is recommended.

#### Required Package List

    sudo apt-get install git build-essential libx11-xcb-dev \
        libxkbcommon-dev libwayland-dev libxrandr-dev

### Linux Build

The general approach is to run CMake to generate make files. Then either run
CMake with the `--build` option or `make` to build from the command line.

#### Linux Quick Start

    cd Vulkan-Loader
    mkdir build
    cd build
    cmake -DUPDATE_DEPS=ON ..
    make

See below for the details.

#### Use CMake to Create the Make Files

Change your current directory to the top of the cloned repository directory,
create a build directory and generate the make files.

    cd Vulkan-Loader
    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Debug \
          -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
          -DCMAKE_INSTALL_PREFIX=install ..

> Note: The `..` parameter tells `cmake` the location of the top of the
> repository. If you place your `build` directory someplace else, you'll need
> to specify the location of the repository top differently.

Use `-DCMAKE_BUILD_TYPE` to specify a Debug or Release build.

When generating the project files, the absolute path to a Vulkan-Headers
install directory must be provided. This can be done automatically by the
`-DUPDATE_DEPS=ON` option, by directly setting the
`VULKAN_HEADERS_INSTALL_DIR` environment variable, or by setting the
`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
either case, the variable should point to the installation directory of a
Vulkan-Headers repository built with the install target.

> Note: For Linux, the default value for `CMAKE_INSTALL_PREFIX` is
> `/usr/local`, which would be used if you do not specify
> `CMAKE_INSTALL_PREFIX`. In this case, you may need to use `sudo` to install
> to system directories later when you run `make install`.

#### Build the Project

You can just run `make` to begin the build.

To speed up the build on a multi-core machine, use the `-j` option for `make`
to specify the number of cores to use for the build. For example:

    make -j4

You can also use

    cmake --build .

### Linux Notes

#### Using The Vulkan Loader Library in this Repository on Linux

If you want to run a Vulkan application that is not built within this
repository with the loader you just built from this repository, you can direct
the application to load it from your build directory:

    export LD_LIBRARY_PATH=<path to your repository root>/build/loader

#### WSI Support Build Options

By default, the Vulkan Loader is built with support for the Vulkan-defined WSI
display servers: Xcb, Xlib, and Wayland. It is recommended to build the
repository components with support for these display servers to maximize their
usability across Linux platforms. If it is necessary to build these modules
without support for one of the display servers, the appropriate CMake option
of the form `BUILD_WSI_xxx_SUPPORT` can be set to `OFF`.

#### Linux Install to System Directories

Installing the files resulting from your build to the systems directories is
optional since environment variables can usually be used instead to locate the
binaries. There are also risks with interfering with binaries installed by
packages. If you are certain that you would like to install your binaries to
system directories, you can proceed with these instructions.

Assuming that you've built the code as described above and the current
directory is still `build`, you can execute:

    sudo make install

This command installs files to `/usr/local` if no `CMAKE_INSTALL_PREFIX` is
specified when creating the build files with CMake:

- `/usr/local/lib`:  Vulkan loader library and package config files

You may need to run `ldconfig` in order to refresh the system loader search
cache on some Linux systems.

You can further customize the installation location by setting additional
CMake variables to override their defaults. For example, if you would like to
install to `/tmp/build` instead of `/usr/local`, on your CMake command line
specify:

    -DCMAKE_INSTALL_PREFIX=/tmp/build

Then run `make install` as before. The install step places the files in
`/tmp/build`. This may be useful for collecting the artifacts and providing
them to another project that is dependent on them.

Using the `CMAKE_INSTALL_PREFIX` to customize the install location also
modifies the loader search paths to include searching for layers in the
specified install location. In this example, setting `CMAKE_INSTALL_PREFIX` to
`/tmp/build` causes the loader to search
`/tmp/build/etc/vulkan/explicit_layer.d` and
`/tmp/build/share/vulkan/explicit_layer.d` for the layer JSON files. The
loader also searches the "standard" system locations of
`/etc/vulkan/explicit_layer.d` and `/usr/share/vulkan/explicit_layer.d` after
searching the two locations under `/tmp/build`.

You can further customize the installation directories by using the CMake
variables `CMAKE_INSTALL_SYSCONFDIR` to rename the `etc` directory and
`CMAKE_INSTALL_DATADIR` to rename the `share` directory.

See the CMake documentation for more details on using these variables to
further customize your installation.

Also see the `LoaderAndLayerInterface` document in the `loader` folder in this
repository for more information about loader operation.

Note that some executables in this repository (e.g.,
`vk_loader_validation_tests`) use the RPATH linker directive to load the
Vulkan loader from the build directory, `build` in this example. This means
that even after installing the loader to the system directories, these
executables still use the loader from the build directory.

#### Linux Uninstall

To uninstall the files from the system directories, you can execute:

    sudo make uninstall


#### Linux 32-bit support

Usage of this repository's contents in 32-bit Linux environments is not
officially supported. However, since this repository is supported on 32-bit
Windows, these modules should generally work on 32-bit Linux.

Here are some notes for building 32-bit targets on a 64-bit Ubuntu "reference"
platform:

If not already installed, install the following 32-bit development libraries:

`gcc-multilib g++-multilib libx11-dev:i386`

This list may vary depending on your distribution and which windowing systems
you are building for.

Set up your environment for building 32-bit targets:

    export ASFLAGS=--32
    export CFLAGS=-m32
    export CXXFLAGS=-m32
    export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu

Again, your PKG_CONFIG configuration may be different, depending on your
distribution.

Finally, rebuild the repository using `cmake` and `make`, as explained above.

## Building on MacOS

### MacOS Development Environment Requirements

Tested on OSX version 10.12

NOTE: To force the OSX version set the environment variable [MACOSX_DEPLOYMENT_TARGET](https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html) when building VVL and it's dependencies.

Setup Homebrew and components

- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed.

      /usr/bin/ruby -e "$(curl -fsSL \
          https://raw.githubusercontent.com/Homebrew/install/master/install)"

- Ensure Homebrew is at the beginning of your PATH:

      export PATH=/usr/local/bin:$PATH

- Add packages with the following (may need refinement)

      brew install python python3 git

### Clone the Repository

Clone the Vulkan-ValidationLayers repository:

    git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git

### MacOS build

[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Darwin-x86_64.tar.gz) is recommended.

#### CMake Generators

This repository uses CMake to generate build or project files that are then
used to build the repository. The CMake generators explicitly supported in
this repository are:

- Unix Makefiles
- Xcode

#### Building with the Unix Makefiles Generator

This generator is the default generator.

When generating the project files, the absolute path to a Vulkan-Headers
install directory must be provided. This can be done automatically by the
`-DUPDATE_DEPS=ON` option, by directly setting the
`VULKAN_HEADERS_INSTALL_DIR` environment variable, or by setting the
`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
either case, the variable should point to the installation directory of a
Vulkan-Headers repository built with the install target.

    mkdir build
    cd build
    cmake -DUPDATE_DEPS=ON -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir -DCMAKE_BUILD_TYPE=Debug ..
    make

To speed up the build on a multi-core machine, use the `-j` option for `make`
to specify the number of cores to use for the build. For example:

    make -j4

#### Building with the Xcode Generator

To create and open an Xcode project:

    mkdir build-xcode
    cd build-xcode
    cmake -GXcode ..
    open Vulkan-Loader.xcodeproj

Within Xcode, you can select Debug or Release builds in the project's Build
Settings.

### Using the new macOS loader

If you want to test a Vulkan application with the loader you just built, you
can direct the application to load it from your build directory:

    export DYLD_LIBRARY_PATH=<path to your repository>/build/loader

## Building on Fuchsia

Fuchsia uses the project's GN build system to integrate with the Fuchsia platform build.

## Building on QNX

QNX is using its own build system. The proper build environment must be set
under the QNX host development system (Linux, Win64, MacOS) by invoking
the shell/batch script provided with QNX installation.

Then change working directory to the "build-qnx" in this project and type "make".
It will build the ICD loader for all CPU targets supported by QNX.

### SDK Symbols

The Vulkan Loader is a component of the Fuchsia SDK, so it must explicitly declare its exported symbols in
the file vulkan.symbols.api; see [SDK](https://fuchsia.dev/fuchsia-src/development/sdk).

## Cross Compilation

While this repo is capable of cross compilation, there are a handful of caveats.

### Unknown function handling which requires explicit assembly implementations

Unknown function handling is only fully supported on select platforms due to the
need for assembly in the implementation. Other platforms will need to disable
assembly by setting `USE_GAS` or `USE_MASM` to `OFF`.
#### Platforms which fully support unknown function handling

* 64 bit Windows (x64)
* 32 bit Windows (x86)
* 64 bit Linux (x64)
* 32 bit Linux (x86)
* 64 bit Arm (aarch64)

Platforms not listed will use a fallback C Code path that relies on tail-call optimization to work.
No guarantees are made about the use of the fallback code paths.

### Link Time Optimization

When cross compiling, the use of Link Time Optimization (LTO) and unknown function handling
is not supported. Either LTO needs to be turned off, or the assembly should be disabled.

## Tests

To build tests, make sure that the `BUILD_TESTS` option is set to true. Using
the command line, this looks like `-DBUILD_TESTS=ON`.

This project is configured to run with `ctest`, which makes it easy to run the
tests. To run the tests, change the directory to that of the build direction, and
execute `ctest`.

More details can be found in the [README.md](./tests/README.md) for the tests
directory of this project.