Bug 109739 - Mesa build fails when vulkan-overlay-layer option is enabled
Summary: Mesa build fails when vulkan-overlay-layer option is enabled
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/Common (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-22 04:42 UTC by Shmerl
Modified: 2019-02-26 21:02 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shmerl 2019-02-22 04:42:41 UTC
I tried building Mesa master on Debian testing, enabling vulkan-overlay-layer, and it failed because of mismatching includes. I installed glslang-tools vulkan-validationlayers-dev and enabled the option:

-Dvulkan-overlay-layer=true

I had to modify includes like this, to make it build:

diff --git a/src/vulkan/overlay-layer/overlay.cpp b/src/vulkan/overlay-layer/overlay.cpp
index f3678198b00..4b8010ba003 100644
--- a/src/vulkan/overlay-layer/overlay.cpp
+++ b/src/vulkan/overlay-layer/overlay.cpp
@@ -25,13 +25,13 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include <vk_loader_platform.h>
+#include <vulkan/vk_loader_platform.h>
 #include <vulkan/vulkan.h>
-#include <vk_dispatch_table_helper.h>
+#include <vulkan/vk_dispatch_table_helper.h>
 #include <vulkan/vk_layer.h>
-#include "vk_layer_data.h"
+#include "vulkan/vk_layer_data.h"
 #include "vk_layer_table.h"
-#include "vk_layer_extension_utils.h"
+#include "vulkan/vk_layer_extension_utils.h"
 
 #include "imgui.h"
 
diff --git a/src/vulkan/overlay-layer/vk_layer_table.cpp b/src/vulkan/overlay-layer/vk_layer_table.cpp
index 4a033b9add6..f5865fa3a6f 100644
--- a/src/vulkan/overlay-layer/vk_layer_table.cpp
+++ b/src/vulkan/overlay-layer/vk_layer_table.cpp
@@ -19,7 +19,7 @@
  */
 #include <assert.h>
 #include <unordered_map>
-#include "vk_dispatch_table_helper.h"
+#include "vulkan/vk_dispatch_table_helper.h"
 #include "vulkan/vk_layer.h"
 #include "vk_layer_table.h"
 static device_table_map tableMap;
Comment 1 Shmerl 2019-02-22 04:46:34 UTC
Another problem was that ninja install doesn't deploy actual layer .so file.

I did this in my build script:

    DESTDIR="$dest_dir" LC_ALL=C.UTF-8 ninja install

It deployed VkLayer_MESA_overlay.json, but missed libVkLayer_MESA_overlay.so.
Comment 2 oschowa 2019-02-22 10:47:27 UTC
I had to add this to get the overlay .so deployed:

diff --git a/src/vulkan/overlay-layer/meson.build b/src/vulkan/overlay-layer/meson.build
index 573983e0438..9d1bc97c131 100644
--- a/src/vulkan/overlay-layer/meson.build
+++ b/src/vulkan/overlay-layer/meson.build
@@ -48,6 +48,7 @@ vklayer_mesa_overlay = shared_library(
   link_args : cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro']),
   link_with : [libmesa_util, libvulkan_util],
   install_dir : vklayer_install_dir,
+  install : true
 )

also currently the layer won't get build with 

-D vulkan-drivers=''

so you can't build it independently.
Comment 3 Tapani Pälli 2019-02-22 12:21:41 UTC
It seems like meson.build should add 'inc_vulkan_validation' dev header directory to include_directories or just append 'vulkan/' for each header used from there.
Comment 4 Lionel Landwerlin 2019-02-22 12:33:05 UTC
On the install : true, I was told to remove it. Not being a meson expert but I can definitely put it back.

On the header files of the loader/validation-layers, I have the headers installed in a different directory because of a compile option of the loader. I should probably go with the same options as debian.
Comment 5 Lionel Landwerlin 2019-02-22 13:04:34 UTC
Uploaded https://gitlab.freedesktop.org/mesa/mesa/merge_requests/293
Comment 6 Shmerl 2019-02-25 20:26:47 UTC
From https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/729#issuecomment-467162536

it looks like the expected correct usage for these headers is <vulkan/*.h>
Comment 7 Lionel Landwerlin 2019-02-26 13:20:45 UTC
Fixed by : 

commit 964675082231963816a60271390bd04d561888fd
Author: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Date:   Fri Feb 22 12:54:53 2019 +0000

    vulkan/overlay: fix includes
    
    The Loader/Validation-Layers repository allow the user to choose where
    header files are installed. On my system I choose /usr/include
    thinking it was the obvious "base" location, but it turns out the
    headers end up being installed right there rather in a vulkan
    subdirectory. On Debian/Ubuntu the selected installation path is
    /usr/include/vulkan, so just go with that.
    
    Hopefully other distro don't choose another path.
    
    Note that the validation layer doesn't provide a .pc file so we have
    no way of querying where the headers are installed.
    
    Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109739
    Acked-by: Eric Engestrom <eric.engestrom@intel.com>
Comment 8 Mike Lothian 2019-02-26 18:51:29 UTC
On Gentoo it installs into /usr/include :(
Comment 9 Shmerl 2019-02-26 18:57:52 UTC
(In reply to Mike Lothian from comment #8)
> On Gentoo it installs into /usr/include :(

According to upstream, that's something distributions should fix. You can open a Gentoo bug.
Comment 10 Mike Lothian 2019-02-26 20:54:16 UTC
I've created a merge request to get the vulkan-layers headers put into the correct place

https://github.com/gentoo/gentoo/pull/11166

The next issue seems to be the .so gets installed into:

/usr/share/vulkan/explicit_layer.d/libVkLayer_MESA_overlay.so

In gentoo the .so files get installed into /usr/lib and /usr/lib64 with only the json files being installed into /usr/share/vulkan/explicit_layer.d/

This allows both 32bit and 64bit to coexist
Comment 11 Shmerl 2019-02-26 20:58:04 UTC
(In reply to Mike Lothian from comment #10)
> The next issue seems to be the .so gets installed into:
> 
> /usr/share/vulkan/explicit_layer.d/libVkLayer_MESA_overlay.so
> 
> In gentoo the .so files get installed into /usr/lib and /usr/lib64 with only
> the json files being installed into /usr/share/vulkan/explicit_layer.d/
> 
> This allows both 32bit and 64bit to coexist

Yes, looks like it's not supporting multilib case in the current Meson configuration. JSON should probably include arch and .so should be placed accordingly.

Can you please open a separate bug for it though, since it's not related to the issue in the current bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.