public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid()
@ 2022-01-04 20:21 Martin Storsjö
  2022-01-11 15:46 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Storsjö @ 2022-01-04 20:21 UTC (permalink / raw)
  To: binutils

This makes the output deterministic without requiring the caller to
pass --temp-prefix.

This also avoids potential prefix clashes, if building multiple import
libraries that later are merged into one single import library (which
is done for a number of umbrella libraries in mingw-w64-crt).

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 binutils/dlltool.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 8c1ddd61f63..83f30676f77 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3930,9 +3930,6 @@ main (int ac, char **av)
 	}
     }
 
-  if (!tmp_prefix)
-    tmp_prefix = prefix_encode ("d", getpid ());
-
   for (i = 0; mtable[i].type; i++)
     if (strcmp (mtable[i].type, mname) == 0)
       break;
@@ -3992,6 +3989,22 @@ main (int ac, char **av)
       optind++;
     }
 
+  if (!tmp_prefix)
+    {
+      if (dll_name)
+        {
+          tmp_prefix = xmalloc (strlen (dll_name) + 2);
+          sprintf (tmp_prefix, "%s_", dll_name);
+          for (i = 0; tmp_prefix[i]; i++)
+            if (!ISALNUM (tmp_prefix[i]))
+              tmp_prefix[i] = '_';
+        }
+      else
+        {
+          tmp_prefix = prefix_encode ("d", getpid ());
+        }
+    }
+
   mangle_defs ();
 
   if (exp_name)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid()
  2022-01-04 20:21 [PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid() Martin Storsjö
@ 2022-01-11 15:46 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2022-01-11 15:46 UTC (permalink / raw)
  To: Martin Storsjö, binutils

Hi Martin,

> This makes the output deterministic without requiring the caller to
> pass --temp-prefix.
> 
> This also avoids potential prefix clashes, if building multiple import
> libraries that later are merged into one single import library (which
> is done for a number of umbrella libraries in mingw-w64-crt).

Patch approved and applied.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-11 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 20:21 [PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid() Martin Storsjö
2022-01-11 15:46 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).