diff options
author | Kale Blankenship <kale@lemnisys.com> | 2018-11-25 17:50:12 -0800 |
---|---|---|
committer | Kale Blankenship <kale@lemnisys.com> | 2020-05-19 14:43:12 -0700 |
commit | 9fe8dcdc9a4e6c95ba34127833fff9300e564069 (patch) | |
tree | 0684490660d1c2d8cb7f571d8acb7ab6c23a270d /lib/compilers/golang.js | |
parent | e8c754d83042cab2adc0b67fc05b9e0c0879be83 (diff) | |
download | compiler-explorer-9fe8dcdc9a4e6c95ba34127833fff9300e564069.tar.gz compiler-explorer-9fe8dcdc9a4e6c95ba34127833fff9300e564069.zip |
Go: Add additional architectures
Use 'go build' instead of 'go tool compile' to more easily support
additional architectures.
Diffstat (limited to 'lib/compilers/golang.js')
-rw-r--r-- | lib/compilers/golang.js | 33 |
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; } |