[MLton-devel] mlton/mlton/main main.sml,1.66,1.67

sweeks@users.sourceforge.net sweeks@users.sourceforge.net
Thu, 25 Apr 2002 20:06:25 -0700


Update of /cvsroot/mlton/mlton/mlton/main
In directory usw-pr-cvs1:/tmp/cvs-serv10614/mlton/main

Modified Files:
	main.sml 
Log Message:
MAIL

Changed call to linker to use libgmp.a (if it exists) instead of libgmp.so.
This is because the linker adds a dependency to a shared library even if there
are no references to it.



Index: main.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/main.sml,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** main.sml	12 Apr 2002 13:23:58 -0000	1.66
--- main.sml	26 Apr 2002 03:06:23 -0000	1.67
***************
*** 426,435 ****
  		     List.concat [list ("-D", !defines),
  				  list ("-I", rev (includeDirs))]
  		  val linkLibs: string list =
  		     List.concat [list ("-L", rev (libDirs)),
  				  list ("-l",
  					(if !debug
  					    then "mlton-gdb"
! 					 else "mlton") :: !libs)]
  		  fun compileO (inputs: File.t list) =
  		     let
--- 426,458 ----
  		     List.concat [list ("-D", !defines),
  				  list ("-I", rev (includeDirs))]
+ 		  (* This mess is necessary because the linker on linux
+ 		   * adds a dependency to a shared library even if there are
+ 		   * no references to it.  So, on linux, we explicitly link
+ 		   * with libgmp.a instead of using -lgmp.
+ 		   *)
+ 		  val linkWithGmp =
+ 		     case !hostType of
+ 			Cygwin => "-lgmp"
+ 		      | Linux =>
+ 			   case (List.peekMap
+ 				 (File.lines "/etc/ld.so.conf", fn d =>
+ 				  let
+ 				     val lib = concat [String.dropSuffix (d, 1),
+ 						       "/libgmp.a"]
+ 				  in
+ 				     if File.canRead lib
+ 					then SOME lib
+ 				     else NONE
+ 				  end)) of
+ 			      NONE => "-lgmp"
+ 			    | SOME lib => lib
  		  val linkLibs: string list =
  		     List.concat [list ("-L", rev (libDirs)),
+ 				  [linkWithGmp],
  				  list ("-l",
  					(if !debug
  					    then "mlton-gdb"
! 					 else "mlton")
! 					    :: !libs)]
  		  fun compileO (inputs: File.t list) =
  		     let



_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel