Skip to content

Commit

Permalink
Merge pull request #824 from mull-project/linker-timeout
Browse files Browse the repository at this point in the history
Add an option to configure linker's timeout
  • Loading branch information
AlexDenisov committed Jan 7, 2021
2 parents fd517a9 + b1e5404 commit 335313f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/CompilationDatabaseAndJunk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Get sources and build fmtlib:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
make core-test
*Note: last tested against commit ``018688da2a58ba25cdf173bd899734f755adb11a``*
*Note: last tested against commit 018688da2a58ba25cdf173bd899734f755adb11a*

Run Mull against the ``core-test``:

Expand All @@ -32,7 +32,7 @@ Run Mull against the ``core-test``:
Right now you should see a weird and long error message by the end of execution.
Here is a snippet:

.. code-blocK:: text
.. code-block:: text
/// skipped
[info] Applying mutations (threads: 1)
Expand Down Expand Up @@ -62,7 +62,7 @@ it just uses ``clang`` which works in most of the cases. However, in this case
we deal with C++ which needs a corresponding C++ linker. Instead we should be
using ``clang++``, which will do the job just fine.

*Note: on Linux you may have to specify ``clang-<version>`` or ``clang++-<version>``,
*Note: on Linux you may have to specify clang-<version> or clang++-<version>,
where <version> corresponds to the version of clang installed*

Try this:
Expand Down
3 changes: 2 additions & 1 deletion docs/SQLiteReport.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Working with SQLite report
==========================

**Warning: the data model has changed and most of the tutorial is no longer relevant/applicable**
**Warning: the data model has changed and most of the tutorial is no longer relevant/applicable.
This tutorial will be updated for the next release.**

From the very beginning, we didn't want to impose our vision on treating the results of mutation testing. Some people do not care about the mutation score, while others do care, but want to calculate it slightly differently.

Expand Down
2 changes: 2 additions & 0 deletions docs/generated/CLIOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

--linker-flags string Extra linker flags to produce final executable

--linker-timeout number Timeout for the linking job (milliseconds)

--coverage-info string Path to the coverage info file (LLVM's profdata)

--include-path regex File/directory paths to whitelist (supports regex)
Expand Down
2 changes: 2 additions & 0 deletions include/mull/Config/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace mull {

extern int MullDefaultTimeoutMilliseconds;
extern unsigned MullDefaultLinkerTimeoutMilliseconds;

struct Configuration {
bool debugEnabled;
Expand All @@ -17,6 +18,7 @@ struct Configuration {
bool skipSanityCheckRun;

int timeout;
unsigned linkerTimeout;

IDEDiagnosticsKind diagnostics;

Expand Down
4 changes: 3 additions & 1 deletion lib/Config/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ ParallelizationConfig singleThreadParallelization() {
}

int MullDefaultTimeoutMilliseconds = 3000;
unsigned MullDefaultLinkerTimeoutMilliseconds = 30000;

Configuration::Configuration()
: debugEnabled(false), dryRunEnabled(false), captureTestOutput(true), captureMutantOutput(true),
skipSanityCheckRun(false), timeout(MullDefaultTimeoutMilliseconds),
diagnostics(IDEDiagnosticsKind::None), parallelization(singleThreadParallelization()) {}
linkerTimeout(MullDefaultLinkerTimeoutMilliseconds), diagnostics(IDEDiagnosticsKind::None),
parallelization(singleThreadParallelization()) {}

} // namespace mull
5 changes: 3 additions & 2 deletions lib/Toolchain/Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ std::string Linker::linkObjectFiles(const std::vector<std::string> &objects) {
std::copy(std::begin(objects), std::end(objects), std::back_inserter(arguments));
arguments.emplace_back("-o");
arguments.push_back(resultPath.str().str());
ExecutionResult result = runner.runProgram(configuration.linker, arguments, {}, 50000, true);
ExecutionResult result =
runner.runProgram(configuration.linker, arguments, {}, configuration.linkerTimeout, true);
std::stringstream commandStream;
commandStream << configuration.linker;
for (std::string &argument : arguments) {
Expand All @@ -48,6 +49,6 @@ std::string Linker::linkObjectFiles(const std::vector<std::string> &objects) {
diagnostics.error(message.str());
}
diagnostics.debug("Link command: "s + command);
diagnostics.debug("Compiled executable: "s + resultPath.c_str());
diagnostics.info("Compiled executable: "s + resultPath.c_str());
return resultPath.str().str();
}
9 changes: 9 additions & 0 deletions tools/mull-cxx/CLIOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ opt<std::string> tool::LinkerFlags(
init(std::string()),
cat(MullCXXCategory));

opt<unsigned> tool::LinkerTimeout(
"linker-timeout",
desc("Timeout for the linking job (milliseconds)"),
Optional,
value_desc("number"),
init(MullDefaultLinkerTimeoutMilliseconds),
cat(MullCXXCategory));

opt<std::string> tool::CoverageInfo(
"coverage-info",
desc("Path to the coverage info file (LLVM's profdata)"),
Expand Down Expand Up @@ -317,6 +325,7 @@ void tool::dumpCLIInterface(Diagnostics &diagnostics) {

&Linker,
&LinkerFlags,
&LinkerTimeout,

&CoverageInfo,

Expand Down
1 change: 1 addition & 0 deletions tools/mull-cxx/CLIOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern opt<std::string> CompilationFlags;

extern opt<std::string> Linker;
extern opt<std::string> LinkerFlags;
extern opt<unsigned> LinkerTimeout;

extern opt<std::string> CoverageInfo;

Expand Down
1 change: 1 addition & 0 deletions tools/mull-cxx/mull-cxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int main(int argc, char **argv) {

configuration.linker = tool::Linker.getValue();
configuration.linkerFlags = splitFlags(tool::LinkerFlags.getValue());
configuration.linkerTimeout = tool::LinkerTimeout.getValue();

configuration.debugEnabled = tool::DebugEnabled;
configuration.timeout = tool::Timeout.getValue();
Expand Down

0 comments on commit 335313f

Please sign in to comment.