A little off-thread, but could you please take a look at attached patches? I sent them to the list a few months ago addressing issues with winpthreads' Makefile.am when using MSVC.
The following part of Makefile.am causes build failure when using MSVC: ``` if COPY_STATIC lib_LIBRARIES += libpthread.a libpthread_a_SOURCES = libpthread_a_DEPENDENCIES = libwinpthread.la #FIXME: Use cp kludge until a better method presents itself #libpthread_a_LIBADD = $(LT_OBJDIR)/libwinpthread.a libpthread_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.a endif if COPY_SHARED lib_LIBRARIES += libpthread.dll.a libpthread_dll_a_SOURCES = libpthread_dll_a_DEPENDENCIES = libwinpthread.la #FIXME: Use cp kludge until a better method presents itself #libpthread_dll_a_LIBADD = $(LT_OBJDIR)/libwinpthread.dll.a libpthread_dll_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.dll.a endif ``` It creates libpthread.a and libpthread.dll.a so winpthreads can be linked with usual `-lpthread`. Any ideas? - Kirill Makurin ________________________________ From: LIU Hao Sent: Sunday, February 9, 2025 6:58 PM To: Kirill Makurin; mingw-w64-public@lists.sourceforge.net Subject: Re: [Mingw-w64-public] make sure WINPTHREAD_API is correctly defined in pthread_time.h 在 2025-02-09 16:40, Kirill Makurin 写道: > You make a good point here. > > Move both guarded declaration of `clockid_t` and definition of > `WINPTHREAD_API ` to pthread_compat.h > and include it from both pthread.h and pthread_time.h. > > How does this look? > > Thanks! These patches look good to me. Pushed to master now. -- Best regards, LIU Hao
From 6b27cae5f785de2839554bb9f5f64ba0cad44869 Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Tue, 12 Nov 2024 05:42:26 +0900 Subject: [PATCH 3/3] Update Makefile.am in mingw-w64-libraries/winpthreads/tests Add -L$(top_builddir)/fakelib to AM_LDFLAGS only when NOT using MSVC tools. Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/tests/Makefile.am | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mingw-w64-libraries/winpthreads/tests/Makefile.am b/mingw-w64-libraries/winpthreads/tests/Makefile.am index 19ab5f23e..9dda82f73 100644 --- a/mingw-w64-libraries/winpthreads/tests/Makefile.am +++ b/mingw-w64-libraries/winpthreads/tests/Makefile.am @@ -1,5 +1,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -AM_LDFLAGS = -L$(top_builddir)/fakelib -L$(top_builddir) -lwinpthread -static +AM_LDFLAGS = + +if !MSVC +AM_LDFLAGS += -L$(top_builddir)/fakelib +endif + +AM_LDFLAGS += -L$(top_builddir) -lwinpthread -static #FIXME: The test "test.c" is inherently broken currently. check_PROGRAMS = t_clock_getres t_clock_gettime t_clock_nanosleep t_clock_settime t_nanosleep #test -- 2.46.1.windows.1
From eb74a9fbf05da8d7eb993ab6ffc4f251bf85806b Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Wed, 13 Nov 2024 02:04:30 +0900 Subject: [PATCH 3/3] Update configure.ac and Makefile.am in mingw-w64-libraries/winpthreads Make alias for winpthread[.dll].{a|lib} as pthread[.dll].{a|lib} work with both mingw-w64 and MSVC (as used by libtool) library names. Old method worked only with mingw-w64 library names (lib*[.dll].a). Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/Makefile.am | 68 ++++++++++++++------ mingw-w64-libraries/winpthreads/configure.ac | 8 +-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/Makefile.am b/mingw-w64-libraries/winpthreads/Makefile.am index 54eca7b81..cd18373b8 100644 --- a/mingw-w64-libraries/winpthreads/Makefile.am +++ b/mingw-w64-libraries/winpthreads/Makefile.am @@ -29,29 +29,57 @@ fakelib_libgcc_s_a_SOURCES = fakelib_libgcc_eh_a_SOURCES = endif -lib_LIBRARIES = - -if COPY_STATIC -lib_LIBRARIES += libpthread.a -libpthread_a_SOURCES = -libpthread_a_DEPENDENCIES = libwinpthread.la -#FIXME: Use cp kludge until a better method presents itself -#libpthread_a_LIBADD = $(LT_OBJDIR)/libwinpthread.a -libpthread_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.a -endif - -if COPY_SHARED -lib_LIBRARIES += libpthread.dll.a -libpthread_dll_a_SOURCES = -libpthread_dll_a_DEPENDENCIES = libwinpthread.la -#FIXME: Use cp kludge until a better method presents itself -#libpthread_dll_a_LIBADD = $(LT_OBJDIR)/libwinpthread.dll.a -libpthread_dll_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.dll.a -endif - # Tell libtool how to use the resource compiler .rc.lo: $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@ +# Handle pthread[.dll].{lib|a} alias when installing +install-exec-hook: + filename=$$(grep '^dlname=' libwinpthread.la | sed -E "s|dlname='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + $(LN_S) $(DESTDIR)$(bindir)/$${filename} $(DESTDIR)$(bindir)/$${alias}; \ + else \ + :; \ + fi + filename=$$(grep '^library_names=' libwinpthread.la | sed -E "s|library_names='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + $(LN_S) $(DESTDIR)$(libdir)/$${filename} $(DESTDIR)$(libdir)/$${alias}; \ + else \ + :; \ + fi + filename=$$(grep '^old_library=' libwinpthread.la | sed -E "s|old_library='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + $(LN_S) $(DESTDIR)$(libdir)/$${filename} $(DESTDIR)$(libdir)/$${alias}; \ + else \ + :; \ + fi + +# Likewise when uninstalling +uninstall-hook: + filename=$$(grep '^dlname=' libwinpthread.la | sed -E "s|dlname='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + rm -f $(DESTDIR)$(bindir)/$${alias}; \ + else \ + :; \ + fi + filename=$$(grep '^library_names=' libwinpthread.la | sed -E "s|library_names='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + rm -f $(DESTDIR)$(libdir)/$${alias}; \ + else \ + :; \ + fi + filename=$$(grep '^old_library=' libwinpthread.la | sed -E "s|old_library='(.*)'.*|\1|"); \ + if test -n "$${filename}"; then \ + alias=$$(printf %s "$${filename}" | sed 's|winpthread|pthread|'); \ + rm -f $(DESTDIR)$(libdir)/$${alias}; \ + else \ + :; \ + fi + DISTCHECK_CONFIGURE_FLAGS = --host=$(host_triplet) diff --git a/mingw-w64-libraries/winpthreads/configure.ac b/mingw-w64-libraries/winpthreads/configure.ac index 47be2d6cc..1941f93a0 100644 --- a/mingw-w64-libraries/winpthreads/configure.ac +++ b/mingw-w64-libraries/winpthreads/configure.ac @@ -36,10 +36,10 @@ LT_LANG([Windows Resource]) AC_SUBST([LT_OBJDIR],$lt_cv_objdir) -AS_VAR_IF([enable_shared], [yes], [AS_VAR_SET([copy_shared])]) -AS_VAR_IF([enable_static], [yes], [AS_VAR_SET([copy_static])]) -AM_CONDITIONAL( [COPY_SHARED], [AS_VAR_TEST_SET([copy_shared])] ) -AM_CONDITIONAL( [COPY_STATIC], [AS_VAR_TEST_SET([copy_static])] ) +dnl AS_VAR_IF([enable_shared], [yes], [AS_VAR_SET([copy_shared])]) +dnl AS_VAR_IF([enable_static], [yes], [AS_VAR_SET([copy_static])]) +dnl AM_CONDITIONAL( [COPY_SHARED], [AS_VAR_TEST_SET([copy_shared])] ) +dnl AM_CONDITIONAL( [COPY_STATIC], [AS_VAR_TEST_SET([copy_static])] ) # Checks for libraries. # FIXME: Replace `main' with a function in `-lpthread': -- 2.46.1.windows.1
From 25c67747fab6e5f620ba1f4598799b0e69d2ef7e Mon Sep 17 00:00:00 2001 From: Kirill Makurin <maiddais...@outlook.com> Date: Tue, 12 Nov 2024 05:39:42 +0900 Subject: [PATCH 3/3] Update configure.ac and Makefile.am in mingw-w64-libraries/winpthreads Make alias for winpthread[.dll].{a|lib} as pthread[.dll].{a|lib} work with both mingw-w64 and MSVC (as used by libtool) library names. Old method worked only with mingw-w64 library names (lib*[.dll].a). Signed-off-by: Kirill Makurin <maiddais...@outlook.com> --- mingw-w64-libraries/winpthreads/Makefile.am | 61 +++++++++++++------- mingw-w64-libraries/winpthreads/configure.ac | 8 +-- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/Makefile.am b/mingw-w64-libraries/winpthreads/Makefile.am index 54eca7b81..f7125120f 100644 --- a/mingw-w64-libraries/winpthreads/Makefile.am +++ b/mingw-w64-libraries/winpthreads/Makefile.am @@ -29,29 +29,50 @@ fakelib_libgcc_s_a_SOURCES = fakelib_libgcc_eh_a_SOURCES = endif -lib_LIBRARIES = - -if COPY_STATIC -lib_LIBRARIES += libpthread.a -libpthread_a_SOURCES = -libpthread_a_DEPENDENCIES = libwinpthread.la -#FIXME: Use cp kludge until a better method presents itself -#libpthread_a_LIBADD = $(LT_OBJDIR)/libwinpthread.a -libpthread_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.a -endif - -if COPY_SHARED -lib_LIBRARIES += libpthread.dll.a -libpthread_dll_a_SOURCES = -libpthread_dll_a_DEPENDENCIES = libwinpthread.la -#FIXME: Use cp kludge until a better method presents itself -#libpthread_dll_a_LIBADD = $(LT_OBJDIR)/libwinpthread.dll.a -libpthread_dll_a_AR = cp -f $(LT_OBJDIR)/libwinpthread.dll.a -endif - # Tell libtool how to use the resource compiler .rc.lo: $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@ + +# Handle pthread[.dll].{lib|a} alias when installing +install-exec-hook: + if test -f $(DESTDIR)$(bindir)/winpthread-1.dll; then \ + $(LN_S) $(DESTDIR)$(bindir)/winpthread-1.dll $(DESTDIR)$(bindir)/pthread-1.dll; \ + else \ + :; \ + fi + if test -f $(DESTDIR)$(bindir)/winpthread.dll; then \ + $(LN_S) $(DESTDIR)$(bindir)/winpthread.dll $(DESTDIR)$(bindir)/pthread.dll; \ + else \ + :; \ + fi + if test -f $(DESTDIR)$(libdir)/libwinpthread.a; then \ + $(LN_S) $(DESTDIR)$(libdir)/libwinpthread.a $(DESTDIR)$(libdir)/libpthread.a; \ + else \ + :; \ + fi + if test -f $(DESTDIR)$(libdir)/libwinpthread.dll.a; then \ + $(LN_S) $(DESTDIR)$(libdir)/libwinpthread.dll.a $(DESTDIR)$(libdir)/libpthread.dll.a; \ + else \ + :; \ + fi + if test -f $(DESTDIR)$(libdir)/winpthread.lib; then \ + $(LN_S) $(DESTDIR)$(libdir)/winpthread.lib $(DESTDIR)$(libdir)/pthread.lib; \ + else \ + :; \ + fi + if test -f $(DESTDIR)$(libdir)/winpthread.dll.lib; then \ + $(LN_S) $(DESTDIR)$(libdir)/winpthread.dll.lib $(DESTDIR)$(libdir)/pthread.dll.lib; \ + else \ + :; \ + fi + +# Likewise when uninstalling +uninstall-hook: + for file in $(DESTDIR)$(libdir)/libpthread.a $(DESTDIR)$(libdir)/libpthread.dll.a \ + $(DESTDIR)$(libdir)/pthread.lib $(DESTDIR)$(libdir)/pthread.dll.lib \ + $(DESTDIR)$(bindir)/pthread-1.dll $(DESTDIR)$(bindir)/pthread.dll; do \ + rm -f $${file}; \ + done DISTCHECK_CONFIGURE_FLAGS = --host=$(host_triplet) diff --git a/mingw-w64-libraries/winpthreads/configure.ac b/mingw-w64-libraries/winpthreads/configure.ac index 47be2d6cc..1941f93a0 100644 --- a/mingw-w64-libraries/winpthreads/configure.ac +++ b/mingw-w64-libraries/winpthreads/configure.ac @@ -36,10 +36,10 @@ LT_LANG([Windows Resource]) AC_SUBST([LT_OBJDIR],$lt_cv_objdir) -AS_VAR_IF([enable_shared], [yes], [AS_VAR_SET([copy_shared])]) -AS_VAR_IF([enable_static], [yes], [AS_VAR_SET([copy_static])]) -AM_CONDITIONAL( [COPY_SHARED], [AS_VAR_TEST_SET([copy_shared])] ) -AM_CONDITIONAL( [COPY_STATIC], [AS_VAR_TEST_SET([copy_static])] ) +dnl AS_VAR_IF([enable_shared], [yes], [AS_VAR_SET([copy_shared])]) +dnl AS_VAR_IF([enable_static], [yes], [AS_VAR_SET([copy_static])]) +dnl AM_CONDITIONAL( [COPY_SHARED], [AS_VAR_TEST_SET([copy_shared])] ) +dnl AM_CONDITIONAL( [COPY_STATIC], [AS_VAR_TEST_SET([copy_static])] ) # Checks for libraries. # FIXME: Replace `main' with a function in `-lpthread': -- 2.46.1.windows.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public