From d7356c0df5bee2566092755bc015b94b99a5a1c8 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 16 Nov 2020 11:46:53 -0800 Subject: [PATCH] sandbox root module Signed-off-by: Rudi Grinberg --- src/dune_rules/module_compilation.ml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dune_rules/module_compilation.ml b/src/dune_rules/module_compilation.ml index 9643cd4e5f8c..c81d845f87f7 100644 --- a/src/dune_rules/module_compilation.ml +++ b/src/dune_rules/module_compilation.ml @@ -55,7 +55,12 @@ let build_cm cctx ~dep_graphs ~precompiled_cmi ~cm_kind (m : Module.t) ~phase = let stdlib = CC.stdlib cctx in let mode = Mode.of_cm_kind cm_kind in let dynlink = CC.dynlink cctx in - let sandbox = CC.sandbox cctx in + let sandbox = + let default = CC.sandbox cctx in + match Module.kind m with + | Root -> Sandbox_config.needs_sandboxing + | _ -> default + in (let open Option.O in let* compiler = Result.to_option (Context.compiler ctx mode) in let ml_kind = Cm_kind.source cm_kind in @@ -165,12 +170,9 @@ let build_cm cctx ~dep_graphs ~precompiled_cmi ~cm_kind (m : Module.t) ~phase = in let modules = Compilation_context.modules cctx in let obj_dirs = - match Module.kind m with - | Root -> [] - | _ -> - Obj_dir.all_obj_dirs obj_dir ~mode - |> List.concat_map ~f:(fun p -> - [ Command.Args.A "-I"; Path (Path.build p) ]) + Obj_dir.all_obj_dirs obj_dir ~mode + |> List.concat_map ~f:(fun p -> + [ Command.Args.A "-I"; Path (Path.build p) ]) in SC.add_rule sctx ~sandbox ~dir (let open Build.With_targets.O in