aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpartouf <partouf@gmail.com>2023-05-12 23:11:21 +0200
committerpartouf <partouf@gmail.com>2023-05-12 23:11:21 +0200
commit36ed5a2f7602077dbc2da8f4d55cb442177d7b2e (patch)
tree3331c80341bfcb20aad9d5dfe411b5ac1387d8ab
parent2f15ef464d232efe042311aee8ba306e0f1f8fa7 (diff)
downloadcompiler-explorer-gh-7376.tar.gz
compiler-explorer-gh-7376.zip
fix to bad cachinggh-7376
-rw-r--r--lib/base-compiler.ts16
-rw-r--r--lib/compilers/argument-parsers.ts15
-rw-r--r--test/compilers/argument-parsers-tests.js14
3 files changed, 28 insertions, 17 deletions
diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts
index 9e6202295..ebf0ab61d 100644
--- a/lib/base-compiler.ts
+++ b/lib/base-compiler.ts
@@ -368,7 +368,7 @@ export class BaseCompiler implements ICompiler {
return {mtime: this.mtime, compiler, args, options};
}
- protected async execCompilerCached(compiler, args, options) {
+ protected async execCompilerCached(compiler, args, options, errorsAreOk = false) {
if (this.mtime === null) {
throw new Error('Attempt to access cached compiler before initialise() called');
}
@@ -380,9 +380,23 @@ export class BaseCompiler implements ICompiler {
const key = this.getCompilerCacheKey(compiler, args, options);
let result = await this.env.compilerCacheGet(key as any);
+ if (result) {
+ if (!errorsAreOk && (result.code !== 0 || result.stderr.length > 0)) {
+ result = undefined;
+ }
+ }
if (!result) {
result = await this.env.enqueue(async () => await exec.execute(compiler, args, options));
if (result.okToCache) {
+ if (!errorsAreOk && (result.code !== 0 || result.stderr.length > 0)) {
+ const argstr = args.join(' ');
+ // eslint-disable-next-line max-len
+ logger.warn(
+ `errors are not ok for this command: ${compiler} ${argstr}, but we still got an error!`,
+ );
+ return result;
+ }
+
this.env
.compilerCachePut(key as any, result, undefined)
.then(() => {
diff --git a/lib/compilers/argument-parsers.ts b/lib/compilers/argument-parsers.ts
index da92c59f9..53425e481 100644
--- a/lib/compilers/argument-parsers.ts
+++ b/lib/compilers/argument-parsers.ts
@@ -217,7 +217,13 @@ export class ClangParser extends BaseParser {
static mllvmOptions = new Set<string>();
static override setCompilerSettingsFromOptions(compiler, options) {
- logger.debug(`clang-like compiler options: ${_.keys(options).join(' ')}`);
+ const keys = _.keys(options);
+ logger.debug(`clang-like compiler options: ${keys.join(' ')}`);
+
+ if (keys.length === 0) {
+ logger.error(`compiler options appear empty for ${compiler.compiler.id}`);
+ }
+
if (this.hasSupport(options, '-fsave-optimization-record')) {
compiler.compiler.optArg = '-fsave-optimization-record';
compiler.compiler.supportsOptOutput = true;
@@ -321,7 +327,12 @@ export class ClangParser extends BaseParser {
const EXAMPLES_PATH = props.get('builtin', 'sourcePath', './examples/');
let filename = path.join(EXAMPLES_PATH, 'c++/default.cpp');
if (!path.isAbsolute(filename)) filename = path.join(process.cwd(), filename);
- const result = await compiler.execCompilerCached(compiler.compiler.exe, this.getStdVersHelpOptions(filename));
+ const result = await compiler.execCompilerCached(
+ compiler.compiler.exe,
+ this.getStdVersHelpOptions(filename),
+ undefined,
+ true,
+ );
if (result.stderr) {
const lines = utils.splitLines(result.stderr);
diff --git a/test/compilers/argument-parsers-tests.js b/test/compilers/argument-parsers-tests.js
index bc4908f67..16ff3d8f5 100644
--- a/test/compilers/argument-parsers-tests.js
+++ b/test/compilers/argument-parsers-tests.js
@@ -143,20 +143,6 @@ describe('clang parser', () => {
]);
});
});
-
- it('should asfasfasfasfasfasfasf', () => {
- return ClangParser.parse(
- makeCompiler(
- ' -S Only run preprocess and compilation steps\n --target=<value> Generate code for the given target\n -Tbss <addr> Set starting address of BSS to <addr>\n',
- ),
- ).should.eventually.satisfy(result => {
- return Promise.all([
- result.compiler.supportsTargetIs.should.equals(true),
- result.compiler.supportsTarget.should.equals(false),
- result.compiler.supportsMarch.should.equals(false),
- ]);
- });
- });
});
describe('pascal parser', () => {