diff options
author | Guillaume Melquiond <guillaume.melquiond@inria.fr> | 2014-05-22 10:48:11 +0200 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@inria.fr> | 2014-05-22 10:48:11 +0200 |
commit | 4d6a5677f0f4af0193bb42f5d2938287efaaf91b (patch) | |
tree | df73ba2913e000fd809a7ae81e4b6cd82926a765 /library/library.ml | |
parent | cc63a961f846e6e00f56d4c1e98d80fafbfb17b8 (diff) |
Fix native_compute for systems with a limited size for the command line.
The call to the native compiler can fail due to the sheer amounts of -I
options passed to it. Indeed, it is easy to get the command line to exceed
512KB, thus causing various operating systems to reject it. This commit
avoids the issue by only passing the -I options that matter for the
currently compiled code.
Note that, in the worst case, this commit is still not sufficient on
Windows (32KB max), but this worst case should be rather uncommon and thus
can be ignored for now.
For the record, the command-line size mandated by Posix is 4KB.
Diffstat (limited to 'library/library.ml')
-rw-r--r-- | library/library.ml | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/library/library.ml b/library/library.ml index d2d2d72e4..a9cdf1f2f 100644 --- a/library/library.ml +++ b/library/library.ml @@ -763,9 +763,8 @@ let save_library_to ?todo dir f = close_out ch; (* Writing native code files *) if not !Flags.no_native_compiler then - let lp = Loadpath.get_accessible_paths () in let fn = Filename.dirname f'^"/"^Nativecode.mod_uid_of_dirpath dir in - if not (Int.equal (Nativelib.compile_library dir ast lp fn) 0) then + if not (Int.equal (Nativelib.compile_library dir ast fn) 0) then msg_error (str"Could not compile the library to native code. Skipping.") with reraise -> let reraise = Errors.push reraise in @@ -794,7 +793,13 @@ let mem s = (CObj.size_kb m) (CObj.size_kb m.library_compiled) (CObj.size_kb m.library_objects))) -let get_load_paths_str () = - List.map CUnix.string_of_physical_path (Loadpath.get_accessible_paths ()) +module StringOrd = struct type t = string let compare = String.compare end +module StringSet = Set.Make(StringOrd) -let _ = Nativelib.get_load_paths := get_load_paths_str +let get_used_load_paths () = + StringSet.elements + (List.fold_left (fun acc m -> StringSet.add + (Filename.dirname (library_full_filename m.library_name)) acc) + StringSet.empty !libraries_loaded_list) + +let _ = Nativelib.get_load_paths := get_used_load_paths |