From e99129d72f5a945ecc9a3a823259bedbb1bb8e3d Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Sat, 13 Apr 2024 22:37:21 +0300 Subject: [PATCH] several fixes (#112) * updated fmt * submodules updated * fixed _TIMESPEC_DEFINED for winpthreads under windows * fixed sdl3 under qt * virtual_memory: Ensure mapped addresses stay inside the user area * Fixes LLE Libc crashing on linux --------- Co-authored-by: GPUCode --- .gitmodules | 8 +++----- CMakeLists.txt | 17 ++++++++--------- externals/CMakeLists.txt | 5 +++-- externals/cryptopp-cmake | 2 +- externals/fmt | 1 + externals/sdl3 | 2 +- externals/zlib-ng | 2 +- src/core/hle/libraries/libc/libc_cxa.h | 1 - .../hle/libraries/libkernel/thread_management.h | 1 - src/core/virtual_memory.cpp | 3 ++- third-party/CMakeLists.txt | 3 --- third-party/fmt | 1 - 12 files changed, 20 insertions(+), 26 deletions(-) create mode 160000 externals/fmt delete mode 160000 third-party/fmt diff --git a/.gitmodules b/.gitmodules index 08481f31..51f34f95 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "third-party/fmt"] - path = third-party/fmt - url = https://github.com/fmtlib/fmt.git - shallow = true [submodule "third-party/magic_enum"] path = third-party/magic_enum url = https://github.com/Neargye/magic_enum.git @@ -47,4 +43,6 @@ [submodule "externals/sdl3"] path = externals/sdl3 url = https://github.com/shadps4-emu/ext-SDL.git - +[submodule "externals/fmt"] + path = externals/fmt + url = https://github.com/shadps4-emu/ext-fmt.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ebc4f8..f94e3ff7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,12 +14,6 @@ project(shadps4) option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF) -if(ENABLE_QT_GUI) - find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) - qt_standard_project_setup() - set(CMAKE_AUTORCC ON) -endif() - # This function should be passed a list of all files in a target. It will automatically generate # file groups following the directory hierarchy, so that the layout of the files in IDEs matches the # one in the filesystem. @@ -93,6 +87,12 @@ add_subdirectory(externals) add_subdirectory(third-party) include_directories(src) +if(ENABLE_QT_GUI) + find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) + qt_standard_project_setup() + set(CMAKE_AUTORCC ON) +endif() + set(AUDIO_CORE src/audio_core/sdl_audio.cpp src/audio_core/sdl_audio.h ) @@ -331,7 +331,7 @@ endif() create_target_directory_groups(shadps4) -target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11) +target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 SDL3-shared) target_link_libraries(shadps4 PRIVATE discord-rpc vulkan-1 xxhash Zydis) if(NOT ENABLE_QT_GUI) @@ -352,6 +352,7 @@ if (WIN32) target_link_libraries(shadps4 PRIVATE mincore winpthread clang_rt.builtins-x86_64.lib) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) + add_definitions(-D_TIMESPEC_DEFINED) #needed for conflicts with time.h of windows.h endif() if(WIN32) @@ -373,12 +374,10 @@ add_custom_command(TARGET shadps4 POST_BUILD $ ) -if(NOT ENABLE_QT_GUI) add_custom_command(TARGET shadps4 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) -endif() if (WIN32) add_custom_command(TARGET shadps4 POST_BUILD diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 3e4e201f..2eec1998 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -6,6 +6,9 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) endif() +# fmtlib +add_subdirectory(fmt EXCLUDE_FROM_ALL) + # Discord-RPC set(BUILD_EXAMPLES OFF CACHE BOOL "") add_subdirectory(discord-rpc EXCLUDE_FROM_ALL) @@ -30,7 +33,5 @@ set(WITH_NEW_STRATEGIES ON) set(WITH_NATIVE_INSTRUCTIONS ON) add_subdirectory(zlib-ng) -if(NOT ENABLE_QT_GUI) # SDL3 add_subdirectory(sdl3 EXCLUDE_FROM_ALL) -endif() diff --git a/externals/cryptopp-cmake b/externals/cryptopp-cmake index a99c80c2..19cd13af 160000 --- a/externals/cryptopp-cmake +++ b/externals/cryptopp-cmake @@ -1 +1 @@ -Subproject commit a99c80c26686e44eddf0432140ae397f3efbd0b3 +Subproject commit 19cd13af5f7fa4904b174b81e98852283dbe8c1f diff --git a/externals/fmt b/externals/fmt new file mode 160000 index 00000000..aa52eb76 --- /dev/null +++ b/externals/fmt @@ -0,0 +1 @@ +Subproject commit aa52eb765dec0eb67fab4b035a4a05b82346c8f5 diff --git a/externals/sdl3 b/externals/sdl3 index c8a06601..cbb3c69c 160000 --- a/externals/sdl3 +++ b/externals/sdl3 @@ -1 +1 @@ -Subproject commit c8a066019b686351afc614a44a2111111c42d697 +Subproject commit cbb3c69cb0d771cdd221339aa1a064c55ec6e67d diff --git a/externals/zlib-ng b/externals/zlib-ng index af8169a7..3f35bfcc 160000 --- a/externals/zlib-ng +++ b/externals/zlib-ng @@ -1 +1 @@ -Subproject commit af8169a724bd607e4e8c7de2a705ab17206217d6 +Subproject commit 3f35bfccff2d1dacdfe9844712be1e042d028700 diff --git a/src/core/hle/libraries/libc/libc_cxa.h b/src/core/hle/libraries/libc/libc_cxa.h index 30d61a50..e33dd32f 100644 --- a/src/core/hle/libraries/libc/libc_cxa.h +++ b/src/core/hle/libraries/libc/libc_cxa.h @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#define _TIMESPEC_DEFINED #include #include "common/types.h" diff --git a/src/core/hle/libraries/libkernel/thread_management.h b/src/core/hle/libraries/libkernel/thread_management.h index 203ed872..83e1a58d 100644 --- a/src/core/hle/libraries/libkernel/thread_management.h +++ b/src/core/hle/libraries/libkernel/thread_management.h @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#define _TIMESPEC_DEFINED #include #include diff --git a/src/core/virtual_memory.cpp b/src/core/virtual_memory.cpp index 3c9c2e20..8907622a 100644 --- a/src/core/virtual_memory.cpp +++ b/src/core/virtual_memory.cpp @@ -170,7 +170,8 @@ u64 memory_alloc_aligned(u64 address, u64 size, MemoryMode mode, u64 alignment) } return ptr; #else - void* hint_address = reinterpret_cast(AlignUp(address, alignment)); + void* hint_address = address == 0 ? reinterpret_cast(USER_MIN) + : reinterpret_cast(AlignUp(address, alignment)); void* ptr = mmap(hint_address, size, convertMemoryMode(mode), MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(ptr != MAP_FAILED); return reinterpret_cast(ptr); diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 8acf2406..012b8bbc 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -6,9 +6,6 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) endif() -# fmtlib -add_subdirectory(fmt EXCLUDE_FROM_ALL) - # MagicEnum add_subdirectory(magic_enum EXCLUDE_FROM_ALL) diff --git a/third-party/fmt b/third-party/fmt deleted file mode 160000 index 8e42eef4..00000000 --- a/third-party/fmt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8e42eef4950feb5d2b76574a9cd2591dfaae2449