changeset 1822:8bc16ff91d32

Edward Z. Yang's patch to avoid repeating linker arguments
author Adam Chlipala <adam@chlipala.net>
date Wed, 19 Sep 2012 14:20:47 -0400
parents 148203744882
children 66a58d8501e0
files src/compiler.sml
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/compiler.sml	Sun Aug 05 14:55:28 2012 -0400
+++ b/src/compiler.sml	Wed Sep 19 14:20:47 2012 -0400
@@ -1442,6 +1442,11 @@
 
 val beforeC = ref (fn () => ())
 
+structure StringSet = BinarySetFn(struct
+                                  type ord_key = string
+                                  val compare = String.compare
+                                  end)
+
 fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} =
     let
         val proto = Settings.currentProtocol ()
@@ -1478,7 +1483,14 @@
             else
                 (compile, link)
 
-        val link = foldl (fn (s, link) => link ^ " " ^ s) link link'
+        val link = #1 (foldl
+            (fn (s, (link, set)) =>
+              if StringSet.member (set, s) then
+                (link, set)
+              else
+                ((link ^ " " ^ s), StringSet.add (set, s)))
+            (link, StringSet.empty)
+            link')
 
         fun system s =
             (if debug then