|
|
|
@ -68,7 +68,7 @@ function Compile(compilers) {
|
|
|
|
|
this.cache = LRU({
|
|
|
|
|
max: gccProps('cacheMb') * 1024 * 1024,
|
|
|
|
|
length: function (n) {
|
|
|
|
|
return n.asm.length;
|
|
|
|
|
return JSON.stringify(n).length;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.cacheHits = 0;
|
|
|
|
@ -149,8 +149,8 @@ Compile.prototype.runCompiler = function (compiler, options) {
|
|
|
|
|
});
|
|
|
|
|
child.on('exit', function (code) {
|
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
// TODO: why is this apparently needed in the getMultiarch case?
|
|
|
|
|
// without it, I apparently get stdout/stderr callbacks *after* the exit
|
|
|
|
|
// Why is this apparently needed in some cases (e.g. when I used to use this to do getMultiarch)?
|
|
|
|
|
// Without it, I apparently get stdout/stderr callbacks *after* the exit...
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
resolve({code: code, stdout: stdout, stderr: stderr, okToCache: okToCache});
|
|
|
|
|
}, 0);
|
|
|
|
@ -160,21 +160,19 @@ Compile.prototype.runCompiler = function (compiler, options) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Compile.prototype.getMultiarch = function () {
|
|
|
|
|
// TODO; force caller to block until this is done...
|
|
|
|
|
return this.runCompiler("gcc", ["-print-multiarch"])
|
|
|
|
|
.then(function (obj) {
|
|
|
|
|
if (obj.code === 0) {
|
|
|
|
|
var multi = obj.stdout.trim();
|
|
|
|
|
console.log("Multiarch: " + obj.stdout.trim());
|
|
|
|
|
process.env.LIBRARY_PATH = '/usr/lib/' + multi;
|
|
|
|
|
process.env.C_INCLUDE_PATH = '/usr/include/' + multi;
|
|
|
|
|
process.env.CPLUS_INCLUDE_PATH = '/usr/include/' + multi;
|
|
|
|
|
} else {
|
|
|
|
|
console.log("Unable to get multiarch: " + err);
|
|
|
|
|
}
|
|
|
|
|
}, function (err) {
|
|
|
|
|
console.log("Unable to get multiarch: " + err);
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
var multi = child_process.execSync("gcc -print-multiarch").toString().trim();
|
|
|
|
|
if (multi) {
|
|
|
|
|
console.log("Multiarch: " + multi);
|
|
|
|
|
process.env.LIBRARY_PATH = '/usr/lib/' + multi;
|
|
|
|
|
process.env.C_INCLUDE_PATH = '/usr/include/' + multi;
|
|
|
|
|
process.env.CPLUS_INCLUDE_PATH = '/usr/include/' + multi;
|
|
|
|
|
} else {
|
|
|
|
|
console.log("No multiarch");
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.log("Unable to get multiarch: " + err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Compile.prototype.objdump = function (outputFilename, result, maxSize, intelAsm) {
|
|
|
|
@ -332,7 +330,9 @@ Compile.prototype.checkSource = function (source) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Compile.prototype.cacheStats = function () {
|
|
|
|
|
console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses");
|
|
|
|
|
var pc = (100 * this.cacheHits) / (this.cacheMisses + this.cacheHits);
|
|
|
|
|
console.log("Cache stats: " + this.cacheHits + " hits, " + this.cacheMisses + " misses (" + pc.toFixed(2) +
|
|
|
|
|
"%), LRU has " + this.cache.itemCount + " item(s) totalling " + this.cache.length + " bytes");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function compileHandler(compilers) {
|
|
|
|
|