Skip to content

Commit

Permalink
Tentative 6g support
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Feb 21, 2015
1 parent 746072c commit 4190a0b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app.js
Expand Up @@ -221,7 +221,9 @@ function configuredCompilers() {
id: name,
exe: exe,
name: props.get("gcc-explorer", base + ".name", name),
alias: props.get("gcc-explorer", base + ".alias")
alias: props.get("gcc-explorer", base + ".alias"),
versionFlag: props.get("gcc-explorer", base + ".versionFlag"),
is6g: !!props.get("gcc-explorer", base + ".is6g", false)
});
}));
}
Expand All @@ -232,7 +234,8 @@ function getCompilerInfo(compilerInfo) {
}
return new Promise(function (resolve) {
var compiler = compilerInfo.exe;
child_process.exec(compiler + ' --version', function (err, output) {
var versionFlag = compilerInfo.versionFlag || '--version';
child_process.exec(compiler + ' ' + versionFlag, function (err, output) {
if (err) return resolve(null);
var version = output.split('\n')[0];
child_process.exec(compiler + ' --target-help', function (err, output) {
Expand Down
6 changes: 5 additions & 1 deletion etc/config/gcc-explorer.amazon-go.properties
Expand Up @@ -9,7 +9,11 @@ clientGoogleAnalyticsEnabled=true
language=go
defaultCompiler=gccgo

compilers=gccgo491
compilers=gccgo491:6g141
compileFilename=file.go
compiler.gccgo491.exe=/usr/bin/gccgo
compiler.gccgo491.name=x86 gccgo 4.9.1
compiler.6g141.exe=/opt/go/pkg/tool/linux_amd64/6g
compiler.6g141.name=x86 6g 1.6.1
compiler.6g141.versionFlag=-V
compiler.6g141.is6g=true
6 changes: 5 additions & 1 deletion etc/config/gcc-explorer.lud-ldnmg01.properties
Expand Up @@ -3,11 +3,15 @@
compileTimeoutMs=5000
defaultCompiler=g46
#compilers=g44:g45:g46:clang34
compilers=go
compilers=go:6g
language=go
compileFilename=file.go
compiler.go.exe=/usr/bin/gccgo
compiler.go.name=GCC go
compiler.6g.exe=/home/mgodbolt/build/go/pkg/tool/linux_amd64/6g
compiler.6g.name=6g go
compiler.6g.versionFlag=-V
compiler.6g.is6g=true
compiler.g44.exe=/usr/bin/g++-4.4
compiler.g44.name=g++ 4.4
compiler.g44.alias=/usr/bin/g++-4.4
Expand Down
29 changes: 29 additions & 0 deletions lib/compile.js
Expand Up @@ -68,6 +68,30 @@ Compile.prototype.newTempDir = function () {
Compile.prototype.writeFile = Promise.denodeify(fs.writeFile);
Compile.prototype.stat = Promise.denodeify(fs.stat);

Compile.prototype.convert6g = function (code) {
var re = /^[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/;
var prevLine = null;
var file = null
return code.split('\n').map(function (line) {
var match = line.match(re);
if (match) {
var res = "";
if (file == null) {
res += "\t.file 1 \"" + match[1] + "\"\n";
file = match[1];
}
if (prevLine != match[2]) {
res += "\t.loc 1 " + match[2] + "\n";
prevLine = match[2];
}
return res + "\t" + match[3].toLowerCase() + match[4];
} else
return null;
}).filter(function (x) {
return x;
}).join("\n");
};

Compile.prototype.getRemote = function (compiler) {
var compilerInfo = this.compilersById[compiler];
if (!compilerInfo) return false;
Expand Down Expand Up @@ -163,6 +187,11 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
result.asm = "<Compilation failed>";
return result;
}
if (compilerInfo.is6g) {
result.asm = self.convert6g(result.stdout);
result.stdout = "";
return Promise.resolve(result);
}
return self.stat(outputFilename).then(function (stat) {
if (stat.size >= maxSize) {
result.asm = "<No output: generated assembly was too large (" + stat.size + " > " + maxSize + " bytes)>";
Expand Down

0 comments on commit 4190a0b

Please sign in to comment.