Exclude libpthread from automatic export generation

Message ID 20250125194519.2576321-1-wellons@nullprogram.com
State New
Headers
Series Exclude libpthread from automatic export generation |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Christopher Wellons Jan. 25, 2025, 7:45 p.m. UTC
  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(+)
  

Comments

Alan Modra Jan. 27, 2025, 7:58 a.m. UTC | #1
On Sat, Jan 25, 2025 at 02:45:20PM -0500, Christopher Wellons wrote:
> --- 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 }
>  };

Applied.
  

Patch

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 }
 };