summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-09-19 14:20:47 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-09-19 14:20:47 -0400
commit00753a70dadf871654fa4f805bf3a409ad8bfbd7 (patch)
tree4e8b5af14dec9b90670068201fea0935640d3217 /src/compiler.sml
parent0ce7847026a7be88c3cde012c5f74d69d682a491 (diff)
Edward Z. Yang's patch to avoid repeating linker arguments
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml14
1 files changed, 13 insertions, 1 deletions
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