diff options
-rw-r--r-- | driver/compenv.ml | 27 | ||||
-rw-r--r-- | driver/compenv.mli | 3 | ||||
-rw-r--r-- | driver/main.ml | 6 | ||||
-rw-r--r-- | driver/optmain.ml | 8 |
4 files changed, 37 insertions, 7 deletions
diff --git a/driver/compenv.ml b/driver/compenv.ml index 72cefac84..40b5657f7 100644 --- a/driver/compenv.ml +++ b/driver/compenv.ml @@ -58,6 +58,8 @@ let first_ccopts = ref [] let last_ccopts = ref [] let first_ppx = ref [] let last_ppx = ref [] +let first_objfiles = ref [] +let last_objfiles = ref [] (* Note: this function is duplicated in optcompile.ml *) let check_unit_name ppf filename name = @@ -297,6 +299,27 @@ let read_OCAMLPARAM position = first_ppx := v :: !first_ppx end + + | "cmo" | "cma" -> + if not !native_code then + begin + match position with + | Before_link | Before_compile -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end + + | "cmx" | "cmxa" -> + if !native_code then + begin + match position with + | Before_link | Before_compile -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end + | _ -> Printf.eprintf "Warning: discarding value of variable %S in OCAMLCOMPPARAM\n%!" @@ -310,7 +333,11 @@ let readenv position = last_include_dirs := []; last_ccopts := []; last_ppx := []; + last_objfiles := []; read_OCAMLPARAM position; all_ccopts := !last_ccopts @ !first_ccopts; all_ppx := !last_ppx @ !first_ppx +let get_objfiles () = + List.rev (!last_objfiles @ !objfiles @ !first_objfiles) + diff --git a/driver/compenv.mli b/driver/compenv.mli index 8c835e3f8..6e0f5be04 100644 --- a/driver/compenv.mli +++ b/driver/compenv.mli @@ -27,6 +27,9 @@ val first_include_dirs : string list ref val last_include_dirs : string list ref val implicit_modules : string list ref +(* return the list of objfiles, after OCAMLPARAM and List.rev *) +val get_objfiles : unit -> string list + type readenv_position = Before_args | Before_compile | Before_link diff --git a/driver/main.ml b/driver/main.ml index c839c7ce1..e80c202bc 100644 --- a/driver/main.ml +++ b/driver/main.ml @@ -150,14 +150,14 @@ let main () = if !make_archive then begin Compmisc.init_path false; - Bytelibrarian.create_archive ppf (List.rev !objfiles) + Bytelibrarian.create_archive ppf (Compenv.get_objfiles ()) (extract_output !output_name); Warnings.check_fatal (); end else if !make_package then begin Compmisc.init_path false; let extracted_output = extract_output !output_name in - let revd = List.rev !objfiles in + let revd = get_objfiles () in Bytepackager.package_files ppf revd (extracted_output); Warnings.check_fatal (); end @@ -179,7 +179,7 @@ let main () = default_output !output_name in Compmisc.init_path false; - Bytelink.link ppf (List.rev !objfiles) target; + Bytelink.link ppf (get_objfiles ()) target; Warnings.check_fatal (); end; exit 0 diff --git a/driver/optmain.ml b/driver/optmain.ml index e5f7ed0ce..45204dbf6 100644 --- a/driver/optmain.ml +++ b/driver/optmain.ml @@ -164,19 +164,19 @@ let main () = fatal "Option -a cannot be used with .cmxa input files."; Compmisc.init_path true; let target = extract_output !output_name in - Asmlibrarian.create_archive (List.rev !objfiles) target; + Asmlibrarian.create_archive (get_objfiles ()) target; Warnings.check_fatal (); end else if !make_package then begin Compmisc.init_path true; let target = extract_output !output_name in - Asmpackager.package_files ppf (List.rev !objfiles) target; + Asmpackager.package_files ppf (get_objfiles ()) target; Warnings.check_fatal (); end else if !shared then begin Compmisc.init_path true; let target = extract_output !output_name in - Asmlink.link_shared ppf (List.rev !objfiles) target; + Asmlink.link_shared ppf (get_objfiles ()) target; Warnings.check_fatal (); end else if not !compile_only && !objfiles <> [] then begin @@ -196,7 +196,7 @@ let main () = default_output !output_name in Compmisc.init_path true; - Asmlink.link ppf (List.rev !objfiles) target; + Asmlink.link ppf (get_objfiles ()) target; Warnings.check_fatal (); end; exit 0 |