[Ur] Don't repeat arguments to linker

Edward Z. Yang ezyang at MIT.EDU
Sun Sep 16 22:28:41 EDT 2012


GHC, for example, doesn't like it:

diff -r e8149592990e src/compiler.sml
--- a/src/compiler.sml  Sun Sep 16 08:31:54 2012 -0400
+++ b/src/compiler.sml  Mon Sep 17 04:28:06 2012 +0200
@@ -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 (link, (s, set)) =>
+              if StringSet.member (set, link) then
+                (s, set)
+              else
+                ((link ^ " " ^ s), StringSet.add (set, link)))
+            (link, StringSet.empty)
+            link')
 
         fun system s =
             (if debug then



More information about the Ur mailing list