aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/golang.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers/golang.js')
-rw-r--r--lib/compilers/golang.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js
index 196cf8b02..ea9bb6fc5 100644
--- a/lib/compilers/golang.js
+++ b/lib/compilers/golang.js
@@ -164,33 +164,52 @@ class GolangCompiler extends BaseCompiler {
}
extractLogging(stdout) {
- const reLogging = /^<source>:([0-9]*):([0-9]*):\s(.*)/i;
+ let filepath = `./${this.compileFilename}`;
+ const reLogging = new RegExp(`^${filepath}:([0-9]*):([0-9]*):\\s(.*)`, 'i');
return stdout.filter(obj => obj.text.match(reLogging))
- .map(obj => obj.text)
+ .map(obj => obj.text.replace(filepath, '<source>'))
.join('\n');
}
async postProcess(result) {
- const logging = this.extractLogging(result.stdout);
- result.asm = this.convertNewGoL(result.stdout);
+ let out = result.stderr;
+ if (this.compiler.id === '6g141') {
+ out = result.stdout;
+ }
+ const logging = this.extractLogging(out);
+ result.asm = this.convertNewGoL(out);
+ result.stderr = null;
result.stdout = utils.parseOutput(logging, result.inputFilename);
return [result, ""];
}
- optionsForFilter(filters, outputFilename) {
+ optionsForFilter(filters, outputFilename, userOptions) {
// If we're dealing with an older version...
if (this.compiler.id === '6g141') {
return ['tool', '6g', '-g', '-o', outputFilename, '-S'];
}
- return ['tool', 'compile', '-o', outputFilename, '-S'];
+ // Add userOptions to -gcflags to preserve previous behavior.
+ return ['build', '-o', outputFilename, '-gcflags', '-S ' + userOptions.join(' ')];
+ }
+
+ filterUserOptions(userOptions) {
+ if (this.compiler.id === '6g141') {
+ return userOptions;
+ }
+ // userOptions are added to -gcflags in optionsForFilter
+ return [];
}
getDefaultExecOptions() {
const execOptions = super.getDefaultExecOptions();
- const goroot = this.compilerProps("compiler." + this.compiler.id + ".goroot");
+ const goroot = this.compilerProps(`compiler.${this.compiler.id}.goroot`);
if (goroot) {
execOptions.env.GOROOT = goroot;
}
+ const goarch = this.compilerProps(`compiler.${this.compiler.id}.goarch`);
+ if (goarch) {
+ execOptions.env.GOARCH = goarch;
+ }
return execOptions;
}