proper jthread support

This commit is contained in:
lizzie 2026-06-09 04:03:20 +00:00
parent 4cd3ff5aae
commit 0da809bd8b
4 changed files with 29 additions and 28 deletions

View file

@ -1,33 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ca57e1..d38c0c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,9 +113,10 @@ elseif(MINGW)
find_program(MAKE mingw32-make REQUIRED)
set(OPENSSL_BUILD_TOOL ${MAKE})
else()
- find_program(MAKE make REQUIRED)
+ find_program(MAKE gmake REQUIRED)
set(OPENSSL_BUILD_TOOL ${MAKE})
endif()
+set(OPENSSL_BUILD_TOOL gmake)
# Modify configure/build options
if(OPENSSL_TEST AND NOT CMAKE_CROSSCOMPILING)
@@ -140,7 +141,7 @@ if(NUMBER_OF_THREADS GREATER 1)
list(APPEND OPENSSL_CONFIGURE_OPTIONS /FS)
list(APPEND OPENSSL_BUILD_OPTIONS /J ${NUMBER_OF_THREADS})
else()
- list(APPEND OPENSSL_BUILD_OPTIONS -j ${NUMBER_OF_THREADS})
+# list(APPEND OPENSSL_BUILD_OPTIONS -j ${NUMBER_OF_THREADS})
endif()
endif()
diff --git a/cmake/ConfigureOpenSSL.cmake b/cmake/ConfigureOpenSSL.cmake
index 3012e05..9862aa0 100644
index 3012e05..eda6cfb 100644
--- a/cmake/ConfigureOpenSSL.cmake
+++ b/cmake/ConfigureOpenSSL.cmake
@@ -134,10 +134,24 @@ function(configure_openssl)
@@ -108,7 +108,8 @@ function(configure_openssl)
)
if(NOT "${CONFIGURE_OPTIONS_OLD}" STREQUAL "")
- if(CONFIGURE_OPTIONS STREQUAL CONFIGURE_OPTIONS_OLD)
+ # TODO(lizzie): Emscripten has issues with rebuilding due to the wrapper it uses
+ if(CMAKE_SYSTEM_NAME MATCHES "Emscripten" OR CONFIGURE_OPTIONS STREQUAL CONFIGURE_OPTIONS_OLD)
message(STATUS "Found previous configure results. Don't perform configuration")
return()
endif()
@@ -134,10 +135,24 @@ function(configure_openssl)
set(VERBOSE_OPTION OUTPUT_QUIET)
endif()

View file

@ -379,6 +379,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# Prefer the -pthread flag on Linux.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# It is absolutely promordial to enable on Emscripten
# Not only this allows to use std::thread and std::jthread without exceptions
# but it also fixes several issues related to MT operations.
# ...and CMake doesn't include it by default even when we specify
# that we prefer the pthread flag; why is that? I don't know.
if (PLATFORM_EMSCRIPTEN)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-pthread>)
endif()
find_package(RenderDoc MODULE)

View file

@ -136,6 +136,11 @@ public:
eden_path = GetDataDirectory("XDG_DATA_HOME") / EDEN_DIR;
eden_path_cache = GetDataDirectory("XDG_CACHE_HOME") / EDEN_DIR;
eden_path_config = GetDataDirectory("XDG_CONFIG_HOME") / EDEN_DIR;
#if defined(__EMSCRIPTEN__) || defined(__wasi__) || defined(__managarm__)
// folders MAY not exist in this distrobution/OS
CreateParentDir(GetDataDirectory("XDG_CONFIG_HOME"));
CreateParentDir(GetDataDirectory("XDG_CACHE_HOME"));
#endif
} else {
eden_path_cache = eden_path / CACHE_DIR;
eden_path_config = eden_path / CONFIG_DIR;

View file

@ -77,5 +77,8 @@ if (NOT MSVC)
endif()
if (PLATFORM_EMSCRIPTEN)
set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "--global-base=16777216")
target_link_options(yuzu-cmd PRIVATE
-sGLOBAL_BASE=16777216
-sPTHREAD_POOL_SIZE_STRICT=0
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency)
endif()