[PATCH] Exclude libpthread from automatic export generation

Christopher Wellons wellons@nullprogram.com
Sat Jan 25 19:45:20 GMT 2025


Before this change, static linking libwinpthread, commonly distributed
as part of Mingw-w64, while using automatic symbol exports would export
the entire threading API, which is never wanted. This is always the case
when static linking libstdc++ built against libpthread.
---
I only added libpthread because it has such a big impact, but libucrtapp
should probably be listed as well. The following Mingw-w64 libraries all
also contain at least one definition beyond DLL exports: libdloadhelper,
libdxerr8, libdxerr9, libgmon, libmsvcr100, libmsvcr110, libmsvcr120,
libmsvcr120_app, libmsvcr120d, libmsvcr80, libmsvcr90, and libmsvcr90d.
But they're rather unusual and have little impact. It's probably worth
blanket-excluding the entire sysroot.

 ld/pe-dll.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index d888a0b6373..f24b8716ae2 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -382,6 +382,8 @@ static const autofilter_entry_type autofilter_liblist[] =
   { STRING_COMMA_LEN ("libmsvcrt-os") },
   { STRING_COMMA_LEN ("libucrt") },
   { STRING_COMMA_LEN ("libucrtbase") },
+  { STRING_COMMA_LEN ("libpthread") },
+  { STRING_COMMA_LEN ("libwinpthread") },
   { NULL, 0 }
 };
 
-- 
2.39.5



More information about the Binutils mailing list