Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/c-util/run-cc.sml
ViewVC logotype

Diff of /branches/lamont/src/compiler/c-util/run-cc.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1713, Fri Mar 9 21:37:19 2012 UTC revision 1714, Sat Mar 10 00:00:50 2012 UTC
# Line 11  Line 11 
11    (* compile ("base", cflags) -- compiles the file "base.c" to produce "base.o". *)    (* compile ("base", cflags) -- compiles the file "base.c" to produce "base.o". *)
12      val compile : string * string list -> unit      val compile : string * string list -> unit
13    
14    (* link ("base", opts) -- links base.o using the given options (libraries, etc.) *)    (* linkExec ("base", opts) -- links base.o to create an executable using the
15      val link : string * string list -> unit     * given options (libraries, etc.)
16       *)
17        val linkExec : string * string list -> unit
18    
19      (* linkLib ("base", opts) -- links base.o to create using the given options (libraries, etc.) *)
20        val linkLib : string * string list -> unit
21    
22    end = struct    end = struct
23    
# Line 29  Line 34 
34              PhaseTimer.withTimer Timers.timeCC system cmd              PhaseTimer.withTimer Timers.timeCC system cmd
35            end            end
36    
37      fun link (baseName, ldOpts) = let      fun linkExec (baseName, ldOpts) = let
38            val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}            val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}
39            val exeFile = baseName            val exeFile = baseName
40            val cmd = String.concatWith " " ([Paths.cc, "-o", exeFile, objFile] @ ldOpts)            val cmd = String.concatWith " " ([Paths.cc, "-o", exeFile, objFile] @ ldOpts)
41            in            in
42              PhaseTimer.withTimer Timers.timeCC system cmd              PhaseTimer.withTimer Timers.timeCC system cmd
43            end            end
44    
45        fun linkLib (baseName, ldOpts) = let
46              val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}
47              val tmpFile = OS.Path.joinBaseExt{base=OS.FileSys.tmpName(), ext=SOME "o"}
48              val cmd = String.concatWith " " ([Paths.ld, "-r", "-o", tmpFile, objFile] @ ldOpts)
49              fun link () = (
50                    system cmd;
51                    OS.FileSys.rename{old=tmpFile, new=objFile}
52                      handle ex => (OS.FileSys.remove tmpFile; raise ex))
53              in
54                PhaseTimer.withTimer Timers.timeCC system cmd
55              end
56    
57    end    end

Legend:
Removed from v.1713  
changed lines
  Added in v.1714

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0