From 466346c208f1db7bcc6c9b924ceda2f8cd5f4aac Mon Sep 17 00:00:00 2001 From: Patrick Quist Date: Wed, 5 Jun 2024 18:18:55 +0200 Subject: [PATCH] fix kotlin execution result when compilation fails (#6556) Fixes https://github.com/compiler-explorer/compiler-explorer/issues/6547 --- lib/compilers/java.ts | 4 ++-- lib/compilers/kotlin.ts | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/compilers/java.ts b/lib/compilers/java.ts index fc7691b8a18..286d625e3e8 100644 --- a/lib/compilers/java.ts +++ b/lib/compilers/java.ts @@ -28,7 +28,7 @@ import fs from 'fs-extra'; import Semver from 'semver'; import type {ParsedAsmResult, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; -import {BypassCache} from '../../types/compilation/compilation.interfaces.js'; +import {BypassCache, CompilationResult} from '../../types/compilation/compilation.interfaces.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; @@ -130,7 +130,7 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo return ['-Xlint:all', '-encoding', 'utf8']; } - override async handleInterpreting(key, executeParameters: ExecutableExecutionOptions) { + override async handleInterpreting(key, executeParameters: ExecutableExecutionOptions): Promise { const compileResult = await this.getOrBuildExecutable(key, BypassCache.None); if (compileResult.code === 0) { const extraXXFlags: string[] = []; diff --git a/lib/compilers/kotlin.ts b/lib/compilers/kotlin.ts index 3515526103d..51d7c9f1b9e 100644 --- a/lib/compilers/kotlin.ts +++ b/lib/compilers/kotlin.ts @@ -22,7 +22,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import {BypassCache} from '../../types/compilation/compilation.interfaces.js'; +import {BypassCache, CompilationResult} from '../../types/compilation/compilation.interfaces.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; @@ -96,12 +96,23 @@ export class KotlinCompiler extends JavaCompiler implements SimpleOutputFilename * * TODO(supergrecko): Find a better fix than this bandaid for execution */ - override async handleInterpreting(key, executeParameters: ExecutableExecutionOptions) { + override async handleInterpreting(key, executeParameters: ExecutableExecutionOptions): Promise { const alteredKey = { ...key, options: ['-include-runtime', '-d', 'example.jar'], }; const compileResult = await this.getOrBuildExecutable(alteredKey, BypassCache.None); + if (compileResult.code !== 0) { + return { + stdout: compileResult.stdout, + stderr: compileResult.stderr, + code: compileResult.code, + didExecute: false, + buildResult: compileResult, + timedOut: false, + }; + } + executeParameters.args = [ '-Xss136K', // Reduce thread stack size '-XX:CICompilerCount=2', // Reduce JIT compilation threads. 2 is minimum @@ -116,6 +127,7 @@ export class KotlinCompiler extends JavaCompiler implements SimpleOutputFilename // our java parameters as program parameters ...executeParameters.args, ]; + const result = await this.runExecutable(this.javaRuntime, executeParameters, compileResult.dirPath); return { ...result,