Add checks for config problems (#5208)

Fixes #4947. I could not find existing checks, so I added something in
the compiler finder. The implementation is not as elegant as I'd hoped,
but it gets the job done.
This commit is contained in:
Jeremy Rifkin
2023-07-09 17:36:21 -04:00
committed by Matt Godbolt
parent 9fa6981b5f
commit 585ed08057
6 changed files with 104 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
# Default settings for cppx-gold
compilers=&clang
compilers=&gcc
group.gcc.compilers=golddefault
compiler.golddefault.exe=/usr/bin/clang-gold

View File

@@ -7,7 +7,7 @@ compilerType=fortran
###############################
# GCC for x86
group.gfortran_86.compilers=gfortran412:gfortran447:gfortran453:gfortran464:gfortran471:gfortran472:gfortran473:gfortran474:gfortran481:gfortran482:gfortran483:gfortran484:gfortran485:gfortran490:gfortran491:gfortran492:gfortran493:gfortran494def:gfortran48:gfortran510:gfortran520:gfortran530:gfortran540:gfortran550def:gfortran5:gfortran62:gfortran63def:gfortran6:gfortran71def:gfortran72def:gfortran73def:gfortran7:gfortran8:gfortran81def:gfortran9:gfortran10:gfortran11:gfortran
group.gfortran_86.compilers=gfortran412:gfortran447:gfortran453:gfortran464:gfortran471:gfortran472:gfortran473:gfortran474:gfortran481:gfortran482:gfortran483:gfortran484:gfortran485:gfortran490:gfortran491:gfortran492:gfortran493:gfortran494def:gfortran48:gfortran4:gfortran510:gfortran520:gfortran530:gfortran540:gfortran550def:gfortran5:gfortran62:gfortran63def:gfortran6:gfortran71def:gfortran72def:gfortran73def:gfortran7:gfortran8:gfortran81def:gfortran9:gfortran10:gfortran11:gfortran
group.gfortran_86.groupName=GCC x86-64
compiler.gfortran412.exe=/usr/bin/gfortran-4.1.2
compiler.gfortran412.name=gfortran 4.1.2

View File

@@ -12,8 +12,8 @@ compiler.rga_default.dxcPath=/usr/dxc-artifacts/bin/dxc
group.clang.compilers=hlsl_clang_default
group.clang.compilerType=clang
compiler.clang.exe=/usr/bin/clang-trunk
compiler.clang.options=-emit-llvm
compiler.hlsl_clang_default.exe=/usr/bin/clang-trunk
compiler.hlsl_clang_default.options=-emit-llvm
defaultCompiler=dxc
supportsBinary=false

View File

@@ -9,7 +9,7 @@ supportsBinaryObject=true
binaryHideFuncRe=^(__.*|_(init|start|fini)|(de)?register_tm_clones|call_gmon_start|frame_dummy|\.plt.*)$
supportsLibraryCodeFilter=true
group.gcc.compilers=cgdefault
compiler.cgdefault.exe=/usr/bin/gm2
compiler.cgdefault.name=gcc default
group.gcc.compilers=m2gdefault
compiler.m2gdefault.exe=/usr/bin/gm2
compiler.m2gdefault.name=gcc default

View File

@@ -34,12 +34,12 @@ import urljoin from 'url-join';
import type {CompilerInfo, PreliminaryCompilerInfo} from '../types/compiler.interfaces.js';
import type {Language, LanguageKey} from '../types/languages.interfaces.js';
import {unwrap, assert} from './assert.js';
import {unwrap, assert, unwrapString} from './assert.js';
import {InstanceFetcher} from './aws.js';
import {CompileHandler} from './handlers/compile.js';
import {logger} from './logger.js';
import {ClientOptionsHandler} from './options-handler.js';
import {CompilerProps} from './properties.js';
import {CompilerProps, getRawProperties} from './properties.js';
import type {PropertyGetter} from './properties.interfaces.js';
import {basic_comparator, remove} from '../shared/common-utils.js';
import {getPossibleGccToolchainsFromCompilerInfo} from './toolchain-utils.js';
@@ -60,6 +60,7 @@ export class CompilerFinder {
languages: Record<string, Language>;
awsPoller: InstanceFetcher | null = null;
optionsHandler: ClientOptionsHandler;
//visitedCompilers = new Set<string>();
constructor(
compileHandler: CompileHandler,
@@ -471,7 +472,97 @@ export class CompilerFinder {
}
}
checkOrphanedProperties() {
// Quickly check for any orphaned compilers
let error = false;
for (const domains of [
['amazon', 'amazonwin', 'gpu'],
['defaults', 'local'],
]) {
const compilers = new Set<string>();
// duplicate groups across languages is ok, so storing lang.group in the set
const groups = new Set<string>();
const reachableCompilers = new Set<string>();
const reachableGroups = new Set<string>();
const rawProps = getRawProperties();
for (const [prop, props] of Object.entries(rawProps)) {
const [lang, domain] = prop.split('.');
if (domains.includes(domain)) {
if (domain === 'defaults' && `${lang}.local` in rawProps) {
continue; // let .local override
}
for (const [prop, value] of Object.entries(props)) {
const propParts = prop.split('.');
if (prop === 'compilers') {
for (const compiler of unwrapString(value).split(':')) {
if (compiler.startsWith('&')) {
reachableGroups.add(`${lang}.${compiler.slice(1)}`);
} else {
reachableCompilers.add(compiler);
}
}
}
if (propParts[0] === 'group') {
if (propParts[2] === 'compilers') {
// should appear exactly once
const fullGroup = `${lang}.${propParts[1]}`;
if (groups.has(fullGroup)) {
const [lang, realGroup] = fullGroup.split('.');
logger.error(
`Duplicate group id ${realGroup} for ${lang} in domain ${domains.join(',')}`,
);
error = true;
}
groups.add(fullGroup);
for (const compiler of unwrapString(value).split(':')) {
if (compiler.startsWith('&')) {
reachableGroups.add(`${lang}.${compiler.slice(1)}`);
} else {
reachableCompilers.add(compiler);
}
}
}
}
if (propParts[0] === 'compiler') {
if (propParts[2] === 'exe') {
// should appear exactly once
if (compilers.has(propParts[1])) {
logger.error(
`Duplicate compiler id ${propParts[1]} in domain ${domains.join(',')}`,
);
error = true;
}
compilers.add(propParts[1]);
}
}
}
}
}
for (const group of groups) {
if (!reachableGroups.has(group)) {
const [lang, realGroup] = group.split('.');
logger.error(
`Group ${realGroup} is orphaned from the language compilers list for ` +
`${lang} in domain ${domains.join(',')}`,
);
error = true;
}
}
for (const compiler of compilers) {
if (!reachableCompilers.has(compiler)) {
logger.error(`Compiler ${compiler} is not part of any group in domain ${domains.join(',')}`);
error = true;
}
}
}
if (error) {
assert(false);
}
}
async find() {
this.checkOrphanedProperties();
const compilerList = await this.getCompilers();
const toolchains = await getPossibleGccToolchainsFromCompilerInfo(compilerList);

View File

@@ -282,3 +282,7 @@ export function setDebug(debug: boolean) {
export function fakeProps(fake: Record<string, PropertyValue>): PropertyGetter {
return (prop, def) => (fake[prop] === undefined ? def : fake[prop]);
}
export function getRawProperties() {
return properties;
}