aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/nativelib.ml
diff options
context:
space:
mode:
authorGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2014-05-22 10:48:11 +0200
committerGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2014-05-22 10:48:11 +0200
commit4d6a5677f0f4af0193bb42f5d2938287efaaf91b (patch)
treedf73ba2913e000fd809a7ae81e4b6cd82926a765 /kernel/nativelib.ml
parentcc63a961f846e6e00f56d4c1e98d80fafbfb17b8 (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 'kernel/nativelib.ml')
-rw-r--r--kernel/nativelib.ml9
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/nativelib.ml b/kernel/nativelib.ml
index 05e470da9..b877dda8f 100644
--- a/kernel/nativelib.ml
+++ b/kernel/nativelib.ml
@@ -59,7 +59,8 @@ let write_ml_code fn ?(header=[]) code =
List.iter (pp_global fmt) (header@code);
close_out ch_out
-let call_compiler ml_filename load_path =
+let call_compiler ml_filename =
+ let load_path = !get_load_paths () in
let load_path = List.map (fun dn -> dn / output_dir) load_path in
let include_dirs = List.map Filename.quote (include_dirs () @ load_path) in
let include_dirs = String.concat " -I " include_dirs in
@@ -75,9 +76,9 @@ let call_compiler ml_filename load_path =
let compile fn code =
write_ml_code fn code;
- call_compiler fn (!get_load_paths())
+ call_compiler fn
-let compile_library dir code load_path fn =
+let compile_library dir code fn =
let header = mk_library_header dir in
let fn = fn ^ source_ext in
let basename = Filename.basename fn in
@@ -86,7 +87,7 @@ let compile_library dir code load_path fn =
if not (Sys.file_exists dirname) then Unix.mkdir dirname 0o755;
let fn = dirname / basename in
write_ml_code fn ~header code;
- fst (call_compiler fn load_path)
+ fst (call_compiler fn)
(* call_linker links dynamically the code for constants in environment or a *)
(* conversion test. Silently fails if the file does not exist in bytecode *)