[pthreads] Fix EACCESSVIOLATION in pthread_getname_np and better install handling (#28173)

* [pthreads] Fix EACCESSVIOLATION in pthread_getname_np

* [pthreads] Use vcpkg options instead custom commands

* [pthreads] Update port version

* [pthreads] Don't use separate builds for release and debug

* [pthreads] Update port version

* [pthreads] Cleaner solution for building configuration

* [pthreads] Update port version

* [pthreads] Correct variable name

* [pthreads] Update port version

* [pthreads] Make install even more optimized

* [pthreads] Update port version

* [pthreads] Fix static builds

* [pthreads] Update port version

* [pthreads] Correct quotes

* [pthreads] Update port version

* [pthreads] Fix compatibility with UWP

* [pthreads] Update port version

* [pthreads] Correction in fix-pthread_getname_np.patch

* [pthreads] Update port version
This commit is contained in:
tdcosta100 2022-12-28 19:04:12 -03:00 коммит произвёл GitHub
Родитель d94850162c
Коммит b7eaf99a7b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 141 добавлений и 78 удалений

Просмотреть файл

@ -0,0 +1,53 @@
diff --git a/Makefile b/Makefile
index a703b9c..b7b5ea7 100644
--- a/Makefile
+++ b/Makefile
@@ -80,18 +80,27 @@ help:
@ echo nmake clean VSE-static-debug
all:
+!IF DEFINED(BUILD_STATIC)
+! IF DEFINED(BUILD_RELEASE)
$(MAKE) /E clean VC-static
$(MAKE) /E clean VCE-static
$(MAKE) /E clean VSE-static
+! ELSE
$(MAKE) /E clean VC-static-debug
$(MAKE) /E clean VCE-static-debug
$(MAKE) /E clean VSE-static-debug
+! ENDIF
+!ELSE
+! IF DEFINED(BUILD_RELEASE)
$(MAKE) /E clean VC
$(MAKE) /E clean VCE
$(MAKE) /E clean VSE
+! ELSE
$(MAKE) /E clean VC-debug
$(MAKE) /E clean VCE-debug
$(MAKE) /E clean VSE-debug
+! ENDIF
+!ENDIF
$(MAKE) /E clean
TEST_ENV = CFLAGS="$(CFLAGS) /DNO_ERROR_DIALOGS"
@@ -218,8 +227,7 @@ install:
if not exist $(LIBDEST) mkdir $(LIBDEST)
if not exist $(HDRDEST) mkdir $(HDRDEST)
if exist pthreadV*.dll copy pthreadV*.dll $(DLLDEST)
- copy pthreadV*.lib $(LIBDEST)
- copy libpthreadV*.lib $(LIBDEST)
+ if exist pthreadV*.lib copy pthreadV*.lib $(LIBDEST)
copy _ptw32.h $(HDRDEST)
copy pthread.h $(HDRDEST)
copy sched.h $(HDRDEST)
@@ -229,8 +237,8 @@ $(DLLS): $(DLL_OBJS)
$(CC) /LDd /Zi $(DLL_OBJS) /link /implib:$*.lib $(XLIBS) /out:$@
$(INLINED_STATIC_STAMPS): $(STATIC_OBJS)
- if exist lib$*.lib del lib$*.lib
- lib $(STATIC_OBJS) /out:lib$*.lib
+ if exist $*.lib del $*.lib
+ lib $(STATIC_OBJS) /out:$*.lib
echo. >$@
$(SMALL_STATIC_STAMPS): $(STATIC_OBJS_SMALL)

Просмотреть файл

@ -0,0 +1,26 @@
diff --git a/pthread_getname_np.c b/pthread_getname_np.c
index 8fc32b1..7c18655 100644
--- a/pthread_getname_np.c
+++ b/pthread_getname_np.c
@@ -59,10 +59,18 @@ pthread_getname_np(pthread_t thr, char *name, int len)
__ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
- for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++)
- {}
+ if(tp->name)
+ {
+ for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++)
+ {}
+
+ *d = '\0';
+ }
+ else
+ {
+ *name = '\0';
+ }
- *d = '\0';
__ptw32_mcs_lock_release (&threadLock);
return result;

Просмотреть файл

@ -15,3 +15,23 @@ index 1579376..3a7d29b 100644
#if !defined (__PTW32_CONFIG_H)
# error "config.h was not #included"
#endif
diff --git a/pthread_cancel.c b/pthread_cancel.c
index fddf216..bf16870 100644
--- a/pthread_cancel.c
+++ b/pthread_cancel.c
@@ -64,12 +64,12 @@ __ptw32_cancel_callback (ULONG_PTR unused)
DWORD
__ptw32_Registercancellation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
{
- CONTEXT context;
+ /*CONTEXT context;
context.ContextFlags = CONTEXT_CONTROL;
GetThreadContext (threadH, &context);
__PTW32_PROGCTR (context) = (DWORD_PTR) __ptw32_cancel_self;
- SetThreadContext (threadH, &context);
+ SetThreadContext (threadH, &context);*/
return 0;
}

