|
|
@ -15,14 +15,6 @@ type t =
|
|
|
|
; quoting_style: ClangQuotes.style
|
|
|
|
; quoting_style: ClangQuotes.style
|
|
|
|
; is_driver: bool }
|
|
|
|
; is_driver: bool }
|
|
|
|
|
|
|
|
|
|
|
|
(** bad for every clang invocation *)
|
|
|
|
|
|
|
|
let clang_blacklisted_flags =
|
|
|
|
|
|
|
|
[ "--expt-relaxed-constexpr"
|
|
|
|
|
|
|
|
; "-fembed-bitcode-marker"
|
|
|
|
|
|
|
|
; "-fno-absolute-module-directory"
|
|
|
|
|
|
|
|
; "-fno-canonical-system-headers" ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fcp_dir =
|
|
|
|
let fcp_dir =
|
|
|
|
Config.bin_dir ^/ Filename.parent_dir_name ^/ Filename.parent_dir_name
|
|
|
|
Config.bin_dir ^/ Filename.parent_dir_name ^/ Filename.parent_dir_name
|
|
|
|
^/ "facebook-clang-plugins"
|
|
|
|
^/ "facebook-clang-plugins"
|
|
|
@ -92,8 +84,8 @@ let libcxx_include_to_override_regex =
|
|
|
|
|
|
|
|
|
|
|
|
(** Filter arguments from [args], looking into argfiles too. [replace_options_arg prev arg] returns
|
|
|
|
(** Filter arguments from [args], looking into argfiles too. [replace_options_arg prev arg] returns
|
|
|
|
[arg'], where [arg'] is the new version of [arg] given the preceding arguments (in reverse order) [prev]. *)
|
|
|
|
[arg'], where [arg'] is the new version of [arg] given the preceding arguments (in reverse order) [prev]. *)
|
|
|
|
let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s)
|
|
|
|
let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s) ?(post_args = [])
|
|
|
|
?(blacklisted_flags = []) ?(blacklisted_flags_with_arg = []) ?(post_args = []) args =
|
|
|
|
args =
|
|
|
|
(* [prev] is the previously seen argument, [res_rev] is the reversed result, [changed] is true if
|
|
|
|
(* [prev] is the previously seen argument, [res_rev] is the reversed result, [changed] is true if
|
|
|
|
some change has been performed *)
|
|
|
|
some change has been performed *)
|
|
|
|
let rec aux in_argfiles (prev_is_blacklisted_with_arg, res_rev, changed) args =
|
|
|
|
let rec aux in_argfiles (prev_is_blacklisted_with_arg, res_rev, changed) args =
|
|
|
@ -130,9 +122,9 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s)
|
|
|
|
L.external_warning "Error reading argument file '%s': %s@\n" at_argfile
|
|
|
|
L.external_warning "Error reading argument file '%s': %s@\n" at_argfile
|
|
|
|
(Exn.to_string e) ;
|
|
|
|
(Exn.to_string e) ;
|
|
|
|
aux in_argfiles' (false, at_argfile :: res_rev, changed) tl )
|
|
|
|
aux in_argfiles' (false, at_argfile :: res_rev, changed) tl )
|
|
|
|
| flag :: tl when List.mem ~equal:String.equal blacklisted_flags flag ->
|
|
|
|
| flag :: tl when List.mem ~equal:String.equal Config.clang_blacklisted_flags flag ->
|
|
|
|
aux in_argfiles (false, res_rev, true) tl
|
|
|
|
aux in_argfiles (false, res_rev, true) tl
|
|
|
|
| flag :: tl when List.mem ~equal:String.equal blacklisted_flags_with_arg flag ->
|
|
|
|
| flag :: tl when List.mem ~equal:String.equal Config.clang_blacklisted_flags_with_arg flag ->
|
|
|
|
(* remove the flag and its arg separately in case we are at the end of an argfile *)
|
|
|
|
(* remove the flag and its arg separately in case we are at the end of an argfile *)
|
|
|
|
aux in_argfiles (true, res_rev, true) tl
|
|
|
|
aux in_argfiles (true, res_rev, true) tl
|
|
|
|
| arg :: tl ->
|
|
|
|
| arg :: tl ->
|
|
|
@ -150,7 +142,6 @@ let filter_and_replace_unsupported_args ?(replace_options_arg = fun _ s -> s)
|
|
|
|
fatal warnings. *)
|
|
|
|
fatal warnings. *)
|
|
|
|
let clang_cc1_cmd_sanitizer cmd =
|
|
|
|
let clang_cc1_cmd_sanitizer cmd =
|
|
|
|
(* command line options not supported by the opensource compiler or the plugins *)
|
|
|
|
(* command line options not supported by the opensource compiler or the plugins *)
|
|
|
|
let blacklisted_flags_with_arg = ["-mllvm"] in
|
|
|
|
|
|
|
|
let replace_options_arg options arg =
|
|
|
|
let replace_options_arg options arg =
|
|
|
|
match (options, arg) with
|
|
|
|
match (options, arg) with
|
|
|
|
| [], _ ->
|
|
|
|
| [], _ ->
|
|
|
@ -194,19 +185,15 @@ let clang_cc1_cmd_sanitizer cmd =
|
|
|
|
argv_cons "-Wno-everything"
|
|
|
|
argv_cons "-Wno-everything"
|
|
|
|
in
|
|
|
|
in
|
|
|
|
let clang_arguments =
|
|
|
|
let clang_arguments =
|
|
|
|
filter_and_replace_unsupported_args ~blacklisted_flags:clang_blacklisted_flags
|
|
|
|
filter_and_replace_unsupported_args ~replace_options_arg ~post_args:(List.rev post_args_rev)
|
|
|
|
~blacklisted_flags_with_arg ~replace_options_arg ~post_args:(List.rev post_args_rev) cmd.argv
|
|
|
|
cmd.argv
|
|
|
|
in
|
|
|
|
in
|
|
|
|
file_arg_cmd_sanitizer {cmd with argv= clang_arguments}
|
|
|
|
file_arg_cmd_sanitizer {cmd with argv= clang_arguments}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mk ~is_driver quoting_style ~prog ~args =
|
|
|
|
let mk ~is_driver quoting_style ~prog ~args =
|
|
|
|
(* Some arguments break the compiler so they need to be removed even before the normalization step *)
|
|
|
|
(* Some arguments break the compiler so they need to be removed even before the normalization step *)
|
|
|
|
let blacklisted_flags_with_arg = ["-index-store-path"] in
|
|
|
|
let sanitized_args = filter_and_replace_unsupported_args args in
|
|
|
|
let sanitized_args =
|
|
|
|
|
|
|
|
filter_and_replace_unsupported_args ~blacklisted_flags:clang_blacklisted_flags
|
|
|
|
|
|
|
|
~blacklisted_flags_with_arg args
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
let sanitized_args =
|
|
|
|
let sanitized_args =
|
|
|
|
if is_driver then sanitized_args @ List.rev Config.clang_extra_flags else sanitized_args
|
|
|
|
if is_driver then sanitized_args @ List.rev Config.clang_extra_flags else sanitized_args
|
|
|
|
in
|
|
|
|
in
|
|
|
|