Compare commits

...

4 commits

Author SHA1 Message Date
redpolline 423309c44a
Merge 4541685e33 into d4c0c499a4 2024-05-14 00:00:13 +03:00
Pedro Montes Alcalde d4c0c499a4
mem/threads: Include some missing header files (#3291) 2024-05-13 17:02:42 -03:00
Pedro Montes Alcalde 052abe8e83
external: Update tracy to 0.10.0 (#3280) 2024-05-13 14:30:43 -03:00
redpolline 4541685e33 Fix windows build.
Should fix Vita3K/Vita3K#3092.
2024-03-11 11:09:16 -04:00
6 changed files with 125 additions and 87 deletions

View file

@ -39,7 +39,7 @@ jobs:
C:\vcpkg\installed
C:\vcpkg\packages
C:\Users\runneradmin\AppData\Local\ccache
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static-md
extra_cmake_args: -DVITA3K_FORCE_SYSTEM_BOOST=TRUE -DBoost_ROOT="C:\vcpkg\installed\x64-windows-static-md" -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DCMAKE_POLICY_DEFAULT_CMP0144=NEW -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static-md
cmake_preset: windows-ninja
- os: macos-latest
version: zip

View file

@ -35,7 +35,6 @@ enable_testing()
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(lto_usage_mode ALWAYS RELEASE_ONLY NEVER)
set(USE_LTO RELEASE_ONLY CACHE STRING "Use interprocedural optimization/link time optimization")
set_property(CACHE USE_LTO PROPERTY STRINGS ${lto_usage_mode})
@ -67,46 +66,46 @@ macro(b2_build)
execute_process(
COMMAND ${BOOST_SOURCEDIR}/bootstrap.bat --with-toolset=${BOOST_TOOLSET}
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
execute_process(
COMMAND chmod +x ${BOOST_SOURCEDIR}/tools/build/src/engine/build.sh
COMMAND sh ${BOOST_SOURCEDIR}/bootstrap.sh
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
execute_process(
COMMAND chmod +x ${BOOST_SOURCEDIR}/tools/build/src/engine/build.sh
COMMAND sh ${BOOST_SOURCEDIR}/bootstrap.sh --with-toolset=${BOOST_TOOLSET}
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
endif()
endmacro(b2_build)
# Macro to compile Boost
macro(boost_compile)
list(TRANSFORM BOOST_MODULES_TO_FIND PREPEND --with- OUTPUT_VARIABLE b2_cmd_line_common)
set(b2_cmd_line_common ${b2} ${b2_cmd_line_common} -j${CPU_COUNT} --build-dir=${BOOST_INSTALLDIR} --stagedir=${BOOST_INSTALLDIR} cxxflags=${BOOST_CXX_FLAGS})
list(TRANSFORM BOOST_MODULES_TO_FIND PREPEND --with- OUTPUT_VARIABLE b2_cmd_line_common)
set(b2_cmd_line_common ${b2} ${b2_cmd_line_common} -j${CPU_COUNT} --build-dir=${BOOST_INSTALLDIR} --stagedir=${BOOST_INSTALLDIR} cxxflags=${BOOST_CXX_FLAGS})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
execute_process(
COMMAND ${b2_cmd_line_common} address-model=64 --architecture=x64 toolset=${BOOST_TOOLSET} stage
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
execute_process(
COMMAND ${b2_cmd_line_common} stage
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
execute_process(
COMMAND ${b2_cmd_line_common} --ignore-site-config toolset=${BOOST_TOOLSET} stage
WORKING_DIRECTORY ${BOOST_SOURCEDIR}
OUTPUT_QUIET
OUTPUT_QUIET
)
endif()
endmacro(boost_compile)
@ -119,91 +118,126 @@ set(BOOST_MODULES_TO_FIND filesystem system)
# If build process isn't set to forcefully use system Boost
macro(get_boost)
if(NOT VITA3K_FORCE_SYSTEM_BOOST)
# find_package(Boost ...) setting
set(Boost_USE_STATIC_LIBS ON)
# Windows (Specifically MSVC, but it technically applies to all builds regardless of compiler / OS...) doesn't handle
# symbol redefinitions gracefully.
#
# In the case of Boost, BoostConfig.cmake doesn't use CMake's generator expressions when defining it's link libraries,
# instead adding the found definitions to the project's link dependencies directly. With no way to perform library detection only.
# Worse, get_boost() and boost_compile() runs during configure so we don't have a build configuration yet, and therefore do not know what
# build of Boost (Release or Debug) to use at that point. This means that calling find_package(Boost ...) more than once can result
# in a project that has both the Debug and Release libraries added as dependencies. (Which will cause a link failure under MSVC.
# As the libraries are not fully ABI-compatible with each other.)
#
# TL;DR: Fix Boost by not calling find_package(Boost ...) if it's already been found once.
if (NOT VITA3K_Boost_FOUND)
if(NOT VITA3K_FORCE_SYSTEM_BOOST)
# find_package(Boost ...) setting
set(Boost_USE_STATIC_LIBS ON)
set(Boost_NO_WARN_NEW_VERSIONS 1)
set(Boost_NO_WARN_NEW_VERSIONS 1)
# First, try to find Boost without any hints (system Boost)
if(NOT VITA3K_FORCE_CUSTOM_BOOST)
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} QUIET)
endif()
# First, try to find Boost without any hints (system Boost)
if(NOT VITA3K_FORCE_CUSTOM_BOOST)
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} QUIET CONFIG)
else()
message(STATUS "VITA3K_FORCE_CUSTOM_BOOST is enabled, skipping check for system provided Boost distribution.")
endif()
# If system Boost hasn't been found, then enable hints to find custom Boost
if (NOT Boost_FOUND)
message(STATUS "A Boost distribution that meets the requirements needed for the project hasn't been found in your system. Falling back to custom Boost distribution...")
# If system Boost hasn't been found, then enable hints to find custom Boost
if (NOT Boost_FOUND)
message(STATUS "A Boost distribution that meets the requirements needed for the project hasn't been found in your system. Falling back to custom Boost distribution...")
# Set path hints for Boost search inside the repository folder and assist in compilation if needed
set(BOOST_SOURCEDIR "${CMAKE_SOURCE_DIR}/external/boost") # For internal use
set(BOOST_INSTALLDIR "${CMAKE_BINARY_DIR}/external/boost") # For internal use
set(BOOST_ROOT "${BOOST_SOURCEDIR}") # find_package(Boost ...) hint
set(BOOST_INCLUDEDIR "${BOOST_SOURCEDIR}") # find_package(Boost ...) hint
set(BOOST_LIBRARYDIR "${BOOST_INSTALLDIR}/libs") # find_package(Boost ...) hint
# Set path hints for Boost search inside the repository folder and assist in compilation if needed
set(BOOST_SOURCEDIR "${CMAKE_SOURCE_DIR}/external/boost") # For internal use
set(BOOST_INSTALLDIR "${CMAKE_BINARY_DIR}/external/boost") # For internal use
set(BOOSTROOT "${BOOST_SOURCEDIR}") # find_package(Boost ...) hint
set(BOOST_INCLUDEDIR "${BOOST_SOURCEDIR}") # find_package(Boost ...) hint
set(BOOST_LIBRARYDIR "${BOOST_INSTALLDIR}/libs") # find_package(Boost ...) hint
# Find Boost again to check for a existing compilation of the custom distribution
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} PATHS ${BOOST_INSTALLDIR} QUIET NO_DEFAULT_PATH)
# Find Boost again to check for a existing compilation of the custom distribution
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} PATHS ${BOOST_INSTALLDIR} QUIET CONFIG NO_DEFAULT_PATH)
# If no build of the custom distribution is found, compile it
if(NOT Boost_FOUND)
message(STATUS "No existing custom distribution of Boost has been found in ${BOOST_INSTALLDIR}. Proceeding to compile Boost...")
# If no build of the custom distribution is found, compile it
if(NOT Boost_FOUND)
message(STATUS "No existing custom distribution of Boost has been found in ${BOOST_INSTALLDIR}. Proceeding to compile Boost...")
# Set compilation toolset for b2 and Boost builds
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_GENERATOR_TOOLSET STREQUAL "ClangCL")
# Proper toolset should be "clang-win", but b2 has a bug that makes it spam Visual Studio instances if set
# Since Clang for Windows is ABI-compatible with MSVC, using MSVC is fine
set(BOOST_TOOLSET "msvc")
else()
message(WARNING "Boost compilation on Windows requires the use of a clang-cl compiler running inside a Visual Studio Developer CLI environment with a Windows C++ SDK available.")
set(BOOST_TOOLSET "msvc")
endif()
else()
set(BOOST_TOOLSET "msvc")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(BOOST_TOOLSET "clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(BOOST_TOOLSET "gcc")
endif()
endif()
# Set compilation toolset for b2 and Boost builds
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_GENERATOR_TOOLSET STREQUAL "ClangCL")
# Proper toolset should be "clang-win", but b2 has a bug that makes it spam Visual Studio instances if set
# Since Clang for Windows is ABI-compatible with MSVC, using MSVC is fine
set(BOOST_TOOLSET "msvc")
else()
message(WARNING "Boost compilation on Windows requires the use of a clang-cl compiler running inside a Visual Studio Developer CLI environment with a Windows C++ SDK available.")
set(BOOST_TOOLSET "msvc")
endif()
else()
set(BOOST_TOOLSET "msvc")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(BOOST_TOOLSET "clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(BOOST_TOOLSET "gcc")
endif()
endif()
# Determine b2 executable name depending on host system
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(b2_EXECUTABLE_NAME "b2.exe")
else()
set(b2_EXECUTABLE_NAME "b2")
endif()
# Determine b2 executable name depending on host system
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(b2_EXECUTABLE_NAME "b2.exe")
else()
set(b2_EXECUTABLE_NAME "b2")
endif()
# Find b2
find_program(b2 NAME ${b2_EXECUTABLE_NAME} PATHS ${BOOST_SOURCEDIR} NO_CACHE NO_DEFAULT_PATH)
# Find b2
find_program(b2 NAME ${b2_EXECUTABLE_NAME} PATHS ${BOOST_SOURCEDIR} NO_CACHE NO_DEFAULT_PATH)
# Compile b2 if it isn't found
if(b2 STREQUAL "b2-NOTFOUND")
message(STATUS "The b2 buildsystem executable hasn't been found in your system. Compiling b2...")
b2_build()
# Compile b2 if it isn't found
if(b2 STREQUAL "b2-NOTFOUND")
message(STATUS "The b2 buildsystem executable hasn't been found in your system. Compiling b2...")
b2_build()
# Find b2 again after compilation
find_program(b2 NAME ${b2_EXECUTABLE_NAME} PATHS ${BOOST_SOURCEDIR} NO_CACHE NO_DEFAULT_PATH REQUIRED)
endif()
# Find b2 again after compilation
find_program(b2 NAME ${b2_EXECUTABLE_NAME} PATHS ${BOOST_SOURCEDIR} NO_CACHE NO_DEFAULT_PATH REQUIRED)
if(b2 STREQUAL "b2-NOTFOUND")
message(FATAL_ERROR "b2 executable not found after compiling b2. Aborting.")
endif()
endif()
# Compile Boost
message(STATUS "Compiling Boost...")
boost_compile()
# Compile Boost
message(STATUS "Compiling Boost...")
boost_compile()
# Find Boost again
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} PATHS ${BOOST_INSTALLDIR} NO_DEFAULT_PATH REQUIRED)
else()
message(STATUS "Custom Boost distribution found in ${BOOST_INSTALLDIR}")
endif()
endif()
else()
# Try to find Boost on the system and CMake's default paths
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} REQUIRED)
endif()
# Find Boost again
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} PATHS ${BOOST_INSTALLDIR} CONFIG NO_DEFAULT_PATH REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "No Boost distribution found after compiling Boost. Aborting.")
else()
set(VITA3K_Boost_FOUND 1)
endif()
else()
message(STATUS "Custom Boost distribution found in ${BOOST_INSTALLDIR}")
set(VITA3K_Boost_FOUND 1)
endif()
else()
message(STATUS "Using pre-built custom or system provided Boost distribution.")
set(VITA3K_Boost_FOUND 1)
endif()
else()
# Try to find Boost on the system and CMake's default paths
message(STATUS "VITA3K_FORCE_SYSTEM_BOOST is enabled.")
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS ${BOOST_MODULES_TO_FIND} REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Could not find system provided Boost distribution, and VITA3K_FORCE_SYSTEM_BOOST is enabled. Aborting.")
else()
set(VITA3K_Boost_FOUND 1)
endif()
endif()
else()
message(STATUS "Boost libraries already found, reusing existing config.")
endif()
endmacro(get_boost)
get_boost()