Просмотреть файл

@ -17,91 +17,44 @@ else()
list(APPEND PATCH_FILES use-mt.patch)
endif()
list(APPEND PATCH_FILES fix-pthread_getname_np.patch fix-install.patch)
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO pthreads4w
FILENAME "pthreads4w-code-v${VERSION}.zip"
SHA512 49e541b66c26ddaf812edb07b61d0553e2a5816ab002edc53a38a897db8ada6d0a096c98a9af73a8f40c94283df53094f76b429b09ac49862465d8697ed20013
PATCHES
fix-arm-macro.patch
fix-arm64-version_rc.patch # https://sourceforge.net/p/pthreads4w/code/merge-requests/6/
${PATCH_FILES}
OUT_SOURCE_PATH SOURCE_PATH
REPO pthreads4w
FILENAME "pthreads4w-code-v${VERSION}.zip"
SHA512 49e541b66c26ddaf812edb07b61d0553e2a5816ab002edc53a38a897db8ada6d0a096c98a9af73a8f40c94283df53094f76b429b09ac49862465d8697ed20013
PATCHES
fix-arm-macro.patch
fix-arm64-version_rc.patch # https://sourceforge.net/p/pthreads4w/code/merge-requests/6/
${PATCH_FILES}
)
find_program(NMAKE nmake REQUIRED)
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" DESTROOT_DEBUG)
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" DESTROOT_RELEASE)
vcpkg_list(SET OPTIONS_DEBUG "DESTROOT=${DESTROOT_DEBUG}")
vcpkg_list(SET OPTIONS_RELEASE "DESTROOT=${DESTROOT_RELEASE}" "BUILD_RELEASE=1")
################
# Release build
################
message(STATUS "Building ${TARGET_TRIPLET}-rel")
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" INST_DIR_REL)
vcpkg_execute_required_process(
COMMAND "${NMAKE}" -f Makefile all install
"DESTROOT=\"${INST_DIR_REL}\""
WORKING_DIRECTORY "${SOURCE_PATH}"
LOGNAME nmake-build-${TARGET_TRIPLET}-release
)
file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVC3d.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVCE3d.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pthreadVSE3d.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVC3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVCE3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/pthreadVSE3d.lib")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3.lib")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libpthreadVC3.lib" "${CURRENT_PACKAGES_DIR}/lib/pthreadVC3.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libpthreadVCE3.lib" "${CURRENT_PACKAGES_DIR}/lib/pthreadVCE3.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libpthreadVSE3.lib" "${CURRENT_PACKAGES_DIR}/lib/pthreadVSE3.lib")
vcpkg_list(APPEND OPTIONS_DEBUG "BUILD_STATIC=1")
vcpkg_list(APPEND OPTIONS_RELEASE "BUILD_STATIC=1")
endif()
message(STATUS "Building ${TARGET_TRIPLET}-rel done")
vcpkg_install_nmake(
CL_LANGUAGE C
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_NAME Makefile
OPTIONS_DEBUG ${OPTIONS_DEBUG}
OPTIONS_RELEASE ${OPTIONS_RELEASE}
)
if(NOT VCPKG_BUILD_TYPE)
################
# Debug build
################
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" INST_DIR_DBG)
vcpkg_execute_required_process(
COMMAND "${NMAKE}" /G -f Makefile all install
"DESTROOT=\"${INST_DIR_DBG}\""
WORKING_DIRECTORY "${SOURCE_PATH}"
LOGNAME nmake-build-${TARGET_TRIPLET}-debug
)
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVC3.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVCE3.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/pthreadVSE3.dll")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVC3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVCE3.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVSE3.lib")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3d.lib")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3d.lib")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVC3d.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVC3d.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVCE3d.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVCE3d.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpthreadVSE3d.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/pthreadVSE3d.lib")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/PThreads4WConfig.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/PThreads4W")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper-pthread.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/pthread" RENAME vcpkg-cmake-wrapper.cmake)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper-pthreads.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/pthreads" RENAME vcpkg-cmake-wrapper.cmake)

Просмотреть файл

@ -1,8 +1,14 @@
{
"name": "pthreads",
"version": "3.0.0",
"port-version": 12,
"port-version": 13,
"description": "Meta-package that provides PThreads4W on Windows, or assumes presence of system pthreads on POSIX systems.",
"homepage": "https://sourceforge.net/projects/pthreads4w/",
"license": "Apache-2.0"
"license": "Apache-2.0",
"dependencies": [
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

Просмотреть файл

@ -6046,7 +6046,7 @@
},
"pthreads": {
"baseline": "3.0.0",
"port-version": 12
"port-version": 13
},
"ptyqt": {
"baseline": "0.6.5",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f4037e12c8075b814cab20c65509b49bd7f59257",
"version": "3.0.0",
"port-version": 13
},
{
"git-tree": "e000e1dfe6cc2725080cd0e41e04e363cc450bd4",
"version": "3.0.0",