Bear/0003-Bugfix-skip-rebuild-without-new-options-and-preprocess.patch

80 lines
3.2 KiB
Diff
Raw Permalink Normal View History

diff --git a/source/intercept/source/report/wrapper/Application.cc b/source/intercept/source/report/wrapper/Application.cc
index 358d2dc..cec5dba 100644
--- a/source/intercept/source/report/wrapper/Application.cc
+++ b/source/intercept/source/report/wrapper/Application.cc
@@ -167,6 +167,15 @@ namespace wr {
return option_new;
}
+ bool WrapperBuilder::enableWrapperBuilder()
+ {
+ bool emtpy_options = compile_flags_.size() == 0 && ld_flags_.size() == 0;
+ // skip preprocess commands
+ auto it = std::find(parameters_replace_.begin(), parameters_replace_.end(), "-E");
+ bool preprocess = it != parameters_replace_.end();
+ return !emtpy_options && !preprocess;
+ }
+
Execution WrapperBuilder::get_new_execution(Execution& execution)
{
return Execution {
@@ -253,17 +262,17 @@ namespace wr {
rust::Result<wr::Execution> result_execution = supervisor_client.resolve(execution_);
wr::Execution execution = result_execution.unwrap();
-
- if (!lamd_is_compiler_call(execution.executable) && !lamd_is_linker_call(execution.executable)) {
+ wr::WrapperBuilder wrBuilder = wr::WrapperBuilder(execution.executable, execution.environment)
+ .add_arguments(execution.arguments.begin(), execution.arguments.end());
+ if ((!lamd_is_compiler_call(execution.executable) && !lamd_is_linker_call(execution.executable))
+ || !wrBuilder.enableWrapperBuilder()) {
return result_execution
.and_then<sys::Process>(lmd_builder)
.and_then<sys::ExitStatus>(lmd_child_wait)
.map<int>(lmd_status_ret);
}
- auto new_execution = wr::WrapperBuilder(execution.executable, execution.environment)
- .add_arguments(execution.arguments.begin(), execution.arguments.end())
- .get_new_execution(execution);
+ auto new_execution = wrBuilder.get_new_execution(execution);
auto build_spawn = result_execution.and_then<sys::Process>(lmd_wrapper_builder);
diff --git a/source/intercept/source/report/wrapper/Application.h b/source/intercept/source/report/wrapper/Application.h
index 5113be3..41160c5 100644
--- a/source/intercept/source/report/wrapper/Application.h
+++ b/source/intercept/source/report/wrapper/Application.h
@@ -79,6 +79,7 @@ namespace wr {
std::list<std::string> split_optons(std::string& options);
Execution get_new_execution(Execution& execution);
+ bool enableWrapperBuilder();
public:
NON_DEFAULT_CONSTRUCTABLE(WrapperBuilder)
diff --git a/test/cases/compilation/output/skip_preprocess_commands.sh b/test/cases/compilation/output/skip_preprocess_commands.sh
new file mode 100644
index 0000000..ea229b6
--- /dev/null
+++ b/test/cases/compilation/output/skip_preprocess_commands.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env sh
+
+# REQUIRES: preload, shell
+# RUN: %{shell} %s %t
+# RUN: cd %T; /usr/bin/env - %{bear} --verbose --output %t.json -- %{shell} %t/build.sh
+# RUN: assert_compilation %t.json count -eq 0
+
+
+TEST=$1
+
+mkdir -p $TEST;
+touch $TEST/source.c;
+
+cat > "$TEST/build.sh" << EOF
+#!/usr/bin/env sh
+
+$CC -E -o $TEST/source.i $TEST/source.c;
+EOF