forked from myfreeer/mpv-build-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'myfreeer:main' into main
- Loading branch information
Showing
2 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
From dd2fb568b5750261692ed0c47504dac046d5b291 Mon Sep 17 00:00:00 2001 | ||
From 0881cebf665535babb73c5cf173eb0b5aea227a9 Mon Sep 17 00:00:00 2001 | ||
From: shinchiro <[email protected]> | ||
Date: Wed, 29 Nov 2023 17:38:59 +0800 | ||
Date: Tue, 24 Sep 2024 22:27:16 +0800 | ||
Subject: [PATCH] loader: cross-compile & static linking hacks | ||
|
||
--- | ||
loader/CMakeLists.txt | 24 ++++++------------------ | ||
loader/loader.h | 2 ++ | ||
loader/loader.c | 4 ++-- | ||
loader/loader.h | 4 +++- | ||
loader/loader.rc.in | 4 ++++ | ||
loader/loader_windows.c | 2 ++ | ||
loader/vk_loader_platform.h | 9 +++------ | ||
loader/vk_loader_platform.h | 11 ++++------- | ||
loader/vulkan_own.pc.in | 11 +++++++++++ | ||
6 files changed, 28 insertions(+), 24 deletions(-) | ||
7 files changed, 32 insertions(+), 28 deletions(-) | ||
create mode 100644 loader/vulkan_own.pc.in | ||
|
||
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt | ||
index 5a4caec28..da141adbf 100644 | ||
index 6296ebff1..7408a63b8 100644 | ||
--- a/loader/CMakeLists.txt | ||
+++ b/loader/CMakeLists.txt | ||
@@ -22,8 +22,9 @@ include(CheckIncludeFile) | ||
|
@@ -28,7 +29,7 @@ index 5a4caec28..da141adbf 100644 | |
|
||
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 | ||
@@ -311,7 +312,7 @@ if(UNKNOWN_FUNCTIONS_SUPPORTED) | ||
@@ -372,7 +373,7 @@ if(UNKNOWN_FUNCTIONS_SUPPORTED) | ||
list(APPEND NORMAL_LOADER_SRCS ${OPT_LOADER_SRCS}) | ||
endif() | ||
|
||
|
@@ -37,7 +38,7 @@ index 5a4caec28..da141adbf 100644 | |
# If BUILD_DLL_VERSIONINFO was set, use the loader.rc in the build dir, otherwise use the checked in file | ||
set(RC_FILE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc) | ||
if (NOT "$CACHE{BUILD_DLL_VERSIONINFO}" STREQUAL "") | ||
@@ -348,21 +349,8 @@ if(WIN32) | ||
@@ -412,21 +413,8 @@ if(WIN32) | ||
endif() | ||
|
||
else() | ||
|
@@ -61,7 +62,7 @@ index 5a4caec28..da141adbf 100644 | |
target_sources(vulkan PRIVATE ${NORMAL_LOADER_SRCS}) | ||
|
||
set_target_properties(vulkan PROPERTIES | ||
@@ -462,7 +450,7 @@ if (UNKNOWN_FUNCTIONS_SUPPORTED) | ||
@@ -526,7 +514,7 @@ if (UNKNOWN_FUNCTIONS_SUPPORTED) | ||
add_dependencies(vulkan loader_asm_gen_files) | ||
endif() | ||
|
||
|
@@ -70,8 +71,30 @@ index 5a4caec28..da141adbf 100644 | |
# TLDR: This feature only exists at the request of Google for Chromium. No other project should use this! | ||
message(NOTICE "Apple STATIC lib: it will be built but not installed, and vulkan.pc and VulkanLoaderConfig.cmake won't be generated!") | ||
return() | ||
diff --git a/loader/loader.c b/loader/loader.c | ||
index 82e5bca10..b3e98a7ff 100644 | ||
--- a/loader/loader.c | ||
+++ b/loader/loader.c | ||
@@ -1933,7 +1933,7 @@ out: | ||
return res; | ||
} | ||
|
||
-#if defined(_WIN32) | ||
+#if defined(LOADER_DYNAMIC_LIB) | ||
BOOL __stdcall loader_initialize(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) { | ||
(void)InitOnce; | ||
(void)Parameter; | ||
@@ -1971,7 +1971,7 @@ void loader_initialize(void) { | ||
#if defined(LOADER_USE_UNSAFE_FILE_SEARCH) | ||
loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: unsafe searching is enabled"); | ||
#endif | ||
-#if defined(_WIN32) | ||
+#if defined(LOADER_DYNAMIC_LIB) | ||
return TRUE; | ||
#endif | ||
} | ||
diff --git a/loader/loader.h b/loader/loader.h | ||
index 2bce18189..77def28bc 100644 | ||
index fcd95dd10..61c9515a1 100644 | ||
--- a/loader/loader.h | ||
+++ b/loader/loader.h | ||
@@ -33,7 +33,9 @@ | ||
|
@@ -84,6 +107,15 @@ index 2bce18189..77def28bc 100644 | |
|
||
static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { | ||
struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice; | ||
@@ -94,7 +96,7 @@ VkResult loader_validate_instance_extensions(struct loader_instance *inst, const | ||
const struct loader_envvar_all_filters *layer_filters, | ||
const VkInstanceCreateInfo *pCreateInfo); | ||
|
||
-#if defined(_WIN32) | ||
+#if defined(LOADER_DYNAMIC_LIB) | ||
BOOL __stdcall loader_initialize(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context); | ||
#else | ||
void loader_initialize(void); | ||
diff --git a/loader/loader.rc.in b/loader/loader.rc.in | ||
index 0dc4227da..e7fcea06f 100644 | ||
--- a/loader/loader.rc.in | ||
|
@@ -101,18 +133,18 @@ index 0dc4227da..e7fcea06f 100644 | |
// All set through CMake | ||
#define VER_FILE_VERSION ${LOADER_VER_FILE_VERSION} | ||
diff --git a/loader/loader_windows.c b/loader/loader_windows.c | ||
index 43ecf6672..37bc684cf 100644 | ||
index 7b6081333..f8f4551cd 100644 | ||
--- a/loader/loader_windows.c | ||
+++ b/loader/loader_windows.c | ||
@@ -97,6 +97,7 @@ void windows_initialization(void) { | ||
@@ -95,6 +95,7 @@ void windows_initialization(void) { | ||
#endif | ||
} | ||
|
||
+#if defined(LOADER_DYNAMIC_LIB) | ||
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { | ||
(void)hinst; | ||
switch (reason) { | ||
@@ -114,6 +115,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { | ||
@@ -116,6 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { | ||
} | ||
return TRUE; | ||
} | ||
|
@@ -121,17 +153,17 @@ index 43ecf6672..37bc684cf 100644 | |
bool windows_add_json_entry(const struct loader_instance *inst, | ||
char **reg_data, // list of JSON files | ||
diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h | ||
index a70ba71a8..4e42ba05b 100644 | ||
index 23908ae58..3f7137023 100644 | ||
--- a/loader/vk_loader_platform.h | ||
+++ b/loader/vk_loader_platform.h | ||
@@ -71,15 +71,12 @@ | ||
#include <io.h> | ||
#include <shlwapi.h> | ||
#include <direct.h> | ||
+#include <pthread.h> // for mingw | ||
#endif // defined(_WIN32) | ||
|
||
#include "stack_allocation.h" | ||
#endif // defined(_WIN32) | ||
|
||
-#if defined(APPLE_STATIC_LOADER) && !defined(__APPLE__) | ||
-#error "APPLE_STATIC_LOADER can only be defined on Apple platforms!" | ||
|
@@ -142,15 +174,24 @@ index a70ba71a8..4e42ba05b 100644 | |
#define LOADER_EXPORT | ||
#elif defined(__GNUC__) && __GNUC__ >= 4 | ||
#define LOADER_EXPORT __attribute__((visibility("default"))) | ||
@@ -233,7 +230,7 @@ static inline bool loader_platform_is_path(const char *path) { return strchr(pat | ||
// resources allocated by anything allocated by once init. This isn't a problem for static libraries, but it is for dynamic | ||
// ones. When building a DLL, we use DllMain() instead to allow properly cleaning up resources. | ||
@@ -241,7 +238,7 @@ static inline bool loader_platform_is_path(const char *path) { return strchr(pat | ||
// API call made, using InitOnceExecuteOnce, except for initialization primitives which must be done in DllMain. This is because | ||
// there is no way to clean up the resources allocated by anything allocated by once init. | ||
|
||
-#if defined(APPLE_STATIC_LOADER) | ||
+#if defined(BUILD_STATIC_LOADER) | ||
static inline void loader_platform_thread_once_fn(pthread_once_t *ctl, void (*func)(void)) { | ||
assert(func != NULL); | ||
assert(ctl != NULL); | ||
@@ -250,7 +247,7 @@ static inline void loader_platform_thread_once_fn(pthread_once_t *ctl, void (*fu | ||
#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) pthread_once_t var = PTHREAD_ONCE_INIT; | ||
#define LOADER_PLATFORM_THREAD_ONCE_EXTERN_DEFINITION(var) extern pthread_once_t var; | ||
#define LOADER_PLATFORM_THREAD_ONCE(ctl, func) loader_platform_thread_once_fn(ctl, func); | ||
-#elif defined(WIN32) | ||
+#elif defined(LOADER_DYNAMIC_LIB) | ||
static inline void loader_platform_thread_win32_once_fn(INIT_ONCE *ctl, PINIT_ONCE_FN func) { | ||
InitOnceExecuteOnce(ctl, func, NULL, NULL); | ||
} | ||
diff --git a/loader/vulkan_own.pc.in b/loader/vulkan_own.pc.in | ||
new file mode 100644 | ||
index 000000000..ed2f30bb2 | ||
|
@@ -169,5 +210,5 @@ index 000000000..ed2f30bb2 | |
+Libs.private: -lshlwapi -lcfgmgr32 | ||
+Cflags: -I${includedir} | ||
-- | ||
2.44.0 | ||
2.46.0 | ||
|