mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Fix #7539: llvm-mca falls back to autodetected arch if fails to use compilation switches
This commit is contained in:
@@ -107,6 +107,25 @@ export class LLVMMcaTool extends BaseTool {
|
||||
|
||||
const rewrittenOutputFilename = compilationInfo.outputFilename + '.mca';
|
||||
await this.writeAsmFile(utils.normalizeAsmToString(compilationInfo.asm), rewrittenOutputFilename);
|
||||
return super.runTool(compilationInfo, rewrittenOutputFilename, newArgs);
|
||||
let res = await super.runTool(compilationInfo, rewrittenOutputFilename, newArgs);
|
||||
|
||||
if (res.code !== 0) {
|
||||
if (res.stderr[0]?.text.includes('unable to get target')) {
|
||||
// The compiler's set of `--target` values is strictly larger than llvm-mca's -mtriple values.
|
||||
// Fallback: let llvm-mca use the autodetected architecture, with generic cpu.
|
||||
const newArgs2 = newArgs.filter(arg => !arg.startsWith('-mtriple='));
|
||||
res = await super.runTool(compilationInfo, rewrittenOutputFilename, newArgs2);
|
||||
|
||||
res.stdout = [
|
||||
{
|
||||
text:
|
||||
`Warning: llvm-mca was unable to use the target '${target}' specified by the compiler. ` +
|
||||
'Falling back to using the autodetected architecture with -mcpu=generic.\n\n',
|
||||
},
|
||||
...res.stdout,
|
||||
];
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user