2
external/tracy vendored

@ -1 +1 @@
Subproject commit 897aec5b062664d2485f4f9a213715d2e527e0ca
Subproject commit 37aff70dfa50cf6307b3fee6074d627dc2929143

View file

@ -270,12 +270,12 @@ elseif(WIN32)
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/external/discord_game_sdk/lib/x86_64/discord_game_sdk.dll" "$<TARGET_FILE_DIR:vita3k>")
endif()
if(EXISTS "${CMAKE_BINARY_DIR}/external/openssl")
if(EXISTS "${OPENSSL_ROOT_DIR}")
add_custom_command(
TARGET vita3k
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/external/openssl/openssl-3.1/x64/bin/libssl-3-x64.dll" "$<TARGET_FILE_DIR:vita3k>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/external/openssl/openssl-3.1/x64/bin/libcrypto-3-x64.dll" "$<TARGET_FILE_DIR:vita3k>")
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_ROOT_DIR}/bin/libssl-3-x64.dll" "$<TARGET_FILE_DIR:vita3k>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_ROOT_DIR}/bin/libcrypto-3-x64.dll" "$<TARGET_FILE_DIR:vita3k>")
endif()
endif()

View file

@ -18,6 +18,8 @@
#pragma once
#include <kernel/thread/thread_state.h>
#include <algorithm>
#include <list>
#include <set>

View file

@ -20,6 +20,8 @@
#include <mem/ptr.h>
#include <util/align.h>
#include <algorithm>
struct MemspaceBlockAllocator {
struct Block {
std::uint32_t size;