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
master
Xavier Leroy 2001-08-30 09:02:55 +00:00
parent 8133cdf5c3
commit e11cb7a39b
9 changed files with 110 additions and 66 deletions

20
.depend
View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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" ->

View File

@ -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

View File

@ -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 +

59
bytecomp/dllpath.ml Normal file
View File

@ -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'

25
bytecomp/dllpath.mli Normal file
View File

@ -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

View File

@ -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