From 00753a70dadf871654fa4f805bf3a409ad8bfbd7 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 19 Sep 2012 14:20:47 -0400 Subject: Edward Z. Yang's patch to avoid repeating linker arguments --- src/compiler.sml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compiler.sml b/src/compiler.sml index 603dd298..78999a4b 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -1442,6 +1442,11 @@ val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" 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 @@ fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} = 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 -- cgit v1.2.3