From b1e54043695ca422fd1492d9e95401f818381048 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Thu, 7 Jan 2021 14:56:44 +0100 Subject: [PATCH] Add an option to configure linker's timeout --- docs/CompilationDatabaseAndJunk.rst | 6 +++--- docs/SQLiteReport.rst | 3 ++- docs/generated/CLIOptions.rst | 2 ++ include/mull/Config/Configuration.h | 2 ++ lib/Config/Configuration.cpp | 4 +++- lib/Toolchain/Linker.cpp | 5 +++-- tools/mull-cxx/CLIOptions.cpp | 9 +++++++++ tools/mull-cxx/CLIOptions.h | 1 + tools/mull-cxx/mull-cxx.cpp | 1 + 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/docs/CompilationDatabaseAndJunk.rst b/docs/CompilationDatabaseAndJunk.rst index db33efbc6..aaf5148c0 100644 --- a/docs/CompilationDatabaseAndJunk.rst +++ b/docs/CompilationDatabaseAndJunk.rst @@ -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``: @@ -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) @@ -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-`` or ``clang++-``, +*Note: on Linux you may have to specify clang- or clang++-, where corresponds to the version of clang installed* Try this: diff --git a/docs/SQLiteReport.rst b/docs/SQLiteReport.rst index 216fe9ddb..88cdad9bb 100644 --- a/docs/SQLiteReport.rst +++ b/docs/SQLiteReport.rst @@ -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. diff --git a/docs/generated/CLIOptions.rst b/docs/generated/CLIOptions.rst index 5715aad0e..02a280417 100644 --- a/docs/generated/CLIOptions.rst +++ b/docs/generated/CLIOptions.rst @@ -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) diff --git a/include/mull/Config/Configuration.h b/include/mull/Config/Configuration.h index 9bcb06b00..0de38c582 100644 --- a/include/mull/Config/Configuration.h +++ b/include/mull/Config/Configuration.h @@ -8,6 +8,7 @@ namespace mull { extern int MullDefaultTimeoutMilliseconds; +extern unsigned MullDefaultLinkerTimeoutMilliseconds; struct Configuration { bool debugEnabled; @@ -17,6 +18,7 @@ struct Configuration { bool skipSanityCheckRun; int timeout; + unsigned linkerTimeout; IDEDiagnosticsKind diagnostics; diff --git a/lib/Config/Configuration.cpp b/lib/Config/Configuration.cpp index 276758ae2..2be6ebca2 100644 --- a/lib/Config/Configuration.cpp +++ b/lib/Config/Configuration.cpp @@ -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 diff --git a/lib/Toolchain/Linker.cpp b/lib/Toolchain/Linker.cpp index 11f71ea3f..0d3d8eacc 100644 --- a/lib/Toolchain/Linker.cpp +++ b/lib/Toolchain/Linker.cpp @@ -29,7 +29,8 @@ std::string Linker::linkObjectFiles(const std::vector &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) { @@ -48,6 +49,6 @@ std::string Linker::linkObjectFiles(const std::vector &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(); } diff --git a/tools/mull-cxx/CLIOptions.cpp b/tools/mull-cxx/CLIOptions.cpp index 717e52087..68dfd8e10 100644 --- a/tools/mull-cxx/CLIOptions.cpp +++ b/tools/mull-cxx/CLIOptions.cpp @@ -90,6 +90,14 @@ opt tool::LinkerFlags( init(std::string()), cat(MullCXXCategory)); +opt tool::LinkerTimeout( + "linker-timeout", + desc("Timeout for the linking job (milliseconds)"), + Optional, + value_desc("number"), + init(MullDefaultLinkerTimeoutMilliseconds), + cat(MullCXXCategory)); + opt tool::CoverageInfo( "coverage-info", desc("Path to the coverage info file (LLVM's profdata)"), @@ -317,6 +325,7 @@ void tool::dumpCLIInterface(Diagnostics &diagnostics) { &Linker, &LinkerFlags, + &LinkerTimeout, &CoverageInfo, diff --git a/tools/mull-cxx/CLIOptions.h b/tools/mull-cxx/CLIOptions.h index c8b387656..3a4be7634 100644 --- a/tools/mull-cxx/CLIOptions.h +++ b/tools/mull-cxx/CLIOptions.h @@ -28,6 +28,7 @@ extern opt CompilationFlags; extern opt Linker; extern opt LinkerFlags; +extern opt LinkerTimeout; extern opt CoverageInfo; diff --git a/tools/mull-cxx/mull-cxx.cpp b/tools/mull-cxx/mull-cxx.cpp index f32fc713f..231c50bd3 100644 --- a/tools/mull-cxx/mull-cxx.cpp +++ b/tools/mull-cxx/mull-cxx.cpp @@ -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();