From a89cc7ff2832cd39ff3077f5085aba445fa3fe3b Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Tue, 21 Feb 2023 12:22:13 -0500 Subject: [PATCH] Stuff --- lib/base-compiler.ts | 21 +++++++++++++-------- lib/compilers/clangcl.ts | 3 ++- lib/compilers/ispc.ts | 3 ++- lib/compilers/pony.ts | 5 ++++- lib/compilers/spirv.ts | 3 ++- lib/compilers/win32.ts | 3 ++- lib/handlers/compile.ts | 4 ++-- static/panes/compiler.ts | 10 +++++----- types/compiler.interfaces.ts | 29 +++++++++-------------------- 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index d1032ad69..c3824c11d 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -42,7 +42,7 @@ import { LLVMOptPipelineBackendOptions, LLVMOptPipelineOutput, } from '../types/compilation/llvm-opt-pipeline-output.interfaces'; -import {CompilerInfo, ICompiler} from '../types/compiler.interfaces'; +import {CompilerInfo, ICompiler, PreliminaryCompilerInfo} from '../types/compiler.interfaces'; import { BasicExecutionResult, ExecutableExecutionOptions, @@ -80,6 +80,7 @@ import {PropertyGetter} from './properties.interfaces'; import {getToolchainPath} from './toolchain-utils'; import {ITool} from './tooling/base-tool.interface'; import * as utils from './utils'; +import {unwrap} from './assert'; const compilationTimeHistogram = new PromClient.Histogram({ name: 'ce_base_compiler_compilation_duration_seconds', @@ -126,9 +127,9 @@ export class BaseCompiler implements ICompiler { labelNames: [], }); - constructor(compilerInfo: CompilerInfo, env: CompilationEnvironment) { + constructor(compilerInfo: PreliminaryCompilerInfo, env: CompilationEnvironment) { // Information about our compiler - this.compiler = compilerInfo; + this.compiler = compilerInfo as CompilerInfo; // we'll populate later this.lang = languages[compilerInfo.lang]; if (!this.lang) { throw new Error(`Missing language info for ${compilerInfo.lang}`); @@ -891,7 +892,7 @@ export class BaseCompiler implements ICompiler { } if (this.compiler.supportsOptOutput && backendOptions.produceOptInfo) { - options = options.concat(this.compiler.optArg); + options = options.concat(unwrap(this.compiler.optArg)); } const libIncludes = this.getIncludeArguments(libraries); @@ -1042,7 +1043,9 @@ export class BaseCompiler implements ICompiler { async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) { // These options make Clang produce an IR - const newOptions = options.filter(option => option !== '-fcolor-diagnostics').concat(this.compiler.irArg); + const newOptions = options + .filter(option => option !== '-fcolor-diagnostics') + .concat(unwrap(this.compiler.irArg)); const execOptions = this.getDefaultExecOptions(); // A higher max output is needed for when the user includes headers @@ -1078,9 +1081,11 @@ export class BaseCompiler implements ICompiler { // These options make Clang produce the pass dumps const newOptions = options .filter(option => option !== '-fcolor-diagnostics') - .concat(this.compiler.llvmOptArg) - .concat(llvmOptPipelineOptions.fullModule ? this.compiler.llvmOptModuleScopeArg : []) - .concat(llvmOptPipelineOptions.noDiscardValueNames ? this.compiler.llvmOptNoDiscardValueNamesArg : []) + .concat(unwrap(this.compiler.llvmOptArg)) + .concat(llvmOptPipelineOptions.fullModule ? unwrap(this.compiler.llvmOptModuleScopeArg) : []) + .concat( + llvmOptPipelineOptions.noDiscardValueNames ? unwrap(this.compiler.llvmOptNoDiscardValueNamesArg) : [], + ) .concat(this.compiler.debugPatched ? ['-mllvm', '--debug-to-stdout'] : []); const execOptions = this.getDefaultExecOptions(); diff --git a/lib/compilers/clangcl.ts b/lib/compilers/clangcl.ts index e7224c4bc..8d8a04152 100644 --- a/lib/compilers/clangcl.ts +++ b/lib/compilers/clangcl.ts @@ -28,6 +28,7 @@ import {CompilerInfo} from '../../types/compiler.interfaces'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces'; import {Win32Compiler} from './win32'; +import {unwrap} from '../assert'; export class ClangCLCompiler extends Win32Compiler { static override get key() { @@ -47,7 +48,7 @@ export class ClangCLCompiler extends Win32Compiler { // These options make Clang produce an IR const newOptions = options .filter(option => option !== '/FA' && !option.startsWith('/Fa')) - .concat(this.compiler.irArg); + .concat(unwrap(this.compiler.irArg)); const execOptions = this.getDefaultExecOptions(); // A higher max output is needed for when the user includes headers diff --git a/lib/compilers/ispc.ts b/lib/compilers/ispc.ts index d6eb03824..15eae304d 100644 --- a/lib/compilers/ispc.ts +++ b/lib/compilers/ispc.ts @@ -31,6 +31,7 @@ import {BaseCompiler} from '../base-compiler'; import {asSafeVer} from '../utils'; import {ISPCParser} from './argument-parsers'; +import {unwrap} from '../assert'; export class ISPCCompiler extends BaseCompiler { static get key() { @@ -56,7 +57,7 @@ export class ISPCCompiler extends BaseCompiler { } override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) { - const newOptions = [...options, ...this.compiler.irArg, '-o', this.getIrOutputFilename(inputFilename)]; + const newOptions = [...options, ...unwrap(this.compiler.irArg), '-o', this.getIrOutputFilename(inputFilename)]; return super.generateIR(inputFilename, newOptions, filters); } diff --git a/lib/compilers/pony.ts b/lib/compilers/pony.ts index 5435b1f03..2577f2064 100644 --- a/lib/compilers/pony.ts +++ b/lib/compilers/pony.ts @@ -29,6 +29,7 @@ import _ from 'underscore'; import {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces'; import {BaseCompiler} from '../base-compiler'; +import {unwrap} from '../assert'; export class PonyCompiler extends BaseCompiler { static get key() { @@ -62,7 +63,9 @@ export class PonyCompiler extends BaseCompiler { } override async generateIR(inputFilename: string, options: string[], filters: ParseFiltersAndOutputOptions) { - const newOptions = _.filter(options, option => !['--pass', 'asm'].includes(option)).concat(this.compiler.irArg); + const newOptions = _.filter(options, option => !['--pass', 'asm'].includes(option)).concat( + unwrap(this.compiler.irArg), + ); const execOptions = this.getDefaultExecOptions(); // A higher max output is needed for when the user includes headers diff --git a/lib/compilers/spirv.ts b/lib/compilers/spirv.ts index 24d0f946b..6098aa825 100644 --- a/lib/compilers/spirv.ts +++ b/lib/compilers/spirv.ts @@ -33,6 +33,7 @@ import {BaseCompiler} from '../base-compiler'; import {logger} from '../logger'; import {SPIRVAsmParser} from '../parsers/asm-parser-spirv'; import * as utils from '../utils'; +import {unwrap} from '../assert'; export class SPIRVCompiler extends BaseCompiler { protected translatorPath: string; @@ -72,7 +73,7 @@ export class SPIRVCompiler extends BaseCompiler { } if (this.compiler.supportsOptOutput && backendOptions.produceOptInfo) { - options = options.concat(this.compiler.optArg); + options = options.concat(unwrap(this.compiler.optArg)); } const libIncludes = this.getIncludeArguments(libraries); diff --git a/lib/compilers/win32.ts b/lib/compilers/win32.ts index 42bf2f67a..1d448a5c0 100644 --- a/lib/compilers/win32.ts +++ b/lib/compilers/win32.ts @@ -35,6 +35,7 @@ import {MapFileReaderVS} from '../mapfiles/map-file-vs'; import {AsmParser} from '../parsers/asm-parser'; import {PELabelReconstructor} from '../pe32-support'; import * as utils from '../utils'; +import {unwrap} from '../assert'; export class Win32Compiler extends BaseCompiler { static get key() { @@ -106,7 +107,7 @@ export class Win32Compiler extends BaseCompiler { } if (this.compiler.supportsOptOutput && backendOptions.produceOptInfo) { - options = options.concat(this.compiler.optArg); + options = options.concat(unwrap(this.compiler.optArg)); } const libIncludes = this.getIncludeArguments(libraries); diff --git a/lib/handlers/compile.ts b/lib/handlers/compile.ts index da86ddd35..d466ad0ad 100644 --- a/lib/handlers/compile.ts +++ b/lib/handlers/compile.ts @@ -37,7 +37,7 @@ import {CompilerInfo, ICompiler, PreliminaryCompilerInfo} from '../../types/comp import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces'; import {BaseCompiler} from '../base-compiler'; import {CompilationEnvironment} from '../compilation-env'; -import {getCompilerTypeByKey} from '../compilers'; +import {FakeCompiler, getCompilerTypeByKey} from '../compilers'; import {logger} from '../logger'; import {PropertyGetter} from '../properties.interfaces'; import * as utils from '../utils'; @@ -190,7 +190,7 @@ export class CompileHandler { const isPrediscovered = !!compiler.version; const type = compiler.compilerType || 'default'; - let compilerClass; + let compilerClass: ReturnType; try { compilerClass = getCompilerTypeByKey(type); } catch (e) { diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index d420b4896..696d3de31 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -1152,7 +1152,7 @@ export class Compiler extends MonacoPane { + unwrap(this.compiler.disabledFilters).forEach(filter => { if (filters[filter]) { delete filters[filter]; } @@ -2556,13 +2556,13 @@ export class Compiler extends MonacoPane & {version?: string}; export interface ICompiler { @@ -143,6 +132,6 @@ export interface ICompiler { lang: Language; compile(source, options, backendOptions, filters, bypassCache, tools, executionParameters, libraries, files); cmake(files, key); - initialise(mtime: Date, clientOptions, isPrediscovered: boolean); + //initialise(mtime: Date, clientOptions, isPrediscovered: boolean); getInfo(): CompilerInfo; }