Frogging-Family / wine-tkg-git

The wine-tkg build systems, to create custom Wine and Proton builds
888 stars 159 forks source link

Setting _steamvr_support="false" breaks steam runtime build #584

Open itspngu opened 2 years ago

itspngu commented 2 years ago

Sounded like an optional feature to me so I disabled it, but there's a patch failing somewhere once you do that. Left enabled, everything builds fine - not sure if this needs fixing or I'm just dumb, leaving it here just in case.

Shortened build log ```shell_session $ ./proton-tkg.sh [...] patching file steam_helper/steam.cpp Hunk #1 succeeded at 61 (offset 9 lines). Hunk #2 succeeded at 1343 with fuzz 2 (offset 167 lines). patching file steam_helper/steam.cpp Hunk #1 succeeded at 570 with fuzz 2 (offset 11 lines). Hunk #2 succeeded at 608 (offset 4 lines). patching file steam_helper/steam.cpp Hunk #1 succeeded at 39 (offset 3 lines). Hunk #2 succeeded at 52 with fuzz 1 (offset 3 lines). Hunk #3 FAILED at 419. Hunk #4 FAILED at 1008. Hunk #5 succeeded at 1331 with fuzz 1 (offset 308 lines). Hunk #6 succeeded at 1339 (offset 307 lines). 2 out of 6 hunks FAILED -- saving rejects to file steam_helper/steam.cpp.rej Winemaker 0.8.4 Copyright 2000-2004 François Gouget for CodeWeavers Copyright 2004 Dimitrie O. Paun Copyright 2009-2012 André Hentschel Scanning the source directories... Generating project files... . make: Entering directory '/home/pngu/git/tkg/wine-tkg-git/proton-tkg/external-resources/Proton/build/steam.win32' wineg++ -m32 -std=c++17 -c -Wno-attributes -O2 -g -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/proton_dist_tmp/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/lsteamclient/steamworks_sdk_142/ -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/openvr/headers/ -o jsoncpp.o jsoncpp.cpp wineg++ -m32 -std=c++17 -c -Wno-attributes -O2 -g -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/proton_dist_tmp/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/lsteamclient/steamworks_sdk_142/ -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/openvr/headers/ -o steam.o steam.cpp steam.cpp: In function ‘void* load_vrclient()’: steam.cpp:444:17: error: ‘PATH_MAX’ was not declared in this scope; did you mean ‘PDAT_MAX’? 444 | WCHAR pathW[PATH_MAX]; | ^~~~~~~~ | PDAT_MAX steam.cpp:455:55: error: ‘pathW’ was not declared in this scope; did you mean ‘pathU’? 455 | if(!GetEnvironmentVariableW(L"PROTON_VR_RUNTIME", pathW, ARRAY_SIZE(pathW))) | ^~~~~ | pathU steam.cpp:461:44: error: ‘pathW’ was not declared in this scope; did you mean ‘pathU’? 461 | sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL); [...] steam.cpp:755:9: error: ‘pvkDestroyInstance’ was not declared in this scope; did you mean ‘pvkCreateInstance’? 755 | pvkDestroyInstance(vk_instance, NULL); | ^~~~~~~~~~~~~~~~~~ | pvkCreateInstance steam.cpp:768:5: error: ‘dlclose’ was not declared in this scope; did you mean ‘_lclose’? 768 | dlclose(lib_vrclient); | ^~~~~~~ | _lclose winegcc: /usr/bin/ccache failed make: *** [Makefile:88: steam.o] Error 2 make: Leaving directory '/home/pngu/git/tkg/wine-tkg-git/proton-tkg/external-resources/Proton/build/steam.win32' Winemaker 0.8.4 Copyright 2000-2004 François Gouget for CodeWeavers Copyright 2004 Dimitrie O. Paun Copyright 2009-2012 André Hentschel Scanning the source directories... Generating project files... . make: Entering directory '/home/pngu/git/tkg/wine-tkg-git/proton-tkg/external-resources/Proton/build/steam.win64' wineg++ -m64 -std=c++17 -c -Wno-attributes -O2 -g -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/proton_dist_tmp/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/lsteamclient/steamworks_sdk_142/ -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/openvr/headers/ -o jsoncpp.o jsoncpp.cpp wineg++ -m64 -std=c++17 -c -Wno-attributes -O2 -g -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/proton_dist_tmp/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/../wine-tkg-git/src/wine-mirror-git/include/wine -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/lsteamclient/steamworks_sdk_142/ -I/home/pngu/git/tkg/wine-tkg-git/proton-tkg/Proton/openvr/headers/ -o steam.o steam.cpp steam.cpp: In function ‘void* load_vrclient()’: steam.cpp:444:17: error: ‘PATH_MAX’ was not declared in this scope; did you mean ‘PDAT_MAX’? 444 | WCHAR pathW[PATH_MAX]; | ^~~~~~~~ | PDAT_MAX steam.cpp:455:55: error: ‘pathW’ was not declared in this scope; did you mean ‘pathU’? 455 | if(!GetEnvironmentVariableW(L"PROTON_VR_RUNTIME", pathW, ARRAY_SIZE(pathW))) | ^~~~~ | pathU steam.cpp:461:44: error: ‘pathW’ was not declared in this scope; did you mean ‘pathU’? 461 | sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL); [...] steam.cpp:755:9: error: ‘pvkDestroyInstance’ was not declared in this scope; did you mean ‘pvkCreateInstance’? 755 | pvkDestroyInstance(vk_instance, NULL); | ^~~~~~~~~~~~~~~~~~ | pvkCreateInstance steam.cpp:768:5: error: ‘dlclose’ was not declared in this scope; did you mean ‘_lclose’? 768 | dlclose(lib_vrclient); | ^~~~~~~ | _lclose winegcc: /usr/bin/ccache failed make: *** [Makefile:89: steam.o] Error 2 make: Leaving directory '/home/pngu/git/tkg/wine-tkg-git/proton-tkg/external-resources/Proton/build/steam.win64' 'Proton/build/steam.win32/steam.exe.fake' -> 'proton_dist_tmp/lib/wine/i386-windows/steam.exe' 'Proton/build/steam.win64/steam.exe.fake' -> 'proton_dist_tmp/lib64/wine/x86_64-windows/steam.exe' cp: cannot stat 'Proton/build/steam.win32/steam.exe.so': No such file or directory ```
steam.cpp.rej ```diff --- steam_helper/steam.cpp +++ steam_helper/steam.cpp @@ -419,349 +410,6 @@ static void setup_vrpaths(void) } } -static BOOL set_vr_status(HKEY key, DWORD value) -{ - LSTATUS status; - - if ((status = RegSetValueExA(key, "state", 0, REG_DWORD, (BYTE *)&value, sizeof(value)))) - { - WINE_ERR("Could not set state value, status %#x.\n", status); - return FALSE; - } - return TRUE; -} - -void* load_vrclient(void) -{ - WCHAR pathW[PATH_MAX]; - char *pathU; - DWORD sz; - -#ifdef _WIN64 - static const char append_path[] = "/bin/linux64/vrclient.so"; -#else - static const char append_path[] = "/bin/vrclient.so"; -#endif - - /* PROTON_VR_RUNTIME is provided by the proton setup script */ - if(!GetEnvironmentVariableW(L"PROTON_VR_RUNTIME", pathW, ARRAY_SIZE(pathW))) - { - WINE_TRACE("Linux OpenVR runtime is not available\n"); - return 0; - } - - sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, NULL, 0, NULL, NULL); - if(!sz) - { - WINE_ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW)); - return NULL; - } - - pathU = (char *)HeapAlloc(GetProcessHeap(), 0, sz + sizeof(append_path)); - - sz = WideCharToMultiByte(CP_UNIXCP, 0, pathW, -1, pathU, sz, NULL, NULL); - if(!sz) - { - WINE_ERR("Can't convert path to unixcp! %s\n", wine_dbgstr_w(pathW)); - return NULL; - } - - strcat(pathU, append_path); - - WINE_TRACE("got openvr runtime path: %s\n", pathU); - - return dlopen(pathU, RTLD_NOW); -} - -static char *strdupA(const char *s) -{ - size_t l = strlen(s) + 1; - char *r = (char *)heap_alloc(l); - memcpy(r, s, l); - return r; -} - -static void parse_extensions(const char *in, uint32_t *out_count, - char ***out_strs) -{ - char *iter, *start; - char **list, *str = strdupA(in); - uint32_t extension_count = 0, o = 0; - - iter = str; - while(*iter){ - if(*iter++ == ' ') - extension_count++; - } - /* count the one ending in NUL */ - if(iter != str) - extension_count++; - if(!extension_count){ - *out_count = 0; - *out_strs = NULL; - return; - } - - list = (char **)heap_alloc(extension_count * sizeof(*list)); - - start = iter = str; - do{ - if(*iter == ' '){ - *iter = 0; - list[o++] = start; - WINE_TRACE("added %s to list\n", list[o-1]); - iter++; - start = iter; - }else if(*iter == 0){ - list[o++] = start; - WINE_TRACE("added %s to list\n", list[o-1]); - break; - }else{ - iter++; - } - }while(1); - - *out_count = extension_count; - *out_strs = list; -} - -extern "C" -{ - VkPhysicalDevice WINAPI __wine_get_native_VkPhysicalDevice(VkPhysicalDevice phys_dev); -}; - -static DWORD WINAPI initialize_vr_data(void *arg) -{ - vr::IVRClientCore* (*vrclient_VRClientCoreFactory)(const char *name, int *return_code); - uint32_t instance_extensions_count, device_count; - VkPhysicalDevice *phys_devices = NULL; - VkPhysicalDeviceProperties prop = {}; - VkInstanceCreateInfo inst_info = {}; - char **instance_extensions = NULL; - VkApplicationInfo app_info = {}; - char *buffer = NULL, *new_buffer; - vr::IVRClientCore* client_core; - vr::IVRCompositor* compositor; - VkInstance vk_instance = NULL; - BOOL vr_initialized = FALSE; - HKEY vr_key = (HKEY)arg; - vr::EVRInitError error; - HMODULE hvulkan = NULL; - DWORD vr_status = ~0u; - const char *env_str; - unsigned int app_id; - unsigned int length; - void *lib_vrclient; - int return_code; - LSTATUS status; - unsigned int i; - VkResult res; - - WINE_TRACE("Starting VR info initialization.\n"); - - if (!(lib_vrclient = load_vrclient())) - { - WINE_ERR("Could not load libopenvr_api.so.\n"); - set_vr_status(vr_key, ~0u); - RegCloseKey(vr_key); - return 0; - } - - if (!(vrclient_VRClientCoreFactory = reinterpret_cast - (dlsym(lib_vrclient, "VRClientCoreFactory")))) - { - WINE_ERR("Could not find function %s.\n", vrclient_VRClientCoreFactory); - goto done; - } - if (!(client_core = vrclient_VRClientCoreFactory(vr::IVRClientCore_Version, &return_code))) - { - WINE_ERR("Could not get IVRClientCore, error %d.\n", return_code); - } - - /* Without overriding the app_key vrclient waits 2 seconds for a valid appkey before returning. */ - error = client_core->Init(vr::VRApplication_Background, NULL); - if (error != vr::VRInitError_None) - { - if (error == vr::VRInitError_Init_NoServerForBackgroundApp) - WINE_TRACE("VR server is not available.\n"); - else - WINE_ERR("VR init failed, error %u.\n", error); - goto done; - } - vr_initialized = TRUE; - - compositor = reinterpret_cast(client_core->GetGenericInterface(vr::IVRCompositor_Version, &error)); - if (!compositor) - { - WINE_ERR("Could not get compositor, error %u.\n", error); - goto done; - } - - length = compositor->GetVulkanInstanceExtensionsRequired(nullptr, 0); - if (!(buffer = (char *)heap_alloc(length))) - { - WINE_ERR("No memory.\n"); - goto done; - } - *buffer = 0; - compositor->GetVulkanInstanceExtensionsRequired(buffer, length); - WINE_TRACE("Instance extensions %s.\n", buffer); - - if ((status = RegSetValueExA(vr_key, "openvr_vulkan_instance_extensions", 0, REG_SZ, (BYTE *)buffer, length))) - { - WINE_ERR("Could not set openvr_vulkan_instance_extensions value, status %#x.\n", status); - return FALSE; - } - - if (!(hvulkan = LoadLibraryA("winevulkan.dll"))) - { - WINE_ERR("Could not load winevulkan.\n"); - goto done; - } - -#define USE_VULKAN_PROC(name) decltype(name) *p##name;\ - if (!(p##name = reinterpret_cast(GetProcAddress(hvulkan, "wine_"#name)))\ - && !(p##name = reinterpret_cast(GetProcAddress(hvulkan, #name))))\ - {\ - WINE_ERR("Could not find function %s.\n", #name);\ - goto done;\ - } - USE_VULKAN_PROC(vkCreateInstance) - USE_VULKAN_PROC(vkDestroyInstance) - USE_VULKAN_PROC(vkEnumeratePhysicalDevices) - USE_VULKAN_PROC(vkGetPhysicalDeviceProperties) - USE_VULKAN_PROC(__wine_get_native_VkPhysicalDevice) -#undef USE_OPENVR_PROC - - parse_extensions(buffer, &instance_extensions_count, &instance_extensions); - - app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; - app_info.pApplicationName = "proton_vrhelper"; - app_info.applicationVersion = 1; - app_info.pEngineName = "proton_vrhelper"; - app_info.engineVersion = 1; - app_info.apiVersion = VK_MAKE_VERSION(1, 1, 0); - - inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - inst_info.pApplicationInfo = &app_info; - inst_info.enabledExtensionCount = instance_extensions_count; - inst_info.ppEnabledExtensionNames = instance_extensions; - - if ((res = pvkCreateInstance(&inst_info, NULL, &vk_instance)) != VK_SUCCESS) - { - WINE_ERR("Could not create VK instance, res %d.\n", res); - goto done; - } - - if ((res = pvkEnumeratePhysicalDevices(vk_instance, &device_count, NULL)) != VK_SUCCESS) - { - WINE_ERR("Could not enumerate physical devices, res %d.\n", res); - goto done; - } - if (!(phys_devices = (VkPhysicalDevice *)heap_alloc(device_count * sizeof(*phys_devices)))) - { - WINE_ERR("No memory.\n"); - goto done; - } - if ((res = pvkEnumeratePhysicalDevices(vk_instance, &device_count, phys_devices)) != VK_SUCCESS) - { - WINE_ERR("Could not enumerate physical devices, res %d.\n", res); - goto done; - } - - for (i = 0; i < device_count; ++i) - { - char name[256]; - LUID luid; - - pvkGetPhysicalDeviceProperties(phys_devices[i], &prop); - if (prop.apiVersion < VK_MAKE_VERSION(1, 1, 0)) - { - WINE_TRACE("Skipping Vulkan 1.0 adapter %s.\n", prop.deviceName); - continue; - } - - length = compositor->GetVulkanDeviceExtensionsRequired(p__wine_get_native_VkPhysicalDevice(phys_devices[i]), nullptr, 0); - if (!(new_buffer = (char *)heap_realloc(buffer, length))) - { - WINE_ERR("No memory.\n"); - goto done; - } - buffer = new_buffer; - compositor->GetVulkanDeviceExtensionsRequired(p__wine_get_native_VkPhysicalDevice(phys_devices[i]), buffer, length); - sprintf(name, "PCIID:%04x:%04x", prop.vendorID, prop.deviceID); - WINE_TRACE("%s: %s.\n", name, buffer); - - if ((status = RegSetValueExA(vr_key, name, 0, REG_SZ, (BYTE *)buffer, length))) - { - WINE_ERR("Could not set %s value, status %#x.\n", name, status); - return FALSE; - } - } - - vr_status = 1; - -done: - set_vr_status(vr_key, vr_status); - - heap_free(phys_devices); - - if (vk_instance) - pvkDestroyInstance(vk_instance, NULL); - - if (instance_extensions) - { - heap_free(instance_extensions[0]); - heap_free(instance_extensions); - } - if (hvulkan) - FreeLibrary(hvulkan); - heap_free(buffer); - if (vr_initialized) - client_core->Cleanup(); - WINE_TRACE("Completed VR info initialization.\n"); - dlclose(lib_vrclient); - RegCloseKey(vr_key); - return 0; -} - -static void setup_vr_registry(void) -{ - LSTATUS status; - HANDLE thread; - HKEY vr_key; - DWORD disp; - - if ((status = RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\VR", 0, NULL, REG_OPTION_VOLATILE, - KEY_ALL_ACCESS, NULL, &vr_key, &disp))) - { - WINE_ERR("Could not create key, status %#x.\n", status); - return; - } - if (disp != REG_CREATED_NEW_KEY) - { - WINE_ERR("VR key already exists, disp %#x.\n", disp); - RegCloseKey(vr_key); - return; - } - - if (!set_vr_status(vr_key, 0)) - { - RegCloseKey(vr_key); - return; - } - - if (!(thread = CreateThread(NULL, 0, initialize_vr_data, (void *)vr_key, 0, NULL))) - { - WINE_ERR("Could not create thread, error %u.\n", GetLastError()); - RegCloseKey(vr_key); - return; - } - CloseHandle(thread); - - WINE_TRACE("Queued VR info initialization.\n"); -} - static WCHAR *strchrW(WCHAR *h, WCHAR n) { do @@ -1008,7 +649,6 @@ int main(int argc, char *argv[]) { HANDLE wait_handle = INVALID_HANDLE_VALUE; HANDLE event = INVALID_HANDLE_VALUE; - BOOL game_process = FALSE; WINE_TRACE("\n"); ```
System info ```shell_session $ inxi CPU: 16-Core (2-Die) AMD Ryzen 9 3950X (-MT MCP MCM-) speed/min/max: 2199/2200/3500 MHz Kernel: 5.14.16-301.fc35.x86_64 x86_64 Up: 3h 6m Mem: 3929.2/32036.9 MiB (12.3%) Storage: 1.86 TiB (43.8% used) Procs: 489 Shell: Bash inxi: 3.3.06 $ gcc -v Using built-in specs. COLLECT_GCC=./git/tkg/mostlyportable-gcc/gcc-mostlyportable-11.2.1-releases-gcc.11.2.0.r409.g32584d02527/bin/gcc COLLECT_LTO_WRAPPER=/home/pngu/git/tkg/mostlyportable-gcc/gcc-mostlyportable-11.2.1-releases-gcc.11.2.0.r409.g32584d02527/bin/../libexec/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-linux-gnu Configured with: /home/pngu/git/tkg/mostlyportable-gcc/build/gcc/configure --with-pkgversion=TkG-mostlyportable --disable-bootstrap --enable-languages=c,c++,lto --with-gcc-major-version-only --enable-linker-build-id --disable-libstdcxx-pch --without-included-gettext --enable-libgomp --enable-lto --enable-threads=posix --enable-tls --enable-nls --enable-clocale=gnu --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-target-system-zlib=auto --with-system-zlib --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --enable-multilib --disable-werror --enable-checking=release --with-fpmath=sse --prefix=/tmp/mostlyportable-gcc --with-tune=generic --without-cuda-driver --with-isl=/tmp/mostlyportable-gcc --with-gmp=/tmp/mostlyportable-gcc --with-mpfr=/tmp/mostlyportable-gcc --with-mpc=/tmp/mostlyportable-gcc --enable-offload-targets=nvptx-none --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.1 20211106 (TkG-mostlyportable) $ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=./git/tkg/mostlyportable-gcc/mingw-mostlyportable-11.2.1-releases-gcc.11.2.0.r409.g32584d02527/bin/x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/home/pngu/git/tkg/mostlyportable-gcc/mingw-mostlyportable-11.2.1-releases-gcc.11.2.0.r409.g32584d02527/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/lto-wrapper Target: x86_64-w64-mingw32 Configured with: /home/pngu/git/tkg/mostlyportable-gcc/build/gcc/configure --with-pkgversion=TkG-mostlyportable --target=x86_64-w64-mingw32 --libexecdir=/tmp/mostlyportable-mingw/lib --enable-languages=c,lto,c++,objc,obj-c++ --disable-shared --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=yes --with-system-zlib --enable-cloog-backend=isl --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --with-isl=/tmp/mostlyportable-mingw --with-gmp=/tmp/mostlyportable-mingw --with-mpfr=/tmp/mostlyportable-mingw --with-mpc=/tmp/mostlyportable-mingw --prefix=/tmp/mostlyportable-mingw --disable-sjlj-exceptions --with-dwarf2 --enable-threads=posix Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.1 20211106 (TkG-mostlyportable) ```
Tk-Glitch commented 2 years ago

It used to be totally optional and disabled by default (and even forcefully disabled for a while). Looks like we'll need to update the patches we have to get rid of vr dependency code.. Or enforce the option as enabled going forward. I'll take the always enabled route for now until I have time to properly review the changes that broke our patches. Thanks!

Tk-Glitch commented 2 years ago

https://github.com/Frogging-Family/wine-tkg-git/commit/7d572b9e9210e0685eeb8702a4d1035b2d693002