[sledge] special case buck-target-patterns

Summary: For buck targets that contain at least one of the substrings in `buck-target-pattern` option in config, change the buck target to add `_sledge` suffix.

Reviewed By: jberdine

Differential Revision: D15920018

fbshipit-source-id: 44c242e99
master
Timotej Kapus 6 years ago committed by Facebook Github Bot
parent 97c41120ae
commit 4ac252120b

@ -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

@ -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 ;

@ -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)]

Loading…
Cancel
Save