diff --git a/sledge/src/control.ml b/sledge/src/control.ml index cd95bb325..43356788a 100644 --- a/sledge/src/control.ml +++ b/sledge/src/control.ml @@ -425,7 +425,7 @@ let exec_block : let harness : Llair.t -> (int -> Work.t) option = fun pgm -> - let entry_points = Config.find_list "entry_points" in + let entry_points = Config.find_list "entry-points" in List.find_map entry_points ~f:(fun name -> Llair.Func.find pgm.functions (Var.program name) ) |> function diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index f521dc32b..eedff14bd 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -1358,7 +1358,7 @@ let xlate_function : x -> Llvm.llvalue -> Llair.func = let transform : Llvm.llmodule -> unit = fun llmodule -> let pm = Llvm.PassManager.create () in - let entry_points = Config.find_list "entry_points" in + let entry_points = Config.find_list "entry-points" in Llvm_ipo.add_internalize_predicate pm (fun fn -> List.exists entry_points ~f:(String.equal fn) ) ; Llvm_ipo.add_global_dce pm ; diff --git a/sledge/src/sledge_buck.ml b/sledge/src/sledge_buck.ml index dbe681442..c19c08850 100644 --- a/sledge/src/sledge_buck.ml +++ b/sledge/src/sledge_buck.ml @@ -36,7 +36,11 @@ let context () = (* invoke the LTO build for the target *) let buck_build ~context target = let open Process in - eval ~context (run "buck" ["build"; "@mode/" ^ Lazy.force mode; target]) + eval ~context + (run "buck" + [ "build" + ; "@mode/" ^ Lazy.force mode + ; "-c"; "sledge.build=True"; target ]) (* split a fully-qualified buck target into file and rule *) let parse_target target = @@ -119,6 +123,13 @@ let parse_linker_arg ~context rev_modules arg = (* build target and find constituent bitcode modules *) let bitcode_files_of ~target = + let target = + if + List.exists (Config.find_list "buck-target-patterns") + ~f:(fun substring -> String.is_substring target ~substring) + then target ^ "_sledge" + else target + in let context = context () in buck_build ~context target ; let modules = @@ -142,7 +153,7 @@ let llvm_link_opt ~lib_fuzzer_harness ~output modules = (Lazy.force llvm_bin ^ "llvm-link") ( "-internalize" :: ( "-internalize-public-api-list=" - ^ String.concat ~sep:"," (Config.find_list "entry_points") ) + ^ String.concat ~sep:"," (Config.find_list "entry-points") ) :: "-o=-" :: modules ) |- run (Lazy.force llvm_bin ^ "opt") @@ -220,7 +231,8 @@ let main ~(command : unit Command.basic_command) ~analyze = //fully/qualified/build:target. The mechanism used to integrate with \ buck uses the arguments passed to the linker, so the target must \ specify a binary that will be linked, not for instance a library \ - archive." + archive. Sledge passes the --config sledge.build=True flag to buck, which can \ + be used to configure buck targets for sledge." in Command.group ~summary ~readme ~preserve_subcommand_order:() [("analyze", analyze_cmd); ("bitcode", bitcode_cmd); ("link", link_cmd)]