在 2025-12-25 00:24, Luca Bacci 写道:
diff --git a/mingw-w64-crt/testcases/Makefile.am 
b/mingw-w64-crt/testcases/Makefile.am
index 14c59abc..f0d51f3b 100644
--- a/mingw-w64-crt/testcases/Makefile.am
+++ b/mingw-w64-crt/testcases/Makefile.am
@@ -84,6 +85,12 @@ EXTRA_DIST = \
   t_stprintf_tmpl.h \
   t_swprintf_tmpl.h
+libprocdetach.dll: libprocdetach.o
+       $(LINK) -shared libprocdetach.o -Wl,--out-implib,[email protected]
+
+EXTRA_t_safe_flush_DEPENDENCIES = libprocdetach.dll
+t_safe_flush_LDADD = -L. -lprocdetach.dll
+

I think I saw somewhere that `-L.` belong in `_LDFLAGS`. But for this use you don't have to use `-L`; .a libraries can be passed to the linker directly:

   libprocdetach.dll.a: libprocdetach.o
        $(LINK) -shared libprocdetach.o -Wl,--out-implib,$@ -o libprocdetach.dll

   t_safe_flush_LDADD = libprocdetach.dll.a


diff --git a/mingw-w64-crt/testcases/t_safe_flush.c 
b/mingw-w64-crt/testcases/t_safe_flush.c
new file mode 100644
index 00000000..dae4c934
--- /dev/null
+++ b/mingw-w64-crt/testcases/t_safe_flush.c
@@ -0,0 +1,146 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <process.h>
+#include <io.h>
+#include <fcntl.h>
+#include <windows.h>
+#include <versionhelpers.h>
+
+#define STRING "hello world!"
+
+/* child process */
+
+CRITICAL_SECTION cs;
+
+static unsigned int thread_main(void *user_data) {

This needs to be `__stdcall`, otherwise...

+    assert(_beginthreadex(NULL, 0, thread_main, handle_event, 0, NULL) != 0);

won't compile on x86-32.


+    /* The C RunTime library flushes streams from its DllMain
+     * handler on DLL_PROCESS_DETACH. However that DllMain
+     * won't run becuase another DLL triggers instant termination.

                    ^~~~~~~ because

I'm now fixing these locally and passing it through the CI.



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to