Skip to content

Commit

Permalink
fix kotlin execution result when compilation fails (compiler-explorer…
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf authored Jun 5, 2024
1 parent a9ad41b commit 466346c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/compilers/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<CompilationResult> {
const compileResult = await this.getOrBuildExecutable(key, BypassCache.None);
if (compileResult.code === 0) {
const extraXXFlags: string[] = [];
Expand Down
16 changes: 14 additions & 2 deletions lib/compilers/kotlin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<CompilationResult> {
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
Expand All @@ -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,
Expand Down

0 comments on commit 466346c

Please sign in to comment.