[clang] ensure we get the correct file path

Summary:
As explained in the added comment, clang started adding `-faddrsig` at the end
of every `-cc1` command, which trumps our heuristic for finding the file name
(thus we would write debug scripts to `-faddrsig.ast.sh`, do filename-based
filtering on `-faddrsig` instead of the source path, and more...).  We rely on
the file name being the last argument in `-cc1` commands because so far that's
always been the case, and we don't want to parse the clang command line and
have to know about all the clang options...

Thanks martinoluca for the trick of simply passing `-fno-addrsig`!

Reviewed By: martinoluca

Differential Revision: D12921987

fbshipit-source-id: 28bebe647
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent 6a4d8b72f0
commit 54fb38b7e8

@ -66,9 +66,17 @@ let clang_driver_action_items : ClangCommand.t -> action_item list =
pass it now. pass it now.
Using clang instead of gcc may trigger warnings about unsupported optimization flags; Using clang instead of gcc may trigger warnings about unsupported optimization flags;
passing -Wno-ignored-optimization-argument prevents that. *) passing -Wno-ignored-optimization-argument prevents that.
Clang adds "-faddrsig" by default on ELF targets. This is ok in itself, but for some
reason that flag is the only one to show up *after* the source file name in the -cc1
commands emitted by [clang -### ...]. Passing [-fno-addrsig] ensures that the source
path is always the last argument. *)
ClangCommand.append_args ClangCommand.append_args
["-fno-cxx-modules"; "-Qunused-arguments"; "-Wno-ignored-optimization-argument"] [ "-fno-cxx-modules"
; "-Qunused-arguments"
; "-Wno-ignored-optimization-argument"
; "-fno-addrsig" ]
|> (* If -fembed-bitcode is passed, it leads to multiple cc1 commands, which try to read .bc |> (* If -fembed-bitcode is passed, it leads to multiple cc1 commands, which try to read .bc
files that don't get generated, and fail. So pass -fembed-bitcode=off to disable. *) files that don't get generated, and fail. So pass -fembed-bitcode=off to disable. *)
ClangCommand.append_args ["-fembed-bitcode=off"] ClangCommand.append_args ["-fembed-bitcode=off"]

Loading…
Cancel
Save