[virtmagma] add linux config for vulkan loader
This change enables the vulkan loader library to build using the linux
toolchain. This will be used for VM guest test binaries.
Test: ran vulkan_unit_tests_linux over linux guest serial
Change-Id: I4d973d3a9cfb0675975d931e22e3a93e915d8c92
diff --git a/loader/BUILD.gn b/loader/BUILD.gn
index aab9486..2a60e03 100644
--- a/loader/BUILD.gn
+++ b/loader/BUILD.gn
@@ -110,3 +110,52 @@
runtime_deps += [ "//zircon/public/lib/trace-engine:trace-engine_sdk" ]
runtime_deps += [ "//zircon/public/lib/async-default:async-default_sdk" ]
}
+
+# Loader config and definition for building with the linux toolchain.
+# This is intended for use with VM guest binaries. Guest binaries are
+# not required to use this loader; it is used here only to avoid
+# creating a duplicate instance of the vulkan loader repo.
+config("vulkan_linux_build_config") {
+ include_dirs = [
+ "../include",
+ "../build-fuchsia/generated/include",
+ ]
+ defines = [
+ "VK_USE_PLATFORM_XLIB_KHR=1",
+ ]
+}
+
+shared_library("loader_linux") {
+ output_name = "vulkan_linux"
+
+ public_configs = [
+ ":vulkan_linux_build_config"
+ ]
+
+ # Copied from ../CMakeLists.txt and ./loader_cmake_config.h.in
+ cflags_c = [
+ "-DSYSCONFDIR=\"/etc\"",
+ "-DFALLBACK_CONFIG_DIRS=\"/etc/xdg\"",
+ "-DFALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"",
+ "-DHAVE_SECURE_GETENV",
+ ]
+
+ defines = [ "VK_LOADER_DEBUG=\"$vk_loader_debug\"" ]
+
+ include_dirs = [
+ ".",
+ ]
+
+ sources = [
+ "cJSON.c",
+ "debug_utils.c",
+ "dev_ext_trampoline.c",
+ "extension_manual.c",
+ "loader.c",
+ "murmurhash.c",
+ "phys_dev_ext.c",
+ "trampoline.c",
+ "unknown_ext_chain.c",
+ "wsi.c",
+ ]
+}
diff --git a/loader/loader.c b/loader/loader.c
index 773be64..6dc4eae 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -3111,7 +3111,6 @@
const char *xdgdatadirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
if (xdgconfdirs == NULL || xdgconfdirs[0] == '\0') xdgconfdirs = FALLBACK_CONFIG_DIRS;
if (xdgdatadirs == NULL || xdgdatadirs[0] == '\0') xdgdatadirs = FALLBACK_DATA_DIRS;
- const size_t rel_size = strlen(relative_location);
// Leave space for trailing separators
loc_size += strlen(xdgconfdirs) + strlen(xdgdatadirs) + 2 * rel_size + 2;
for (const char *x = xdgconfdirs; *x; ++x)