Don't export Vulkan functions when building the loader statically
authorGeoff Lang <geofflang@chromium.org>
Tue, 16 May 2023 15:59:30 +0000 (11:59 -0400)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 16 May 2023 22:37:41 +0000 (16:37 -0600)
If the loader is linked statically, there is no need to export all
vulkan functions from the linking application. This issue showed up
in ANGLE which would export all GLES and Vulkan functions on Mac.

BUILD.gn
loader/vk_loader_platform.h

index 5790e753ae3ff5aee6983b51fc5f1e5f30f684b2..2f0b2a6083a02b4c7b6da0424e5ca6690b8236c5 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -62,6 +62,9 @@ config("vulkan_internal_config") {
       "FALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"",
     ]
   }
+  if (!vulkan_loader_shared) {
+    defines += [ "BUILD_STATIC_LOADER" ]
+  }
 }
 
 # Vulkan loader
index c68f918001ab835f18473d607d6b7856b8a5894b..2e0c98edd016ad745c85175643e6cd77745fb8ca 100644 (file)
@@ -76,7 +76,9 @@
 
 #include "stack_allocation.h"
 
-#if defined(__GNUC__) && __GNUC__ >= 4
+#if defined(BUILD_STATIC_LOADER)
+#define LOADER_EXPORT
+#elif defined(__GNUC__) && __GNUC__ >= 4
 #define LOADER_EXPORT __attribute__((visibility("default")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
 #define LOADER_EXPORT __attribute__((visibility("default")))