--- Vulkan-Loader-1.2.158.orig/loader/CMakeLists.txt
+++ Vulkan-Loader-1.2.158/loader/CMakeLists.txt
@@ -70,6 +70,7 @@
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
 
 if(WIN32)
+    if(MSVC)
     # Use static MSVCRT libraries
     foreach(configuration
             in
@@ -89,6 +90,7 @@
                            "${${configuration}}")
         endif()
     endforeach()
+    endif()
 
     if(ENABLE_WIN10_ONECORE)
         # Note: When linking your app or driver to OneCore.lib, be sure to remove any links to non-umbrella libs (such as
@@ -137,7 +139,7 @@
 set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} the stack frame for certain calls. If the compiler does not do this, then unknown device")
 set(ASM_FAILURE_MSG "${ASM_FAILURE_MSG} extensions will suffer from a corrupted stack.")
 if(WIN32)
-    if(MINGW)
+    if(NOT MINGW)
         find_program(JWASM_FOUND jwasm)
         if (JWASM_FOUND)
             set(CMAKE_ASM_MASM_COMPILER ${JWASM_FOUND})
@@ -155,7 +157,7 @@
     if (USE_MASM)
       enable_language(ASM_MASM)
     endif ()
-    if(CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND)
+    if(MSVC AND CMAKE_ASM_MASM_COMPILER_WORKS OR JWASM_FOUND)
         if(MINGW)
             set(CMAKE_ASM_MASM_FLAGS ${CMAKE_ASM_MASM_FLAGS} ${JWASM_FLAGS})
         elseif(NOT CMAKE_CL_64 AND NOT JWASM_FOUND)
@@ -169,12 +171,14 @@
         set_target_properties(loader_asm_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})
         add_library(loader-unknown-chain OBJECT unknown_ext_chain_masm.asm)
         add_dependencies(loader-unknown-chain loader_asm_gen_files)
+        set_target_properties(loader-unknown-chain PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL")
     else()
         message(WARNING "Could not find working MASM assebler\n${ASM_FAILURE_MSG}")
         add_custom_target(loader_asm_gen_files)
         add_library(loader-unknown-chain OBJECT unknown_ext_chain.c)
         target_compile_options(loader-unknown-chain PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
         target_compile_options(loader-unknown-chain PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
+        set_target_properties(loader-unknown-chain PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL")
     endif()
 elseif(APPLE)
     # For MacOS, use the C code and force the compiler's tail-call optimization instead of using assembly code.
@@ -207,12 +211,14 @@
 
 if(WIN32)
     add_library(loader-norm OBJECT ${NORMAL_LOADER_SRCS} dirent_on_windows.c)
+    set_target_properties(loader-norm PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL")
     target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>")
     target_compile_options(loader-norm PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
     target_include_directories(loader-norm PRIVATE "$<TARGET_PROPERTY:Vulkan::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
 
     add_library(loader-opt OBJECT ${OPT_LOADER_SRCS})
     add_dependencies(loader-opt loader_asm_gen_files)
+    set_target_properties(loader-opt PROPERTIES DEFINE_SYMBOL "VK_BUILDING_DLL")
     target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>")
     target_compile_options(loader-opt PUBLIC ${MSVC_LOADER_COMPILE_OPTIONS})
     target_include_directories(loader-opt PRIVATE "$<TARGET_PROPERTY:Vulkan::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
@@ -224,6 +230,7 @@
                 $<TARGET_OBJECTS:loader-unknown-chain>
                 ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-1.def
                 ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
+    if(MSVC)
     set_target_properties(vulkan
                           PROPERTIES LINK_FLAGS_DEBUG
                                      "/ignore:4098"
@@ -231,9 +238,16 @@
                                      vulkan-1
                                      PREFIX
                                      "")
+    else()
+    set_target_properties(vulkan
+                          PROPERTIES
+                          LIBRARY_OUTPUT_NAME vulkan
+                          RUNTIME_OUTPUT_NAME vulkan-1
+                          ARCHIVE_OUTPUT_NAME vulkan)
+    endif()
     target_link_libraries(vulkan Vulkan::Headers)
 
-    if(ENABLE_WIN10_ONECORE)
+    if(ENABLE_WIN10_ONECORE AND MSVC)
         target_link_libraries(vulkan OneCoreUAP.lib LIBCMT.LIB LIBCMTD.LIB LIBVCRUNTIME.LIB LIBUCRT.LIB)
         set_target_properties(vulkan PROPERTIES LINK_FLAGS "/NODEFAULTLIB")
     else()
--- Vulkan-Loader-1.2.158.orig/loader/loader.h
+++ Vulkan-Loader-1.2.158/loader/loader.h
@@ -38,7 +38,13 @@
 #include "vk_layer_dispatch_table.h"
 #include "vk_loader_extensions.h"
 
-#if defined(__GNUC__) && __GNUC__ >= 4
+#if defined(_WIN32)
+#  if defined (VK_BUILDING_DLL)
+#    define LOADER_EXPORT __declspec(dllexport)
+#  else
+#    define LOADER_EXPORT
+#  endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
 #define LOADER_EXPORT __attribute__((visibility("default")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
 #define LOADER_EXPORT __attribute__((visibility("default")))
--- Vulkan-Loader-1.2.158.orig/loader/vulkan-1.def
+++ Vulkan-Loader-1.2.158/loader/vulkan-1.def
@@ -21,7 +21,7 @@
 ;
 ;;;;  End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-LIBRARY vulkan-1.dll
+LIBRARY libvulkan-1.dll
 EXPORTS
    vkCreateInstance
    vkDestroyInstance
--- Vulkan-Loader-1.2.158.orig/tests/layers/vk_format_utils.h
+++ Vulkan-Loader-1.2.158/tests/layers/vk_format_utils.h
@@ -25,7 +25,13 @@
 #include "vulkan/vulkan.h"
 
 #if !defined(VK_LAYER_EXPORT)
-#if defined(__GNUC__) && __GNUC__ >= 4
+#if defined(_WIN32)
+#  if defined (VK_BUILDING_DLL)
+#    define VK_LAYER_EXPORT __declspec(dllexport)
+#  else
+#    define VK_LAYER_EXPORT
+#  endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
