aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers
diff options
context:
space:
mode:
authorPatrick Quist <partouf@gmail.com>2024-02-14 19:09:31 +0100
committerGitHub <noreply@github.com>2024-02-14 19:09:31 +0100
commit9c5a6d3d95a95256a085437c6b07980de8504e09 (patch)
tree4266e73a224c264c78f85503c30ceb6424be02e7 /lib/compilers
parentd07b67945d5e2193df3c9e94fa2e62493e244fc2 (diff)
downloadcompiler-explorer-9c5a6d3d95a95256a085437c6b07980de8504e09.tar.gz
compiler-explorer-9c5a6d3d95a95256a085437c6b07980de8504e09.zip
Clang time trace support in execution pane (#6139)gh-10642
Diffstat (limited to 'lib/compilers')
-rw-r--r--lib/compilers/clang.ts36
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/compilers/clang.ts b/lib/compilers/clang.ts
index eb45eee48..2fa7aa358 100644
--- a/lib/compilers/clang.ts
+++ b/lib/compilers/clang.ts
@@ -27,7 +27,12 @@ import path from 'path';
import _ from 'underscore';
-import type {BypassCache, CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
+import type {
+ BuildResult,
+ BypassCache,
+ CompilationResult,
+ ExecutionOptions,
+} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ExecutableExecutionOptions, UnprocessedExecResult} from '../../types/execution/execution.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -76,10 +81,22 @@ export class ClangCompiler extends BaseCompiler {
}
async addTimeTraceToResult(result: CompilationResult, dirPath: string, outputFilename: string) {
- let timeTraceJson = '';
- timeTraceJson = utils.changeExtension(outputFilename, '.json');
- const jsonFilepath = path.join(dirPath, timeTraceJson);
- if (await utils.fileExists(jsonFilepath)) {
+ const timeTraceJson = utils.changeExtension(outputFilename, '.json');
+ const alternativeFilename =
+ outputFilename + '-' + utils.changeExtension(path.basename(result.inputFilename || 'example.cpp'), '.json');
+
+ const mainFilepath = path.join(dirPath, timeTraceJson);
+ const alternativeJsonFilepath = path.join(dirPath, alternativeFilename);
+
+ let jsonFilepath = '';
+
+ if (await utils.fileExists(mainFilepath)) {
+ jsonFilepath = mainFilepath;
+ } else if (await utils.fileExists(alternativeJsonFilepath)) {
+ jsonFilepath = alternativeJsonFilepath;
+ }
+
+ if (jsonFilepath) {
this.addArtifactToResult(
result,
jsonFilepath,
@@ -92,6 +109,15 @@ export class ClangCompiler extends BaseCompiler {
}
}
+ override async afterBuild(key, dirPath: string, buildResult: BuildResult): Promise<BuildResult> {
+ const compilationInfo = this.getCompilationInfo(key, buildResult, dirPath);
+
+ const filename = path.basename(compilationInfo.outputFilename);
+ await this.addTimeTraceToResult(buildResult, dirPath, filename);
+
+ return super.afterBuild(key, dirPath, buildResult);
+ }
+
override runExecutable(executable, executeParameters: ExecutableExecutionOptions, homeDir) {
if (this.asanSymbolizerPath) {
executeParameters.env = {