From e11cb7a39b204656e6a8a73d9501bece8d6e7c08 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Thu, 30 Aug 2001 09:02:55 +0000 Subject: [PATCH] Decoupage de Dll en Dllpath + Dll, facilite la construction de ocamlc.opt et ocamlopt.opt git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3681 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- .depend | 20 +++++++------ Makefile | 10 ++++--- asmcomp/asmlink.ml | 4 +-- bytecomp/bytelink.ml | 4 +-- bytecomp/dll.ml | 45 ++--------------------------- bytecomp/dll.mli | 7 ----- bytecomp/dllpath.ml | 59 ++++++++++++++++++++++++++++++++++++++ bytecomp/dllpath.mli | 25 ++++++++++++++++ otherlibs/dynlink/Makefile | 2 +- 9 files changed, 110 insertions(+), 66 deletions(-) create mode 100644 bytecomp/dllpath.ml create mode 100644 bytecomp/dllpath.mli diff --git a/.depend b/.depend index b8bb4dcde..39ad8edf7 100644 --- a/.depend +++ b/.depend @@ -280,17 +280,21 @@ bytecomp/bytelibrarian.cmo: utils/clflags.cmo utils/config.cmi \ bytecomp/bytelibrarian.cmx: utils/clflags.cmx utils/config.cmx \ bytecomp/emitcode.cmx utils/misc.cmx bytecomp/bytelibrarian.cmi bytecomp/bytelink.cmo: bytecomp/bytesections.cmi utils/ccomp.cmi \ - utils/clflags.cmo utils/config.cmi bytecomp/dll.cmi bytecomp/emitcode.cmi \ - typing/ident.cmi bytecomp/instruct.cmi utils/misc.cmi \ - bytecomp/opcodes.cmo bytecomp/symtable.cmi bytecomp/bytelink.cmi + utils/clflags.cmo utils/config.cmi bytecomp/dll.cmi bytecomp/dllpath.cmi \ + bytecomp/emitcode.cmi typing/ident.cmi bytecomp/instruct.cmi \ + utils/misc.cmi bytecomp/opcodes.cmo bytecomp/symtable.cmi \ + bytecomp/bytelink.cmi bytecomp/bytelink.cmx: bytecomp/bytesections.cmx utils/ccomp.cmx \ - utils/clflags.cmx utils/config.cmx bytecomp/dll.cmx bytecomp/emitcode.cmx \ - typing/ident.cmx bytecomp/instruct.cmx utils/misc.cmx \ - bytecomp/opcodes.cmx bytecomp/symtable.cmx bytecomp/bytelink.cmi + utils/clflags.cmx utils/config.cmx bytecomp/dll.cmx bytecomp/dllpath.cmx \ + bytecomp/emitcode.cmx typing/ident.cmx bytecomp/instruct.cmx \ + utils/misc.cmx bytecomp/opcodes.cmx bytecomp/symtable.cmx \ + bytecomp/bytelink.cmi bytecomp/bytesections.cmo: utils/config.cmi bytecomp/bytesections.cmi bytecomp/bytesections.cmx: utils/config.cmx bytecomp/bytesections.cmi bytecomp/dll.cmo: utils/config.cmi utils/misc.cmi bytecomp/dll.cmi bytecomp/dll.cmx: utils/config.cmx utils/misc.cmx bytecomp/dll.cmi +bytecomp/dllpath.cmo: utils/config.cmi bytecomp/dllpath.cmi +bytecomp/dllpath.cmx: utils/config.cmx bytecomp/dllpath.cmi bytecomp/emitcode.cmo: parsing/asttypes.cmi typing/btype.cmi \ utils/clflags.cmo utils/config.cmi typing/env.cmi typing/ident.cmi \ bytecomp/instruct.cmi bytecomp/lambda.cmi bytecomp/meta.cmi \ @@ -445,12 +449,12 @@ asmcomp/asmlibrarian.cmx: utils/ccomp.cmx asmcomp/clambda.cmx \ asmcomp/asmlibrarian.cmi asmcomp/asmlink.cmo: asmcomp/asmgen.cmi utils/ccomp.cmi utils/clflags.cmo \ asmcomp/cmmgen.cmi asmcomp/compilenv.cmi utils/config.cmi \ - bytecomp/dll.cmi asmcomp/emit.cmi asmcomp/emitaux.cmi \ + bytecomp/dllpath.cmi asmcomp/emit.cmi asmcomp/emitaux.cmi \ parsing/location.cmi utils/misc.cmi asmcomp/proc.cmi \ bytecomp/runtimedef.cmi asmcomp/asmlink.cmi asmcomp/asmlink.cmx: asmcomp/asmgen.cmx utils/ccomp.cmx utils/clflags.cmx \ asmcomp/cmmgen.cmx asmcomp/compilenv.cmx utils/config.cmx \ - bytecomp/dll.cmx asmcomp/emit.cmx asmcomp/emitaux.cmx \ + bytecomp/dllpath.cmx asmcomp/emit.cmx asmcomp/emitaux.cmx \ parsing/location.cmx utils/misc.cmx asmcomp/proc.cmx \ bytecomp/runtimedef.cmx asmcomp/asmlink.cmi asmcomp/clambda.cmo: parsing/asttypes.cmi typing/ident.cmi \ diff --git a/Makefile b/Makefile index 6bec08731..c74542fd9 100644 --- a/Makefile +++ b/Makefile @@ -57,11 +57,11 @@ COMP=bytecomp/lambda.cmo bytecomp/printlambda.cmo \ bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo \ bytecomp/translobj.cmo bytecomp/translcore.cmo \ bytecomp/translclass.cmo bytecomp/translmod.cmo \ - bytecomp/simplif.cmo bytecomp/runtimedef.cmo bytecomp/dll.cmo + bytecomp/simplif.cmo bytecomp/runtimedef.cmo bytecomp/dllpath.cmo BYTECOMP=bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo \ bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo \ - bytecomp/bytesections.cmo bytecomp/symtable.cmo \ + bytecomp/bytesections.cmo bytecomp/dll.cmo bytecomp/symtable.cmo \ bytecomp/bytelibrarian.cmo bytecomp/bytelink.cmo ASMCOMP=asmcomp/arch.cmo asmcomp/cmm.cmo asmcomp/printcmm.cmo \ @@ -334,8 +334,10 @@ beforedepend:: parsing/linenum.ml # The bytecode compiler compiled with the native-code compiler ocamlc.opt: $(COMPOBJS:.cmo=.cmx) - cd asmrun; $(MAKE) meta.o - $(CAMLOPT) $(LINKFLAGS) -o ocamlc.opt $(COMPOBJS:.cmo=.cmx) asmrun/meta.o + cd asmrun; $(MAKE) meta.o dynlink.o + $(CAMLOPT) $(LINKFLAGS) -ccopt "$(BYTECCLINKOPTS)" -o ocamlc.opt \ + $(COMPOBJS:.cmo=.cmx) \ + asmrun/meta.o asmrun/dynlink.o -cclib "$(DYNLINKOPTS)" partialclean:: rm -f ocamlc.opt diff --git a/asmcomp/asmlink.ml b/asmcomp/asmlink.ml index fff54f955..20e0e6983 100644 --- a/asmcomp/asmlink.ml +++ b/asmcomp/asmlink.ml @@ -248,8 +248,8 @@ let call_linker file_list startup_file = (List.map (fun dir -> if dir = "" then "" else Config.native_c_rpath ^ dir) (!Clflags.dllpaths @ - Dll.ld_library_path_contents() @ - Dll.ld_conf_contents()))) + Dllpath.ld_library_path_contents() @ + Dllpath.ld_conf_contents()))) (String.concat " " (List.rev !Clflags.ccobjs)) runtime_lib c_lib diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml index 1c3aefe80..ef50d424d 100644 --- a/bytecomp/bytelink.ml +++ b/bytecomp/bytelink.ml @@ -420,8 +420,8 @@ let build_custom_runtime prim_name exec_name = (List.map (fun dir -> if dir = "" then "" else Config.bytecomp_c_rpath ^ dir) (!Clflags.dllpaths @ - Dll.ld_library_path_contents() @ - Dll.ld_conf_contents()))) + Dllpath.ld_library_path_contents() @ + Dllpath.ld_conf_contents()))) (String.concat " " (List.rev !Clflags.ccobjs)) Config.bytecomp_c_libraries) | "Win32" -> diff --git a/bytecomp/dll.ml b/bytecomp/dll.ml index 7814e1a04..814927854 100644 --- a/bytecomp/dll.ml +++ b/bytecomp/dll.ml @@ -37,47 +37,6 @@ let names_of_opened_dlls = ref ([] : string list) let add_path dirs = search_path := dirs @ !search_path -(* Read the [ld.conf] file and return the corresponding list of directories *) - -let ld_conf_contents () = - let path = ref [] in - begin try - let ic = open_in (Filename.concat Config.standard_library "ld.conf") in - begin try - while true do - path := input_line ic :: !path - done - with End_of_file -> () - end; - close_in ic - with Sys_error _ -> () - end; - List.rev !path - -(* Split the CAML_LD_LIBRARY_PATH environment variable and return - the corresponding list of directories. *) - -let split str sep = - let rec split_rec pos = - if pos >= String.length str then [] else begin - try - let newpos = String.index_from str pos sep in - String.sub str pos (newpos - pos) :: - split_rec (newpos + 1) - with Not_found -> - [String.sub str pos (String.length str - pos)] - end in - split_rec 0 - -let ld_library_path_contents () = - let path_separator = - match Sys.os_type with - "Unix" | "Cygwin" -> ':' | "Win32" -> ';' | _ -> assert false in - try - split (Sys.getenv "CAML_LD_LIBRARY_PATH") path_separator - with Not_found -> - [] - (* Extract names of DLLs from a list of C object files and libraries *) let extract_dll_names files = @@ -142,7 +101,9 @@ let synchronize_primitive num symb = let init_toplevel dllpath = search_path := - ld_library_path_contents() @ split dllpath '\000' @ ld_conf_contents(); + Dllpath.ld_library_path_contents() @ + Dllpath.split_dll_path dllpath @ + Dllpath.ld_conf_contents(); opened_dlls := Array.to_list (get_current_dlls()); names_of_opened_dlls := []; linking_in_core := true diff --git a/bytecomp/dll.mli b/bytecomp/dll.mli index e3f063317..0e79207a9 100644 --- a/bytecomp/dll.mli +++ b/bytecomp/dll.mli @@ -40,13 +40,6 @@ val synchronize_primitive: int -> dll_address -> unit (* Add the given directories to the search path for DLLs. *) val add_path: string list -> unit -(* Read the [ld.conf] file and return the corresponding list of directories *) -val ld_conf_contents: unit -> string list - -(* Split the CAML_LD_LIBRARY_PATH environment variable and return - the corresponding list of directories *) -val ld_library_path_contents: unit -> string list - (* Initialization for linking in core (dynlink or toplevel). Initialize the search path to the same path that was used to start the running program (CAML_LD_LIBRARY_PATH + directories in executable + diff --git a/bytecomp/dllpath.ml b/bytecomp/dllpath.ml new file mode 100644 index 000000000..f0626a871 --- /dev/null +++ b/bytecomp/dllpath.ml @@ -0,0 +1,59 @@ +(***********************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2001 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* $Id$ *) + +(* Handling of load path for dynamically-linked libraries *) + +(* Read the [ld.conf] file and return the corresponding list of directories *) + +let ld_conf_contents () = + let path = ref [] in + begin try + let ic = open_in (Filename.concat Config.standard_library "ld.conf") in + begin try + while true do + path := input_line ic :: !path + done + with End_of_file -> () + end; + close_in ic + with Sys_error _ -> () + end; + List.rev !path + +(* Split the CAML_LD_LIBRARY_PATH environment variable and return + the corresponding list of directories. *) + +let split str sep = + let rec split_rec pos = + if pos >= String.length str then [] else begin + try + let newpos = String.index_from str pos sep in + String.sub str pos (newpos - pos) :: + split_rec (newpos + 1) + with Not_found -> + [String.sub str pos (String.length str - pos)] + end in + split_rec 0 + +let ld_library_path_contents () = + let path_separator = + match Sys.os_type with + "Unix" | "Cygwin" -> ':' | "Win32" -> ';' | _ -> assert false in + try + split (Sys.getenv "CAML_LD_LIBRARY_PATH") path_separator + with Not_found -> + [] + +let split_dll_path path = + split path '\000' diff --git a/bytecomp/dllpath.mli b/bytecomp/dllpath.mli new file mode 100644 index 000000000..496fbf497 --- /dev/null +++ b/bytecomp/dllpath.mli @@ -0,0 +1,25 @@ +(***********************************************************************) +(* *) +(* Objective Caml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2001 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* $Id$ *) + +(* Handling of load path for dynamically-linked libraries *) + +(* Read the [ld.conf] file and return the corresponding list of directories *) +val ld_conf_contents: unit -> string list + +(* Split the CAML_LD_LIBRARY_PATH environment variable and return + the corresponding list of directories *) +val ld_library_path_contents: unit -> string list + +(* Split the given 0-separated path *) +val split_dll_path: string -> string list diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile index fd9e99989..abecf597a 100644 --- a/otherlibs/dynlink/Makefile +++ b/otherlibs/dynlink/Makefile @@ -24,7 +24,7 @@ OBJS=dynlink.cmo COMPILEROBJS=misc.cmo config.cmo tbl.cmo clflags.cmo \ ident.cmo path.cmo \ types.cmo btype.cmo predef.cmo runtimedef.cmo \ - bytesections.cmo dll.cmo symtable.cmo opcodes.cmo meta.cmo + bytesections.cmo dllpath.cmo dll.cmo symtable.cmo opcodes.cmo meta.cmo all: dynlink.cma extract_crc