[make] compatibility with Debian testing

Summary:
- set SHELL to bash explicitly in Makefiles (Debian uses dash)
- avoid using system headers when using our own clang's headers in tests
- do not rely on the name of the object file to write the frontend debugging scripts. It turns out that `-o` is *not* always present in the arguments of `-cc1` functions so the `Option.get` could crash. Since we don't actually need to get the object file name, just a nice enough name, don't try to be smarter at guessing what object will be created and pick a different name built from the source name instead.

Reviewed By: akotulski

Differential Revision: D4159516

fbshipit-source-id: c7bc2b9
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 7705ffbc31
commit 5bd8b7fa95

@ -7,6 +7,7 @@
@SET_MAKE@ @SET_MAKE@
SHELL = bash
PLATFORM = $(shell uname) PLATFORM = $(shell uname)
ATDGEN = @ATDGEN@ ATDGEN = @ATDGEN@

@ -12,7 +12,7 @@ let module CLOpt = CommandLineOption;
/** enable debug mode (to get more data saved to disk for future inspections) */ /** enable debug mode (to get more data saved to disk for future inspections) */
let debug_mode = Config.debug_mode || Config.frontend_stats; let debug_mode = Config.debug_mode || Config.frontend_stats || Config.frontend_debug;
let buffer_len = 262143; let buffer_len = 262143;
@ -120,16 +120,16 @@ let run_clang clang_command read =>
| _ => exit 1 | _ => exit 1
}; };
let run_plugin_and_frontend frontend clang_args => { let run_plugin_and_frontend source_path frontend clang_args => {
let clang_command = ClangCommand.command_to_run (ClangCommand.with_plugin_args clang_args); let clang_command = ClangCommand.command_to_run (ClangCommand.with_plugin_args clang_args);
if debug_mode { if debug_mode {
/* -cc1 clang commands always set -o explicitly */ /* -cc1 clang commands always set -o explicitly */
let object_filename = Option.get (ClangCommand.value_of_option clang_args "-o"); let basename = source_path ^ ".capture";
/* Emit the clang command with the extra args piped to InferClang */ /* Emit the clang command with the extra args piped to InferClang */
let frontend_script_fname = Printf.sprintf "%s.sh" object_filename; let frontend_script_fname = Printf.sprintf "%s.sh" basename;
let debug_script_out = open_out frontend_script_fname; let debug_script_out = open_out frontend_script_fname;
let debug_script_fmt = Format.formatter_of_out_channel debug_script_out; let debug_script_fmt = Format.formatter_of_out_channel debug_script_out;
let biniou_fname = Printf.sprintf "%s.biniou" object_filename; let biniou_fname = Printf.sprintf "%s.biniou" basename;
Format.fprintf debug_script_fmt "%s \\@\n > %s@\n" clang_command biniou_fname; Format.fprintf debug_script_fmt "%s \\@\n > %s@\n" clang_command biniou_fname;
let infer_clang_options = let infer_clang_options =
String.concat String.concat
@ -155,7 +155,7 @@ let run_plugin_and_frontend frontend clang_args => {
"bdump -x -d \"%s/clang_ast.dict\" -w '!!DUMMY!!' %s \\@\n > %s.bdump" "bdump -x -d \"%s/clang_ast.dict\" -w '!!DUMMY!!' %s \\@\n > %s.bdump"
Config.etc_dir Config.etc_dir
biniou_fname biniou_fname
object_filename; basename;
close_out debug_script_out close_out debug_script_out
}; };
run_clang clang_command frontend run_clang clang_command frontend
@ -177,7 +177,7 @@ let cc1_capture clang_cmd => {
| Some fname => run_and_validate_clang_frontend (`File fname) | Some fname => run_and_validate_clang_frontend (`File fname)
| None => | None =>
run_plugin_and_frontend run_plugin_and_frontend
(fun chan_in => run_and_validate_clang_frontend (`Pipe chan_in)) clang_cmd source_path (fun chan_in => run_and_validate_clang_frontend (`Pipe chan_in)) clang_cmd
}; };
/* reset logging to stop capturing log output into the source file's log */ /* reset logging to stop capturing log output into the source file's log */
Logging.set_log_file_identifier CommandLineOption.Clang None; Logging.set_log_file_identifier CommandLineOption.Clang None;

@ -9,7 +9,8 @@ TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make include $(TESTS_DIR)/clang.make
ANALYZER = checkers ANALYZER = checkers
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c # see explanations in cpp/errors/Makefile for the custom isystem
CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions
INFERPRINT_OPTIONS = --issues-txt INFERPRINT_OPTIONS = --issues-txt

@ -10,8 +10,9 @@ include $(TESTS_DIR)/clang.make
ANALYZER = infer ANALYZER = infer
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c # Use the system headers of our own clang. This way, we always use the same system headers
# regardless of the libraries installed on the machine.
CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions
SOURCES = \ SOURCES = \

@ -7,7 +7,8 @@
include ../../Makefile.frontend include ../../Makefile.frontend
OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c # see explanations in cpp/errors/Makefile for the custom isystem
OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
FILES = \ FILES = \
*/*.cpp shared/*/*.cpp \ */*.cpp shared/*/*.cpp \

@ -9,7 +9,8 @@ TESTS_DIR = ../../..
include $(TESTS_DIR)/clang.make include $(TESTS_DIR)/clang.make
ANALYZER = quandary ANALYZER = quandary
CLANG_OPTIONS = -x c++ -std=c++11 -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c # see explanations in cpp/errors/Makefile for the custom isystem
CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(ROOT_DIR) -isystem$(CLANG_INCLUDES)/c++/v1/ -c
INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions INFER_OPTIONS = --cxx --ml-buckets cpp --no-filtering --debug-exceptions
INFERPRINT_OPTIONS = --issues-txt INFERPRINT_OPTIONS = --issues-txt

Loading…
Cancel
Save