aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/base-compiler.js33
-rw-r--r--lib/compilers/ada.js4
-rw-r--r--lib/compilers/rust.js12
3 files changed, 22 insertions, 27 deletions
diff --git a/lib/base-compiler.js b/lib/base-compiler.js
index 25bd3c0eb..9d0af5776 100644
--- a/lib/base-compiler.js
+++ b/lib/base-compiler.js
@@ -361,6 +361,7 @@ export class BaseCompiler {
// Returns a list of additional options that may be required by some backend options.
// Meant to be overloaded by compiler classes.
+ // Called with 2 parameters: backendOptions and outputFilename.
// Default handles the GCC compiler with some debug dump enabled.
optionsForBackend(backendOptions){
const addOpts = [];
@@ -642,7 +643,7 @@ export class BaseCompiler {
let options = this.optionsForFilter(filters, outputFilename, userOptions);
backendOptions = backendOptions || {};
- options = options.concat(this.optionsForBackend(backendOptions));
+ options = options.concat(this.optionsForBackend(backendOptions, outputFilename));
if (this.compiler.options) {
options = options.concat(utils.splitArguments(this.compiler.options));
@@ -716,23 +717,8 @@ export class BaseCompiler {
};
}
- async generateRustMir(inputFilename) {
- // These arguments make Rustc produce the Rust MIR
- const execOptions = this.getDefaultExecOptions();
- // TODO: reconsider this value
- execOptions.maxOutput = 1024 ** 3;
- const mirPath = this.getRustMirOutputFilename(inputFilename);
- const rustcOptions = [
- inputFilename,
- '-o',
- mirPath,
- '--emit=mir',
- '--crate-type',
- 'rlib',
- ];
-
- const output = await this.runCompiler(this.compiler.exe, rustcOptions, this.filename(inputFilename),
- execOptions);
+ async processRustMirOutput(outputFilename, output) {
+ const mirPath = this.getRustMirOutputFilename(outputFilename);
if (output.code !== 0) {
return [{text: 'Failed to run compiler to get Rust MIR'}];
}
@@ -775,10 +761,6 @@ export class BaseCompiler {
return inputFilename.replace(path.extname(inputFilename), '.ll');
}
- getRustMirOutputFilename(inputFilename) {
- return inputFilename.replace(path.extname(inputFilename), '.mir');
- }
-
getGnatDebugOutputFilename(inputFilename) {
return inputFilename + '.dg';
}
@@ -1200,14 +1182,12 @@ export class BaseCompiler {
asmResult,
astResult,
irResult,
- rustMirResult,
rustMacroExpResult,
toolsResult,
] = await Promise.all([
this.runCompiler(this.compiler.exe, options, inputFilenameSafe, execOptions),
(makeAst ? this.generateAST(inputFilename, options) : ''),
(makeIr ? this.generateIR(inputFilename, options, filters) : ''),
- (makeRustMir ? this.generateRustMir(inputFilename, options) : ''),
(makeRustMacroExp ? this.generateRustMacroExpansion(inputFilename, options) : ''),
Promise.all(this.runToolsOfType(tools, 'independent', this.getCompilationInfo(key, {
inputFilename,
@@ -1216,7 +1196,7 @@ export class BaseCompiler {
}))),
]);
- // Both GNAT and GCC can produce their dump/expanded code files along
+ // GNAT, GCC and rustc can produce their extra output files along
// with the main compilation command.
const gnatDebugResult = (makeGnatDebug ?
await this.processGnatDebugOutput(inputFilenameSafe, asmResult)
@@ -1225,6 +1205,9 @@ export class BaseCompiler {
await this.processGccDumpOutput(backendOptions.produceGccDump,
asmResult, this.compiler.removeEmptyGccDump)
: '');
+ const rustMirResult = (makeRustMir ?
+ await this.processRustMirOutput(outputFilename, asmResult)
+ : '');
asmResult.dirPath = dirPath;
asmResult.compilationOptions = options;
diff --git a/lib/compilers/ada.js b/lib/compilers/ada.js
index 9a6fea6f8..6a93249de 100644
--- a/lib/compilers/ada.js
+++ b/lib/compilers/ada.js
@@ -46,9 +46,9 @@ export class AdaCompiler extends BaseCompiler {
return path.join(dirPath, 'example.o');
}
- optionsForBackend(backendOptions){
+ optionsForBackend(backendOptions, outputFilename){
// super is needed as it handles the GCC Dump files.
- const opts = super.optionsForBackend (backendOptions);
+ const opts = super.optionsForBackend (backendOptions, outputFilename);
if (backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugView)
opts.push('-gnatDGL');
diff --git a/lib/compilers/rust.js b/lib/compilers/rust.js
index 3072e8db4..7043b2b00 100644
--- a/lib/compilers/rust.js
+++ b/lib/compilers/rust.js
@@ -45,10 +45,22 @@ export class RustCompiler extends BaseCompiler {
this.linker = this.compilerProps('linker');
}
+ getRustMirOutputFilename(outputFilename) {
+ return outputFilename.replace(path.extname(outputFilename), '.mir');
+ }
+
getSharedLibraryPathsAsArguments() {
return [];
}
+ optionsForBackend(backendOptions, outputFilename) {
+ if (backendOptions.produceRustMir && this.compiler.supportsRustMirView) {
+ const of = this.getRustMirOutputFilename(outputFilename);
+ return ['--emit', `mir=${of}`];
+ }
+ return [];
+ }
+
optionsForFilter(filters, outputFilename, userOptions) {
let options = ['-C', 'debuginfo=1', '-o', this.filename(outputFilename)];