aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2022-12-12 21:38:22 -0600
committerGitHub <noreply@github.com>2022-12-12 21:38:22 -0600
commitcad5227756a9fa4d09aee9fde241ab088cfafa8e (patch)
tree03aa6cd459ac063a2fc7492d11c3e7f8a94b26c0
parent9de0b70af362a8618edd8369d5498be51f862f06 (diff)
downloadcompiler-explorer-gh-5327.tar.gz
compiler-explorer-gh-5327.zip
Don't try and hack the compilation results (#4429)gh-5327
* Don't try and hack the compilation results Carbon tried to synthesize "having run" by overriding and hacking a result routine...but did so _after_ it had been cached. So cached results were broken, but live results not. This "fixes" by adding a post-compilation, but pre-cache hook and uses that instead. Naming is terrible. I also took the time to fix the `CompilationResult`'s `buildResult` Closes #4426
-rw-r--r--etc/config/carbon.defaults.properties2
-rw-r--r--lib/base-compiler.ts6
-rw-r--r--lib/compilers/carbon.ts44
-rw-r--r--types/compilation/compilation.interfaces.ts3
4 files changed, 28 insertions, 27 deletions
diff --git a/etc/config/carbon.defaults.properties b/etc/config/carbon.defaults.properties
index 6555dea35..49b18f709 100644
--- a/etc/config/carbon.defaults.properties
+++ b/etc/config/carbon.defaults.properties
@@ -6,7 +6,7 @@ needsMulti=false
supportsExecute=false
supportsBinary=false
-compiler.carbon-trunkdef.exe=todo-default-path
+compiler.carbon-trunkdef.exe=/opt/compiler-explorer/carbon-trunk/bin/carbon-explorer
compiler.carbon-trunkdef.name=Explorer (trunk)
compiler.carbon-trunkdef.alias=carbon-trunk
diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts
index 265b30381..40fb98675 100644
--- a/lib/base-compiler.ts
+++ b/lib/base-compiler.ts
@@ -2324,6 +2324,8 @@ export class BaseCompiler implements ICompiler {
if (!backendOptions.skipPopArgs) result.popularArguments = this.possibleArguments.getPopularArguments(options);
+ result = this.postCompilationPreCacheHook(result);
+
if (result.okToCache) {
await this.env.cachePut(key, result);
}
@@ -2338,6 +2340,10 @@ export class BaseCompiler implements ICompiler {
return result;
}
+ postCompilationPreCacheHook(result: CompilationResult): CompilationResult {
+ return result;
+ }
+
processAsm(result, filters, options) {
if ((options && options.includes('-emit-llvm')) || this.llvmIr.isLlvmIr(result.asm)) {
return this.llvmIr.process(result.asm, filters);
diff --git a/lib/compilers/carbon.ts b/lib/compilers/carbon.ts
index 47e819b87..88131e801 100644
--- a/lib/compilers/carbon.ts
+++ b/lib/compilers/carbon.ts
@@ -23,8 +23,10 @@
// POSSIBILITY OF SUCH DAMAGE.
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces';
+import {CompilationResult} from '../../types/compilation/compilation.interfaces';
import {CompilerInfo} from '../../types/compiler.interfaces';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces';
+import {ResultLine} from '../../types/resultline/resultline.interfaces';
import {BaseCompiler} from '../base-compiler';
import {BaseParser} from './argument-parsers';
@@ -65,41 +67,31 @@ export class CarbonCompiler extends BaseCompiler {
);
}
- override async afterCompilation(
- result,
- doExecute,
- key,
- executeParameters,
- tools,
- backendOptions,
- filters,
- options,
- optOutput,
- customBuildPath,
- ) {
- result = await super.afterCompilation(
- result,
- doExecute,
- key,
- executeParameters,
- tools,
- backendOptions,
- filters,
- options,
- optOutput,
- customBuildPath,
- );
+ lastLine(lines?: ResultLine[]): string {
+ if (!lines || lines.length === 0) return '';
+ return (lines.at(-1) as ResultLine).text;
+ }
+
+ override postCompilationPreCacheHook(result: CompilationResult): CompilationResult {
if (result.code === 0) {
// Hook to parse out the "result: 123" line at the end of the interpreted execution run.
const re = /^result: (\d+)$/;
- const match = re.exec(result.asm.at(-1).text);
+ const match = re.exec(this.lastLine(result.asm));
const code = match ? parseInt(match[1]) : -1;
result.execResult = {
stdout: result.stdout,
stderr: [],
code: code,
didExecute: true,
- buildResult: {code: 0},
+ buildResult: {
+ code: 0,
+ timedOut: false,
+ stdout: [],
+ stderr: [],
+ downloads: [],
+ executableFilename: '',
+ compilationOptions: [],
+ },
};
result.stdout = [];
}
diff --git a/types/compilation/compilation.interfaces.ts b/types/compilation/compilation.interfaces.ts
index 457928ffa..ed00b69ff 100644
--- a/types/compilation/compilation.interfaces.ts
+++ b/types/compilation/compilation.interfaces.ts
@@ -130,6 +130,9 @@ export type BuildResult = CompilationResult & {
downloads: BuildEnvDownloadInfo[];
executableFilename: string;
compilationOptions: string[];
+ stdout: ResultLine[];
+ stderr: ResultLine[];
+ code: number;
};
export type BuildStep = BasicExecutionResult & {