diff options
-rw-r--r-- | etc/config/fortran.amazon.properties | 4 | ||||
-rw-r--r-- | lib/base-compiler.ts | 112 | ||||
-rw-r--r-- | lib/compilers/assembly.ts | 5 | ||||
-rw-r--r-- | lib/compilers/clean.ts | 10 | ||||
-rw-r--r-- | lib/compilers/dart.ts | 3 | ||||
-rw-r--r-- | lib/compilers/dosbox-compiler.ts | 2 | ||||
-rw-r--r-- | lib/compilers/fortran.ts | 48 | ||||
-rw-r--r-- | lib/compilers/spirv.ts | 5 | ||||
-rw-r--r-- | lib/compilers/win32.ts | 2 | ||||
-rw-r--r-- | lib/utils.ts | 14 |
10 files changed, 139 insertions, 66 deletions
diff --git a/etc/config/fortran.amazon.properties b/etc/config/fortran.amazon.properties index fb2d6f9b4..18578aff4 100644 --- a/etc/config/fortran.amazon.properties +++ b/etc/config/fortran.amazon.properties @@ -838,12 +838,14 @@ libs.curl.versions.7831.path=/opt/compiler-explorer/libs/curl/7.83.1/include libs.http_client.name=http-client libs.http_client.url=https://github.com/fortran-lang/http-client +libs.http_client.staticliblink=http libs.http_client.versions=010 libs.http_client.packagedheaders=true libs.http_client.versions.010.version=0.1.0 libs.json_fortran.name=json-fortran libs.json_fortran.url=https://github.com/jacobwilliams/json-fortran +libs.json_fortran.staticliblink=json-fortran libs.json_fortran.versions=830 libs.json_fortran.packagedheaders=true libs.json_fortran.versions.830.version=8.3.0 @@ -851,6 +853,8 @@ libs.json_fortran.versions.830.version=8.3.0 libs.forcompile.name=ForCompile libs.forcompile.url=https://github.com/gha3mi/forcompile libs.forcompile.description=A Fortran library to access the Compiler Explorer API +libs.forcompile.staticliblink=forcompile +libs.forcompile.dependencies=json_fortran:http_client:curl-d libs.forcompile.versions=trunk libs.forcompile.packagedheaders=true libs.forcompile.versions.trunk.version=trunk diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index 3c1be64ff..e239a4549 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -108,6 +108,7 @@ import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js'; import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js'; import {unique} from '../shared/common-utils.js'; import {ClientOptionsType, OptionsHandlerLibrary, VersionInfo} from './options-handler.js'; +import {propsFor} from './properties.js'; const compilationTimeHistogram = new PromClient.Histogram({ name: 'ce_base_compiler_compilation_duration_seconds', @@ -172,6 +173,8 @@ export class BaseCompiler implements ICompiler { protected externalparser: null | ExternalParserBase; protected supportedLibraries?: Record<string, Library>; protected packager: Packager; + protected executionType: string; + protected sandboxType: string; protected defaultRpathFlag: string = '-Wl,-rpath,'; private static objdumpAndParseCounter = new PromClient.Counter({ name: 'ce_objdumpandparsetime_total', @@ -211,6 +214,10 @@ export class BaseCompiler implements ICompiler { this.compiler.disabledFilters = (this.compiler.disabledFilters as any).split(','); } + const execProps = propsFor('execution'); + this.executionType = execProps('executionType', 'none'); + this.sandboxType = execProps('sandboxType', 'none'); + this.asm = new AsmParser(this.compilerProps); const irDemangler = new LLVMIRDemangler(this.compiler.demangler, this); this.llvmIr = new LlvmIrParser(this.compilerProps, irDemangler); @@ -395,10 +402,11 @@ export class BaseCompiler implements ICompiler { if (this.mtime === null) { throw new Error('Attempt to access cached compiler before initialise() called'); } + if (!options) { options = this.getDefaultExecOptions(); options.timeoutMs = 0; - options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); + options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([], undefined); } // Take a (shallow) copy of the options before we add a random customCwd: The fact we have createAndUseTempDir @@ -836,7 +844,7 @@ export class BaseCompiler implements ICompiler { return sortedlinks; } - getStaticLibraryLinks(libraries: CompileChildLibraries[]) { + getStaticLibraryLinks(libraries: CompileChildLibraries[], libPaths: string[] = []) { const linkFlag = this.compiler.linkFlag || '-l'; return this.getSortedStaticLibraries(libraries) @@ -864,25 +872,26 @@ export class BaseCompiler implements ICompiler { .filter(link => link) as string[]; } - getSharedLibraryPaths(libraries: CompileChildLibraries[]) { + getSharedLibraryPaths(libraries: CompileChildLibraries[], dirPath?: string): string[] { return libraries .map(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); if (!foundVersion) return false; const paths = [...foundVersion.libpath]; - if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot) { - paths.push(`/app/${selectedLib.id}/lib`); + if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot && dirPath) { + paths.push(path.join(dirPath, selectedLib.id, 'lib')); } return paths; }) - .flat(); + .flat() as string[]; } protected getSharedLibraryPathsAsArguments( libraries: CompileChildLibraries[], - libDownloadPath?: string, - toolchainPath?: string, + libDownloadPath: string | undefined, + toolchainPath: string | undefined, + dirPath: string, ) { const pathFlag = this.compiler.rpathFlag || this.defaultRpathFlag; const libPathFlag = this.compiler.libpathFlag || '-L'; @@ -901,12 +910,12 @@ export class BaseCompiler implements ICompiler { [pathFlag + libDownloadPath], this.compiler.libPath.map(path => pathFlag + path), toolchainLibraryPaths.map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => pathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => libPathFlag + path), ) as string[]; } - protected getSharedLibraryPathsAsLdLibraryPaths(libraries) { + protected getSharedLibraryPathsAsLdLibraryPaths(libraries, dirPath: string | undefined) { let paths = ''; if (!this.alwaysResetLdPath) { paths = process.env.LD_LIBRARY_PATH || ''; @@ -914,11 +923,11 @@ export class BaseCompiler implements ICompiler { return _.union( paths.split(path.delimiter).filter(p => !!p), this.compiler.ldPath, - this.getSharedLibraryPaths(libraries), + this.getSharedLibraryPaths(libraries, dirPath), ) as string[]; } - getSharedLibraryPathsAsLdLibraryPathsForExecution(libraries) { + getSharedLibraryPathsAsLdLibraryPathsForExecution(libraries, dirPath: string) { let paths = ''; if (!this.alwaysResetLdPath) { paths = process.env.LD_LIBRARY_PATH || ''; @@ -927,11 +936,11 @@ export class BaseCompiler implements ICompiler { paths.split(path.delimiter).filter(p => !!p), this.compiler.ldPath, this.compiler.libPath, - this.getSharedLibraryPaths(libraries), + this.getSharedLibraryPaths(libraries, dirPath), ); } - getIncludeArguments(libraries: SelectedLibraryVersion[]): string[] { + getIncludeArguments(libraries: SelectedLibraryVersion[], dirPath: string): string[] { const includeFlag = this.compiler.includeFlag || '-I'; return libraries.flatMap(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); @@ -939,7 +948,8 @@ export class BaseCompiler implements ICompiler { const paths = foundVersion.path.map(path => includeFlag + path); if (foundVersion.packagedheaders) { - paths.push(includeFlag + `/app/${selectedLib.id}/include`); + const includePath = path.join(dirPath, selectedLib.id, 'include'); + paths.push(includeFlag + includePath); } return paths; }); @@ -1086,16 +1096,20 @@ export class BaseCompiler implements ICompiler { const toolchainPath = this.getDefaultOrOverridenToolchainPath(backendOptions.overrides || []); - const libIncludes = this.getIncludeArguments(libraries); + const dirPath = path.dirname(inputFilename); + + const libIncludes = this.getIncludeArguments(libraries, dirPath); const libOptions = this.getLibraryOptions(libraries); let libLinks: string[] = []; let libPaths: string[] = []; + let libPathsAsFlags: string[] = []; let staticLibLinks: string[] = []; if (filters.binary) { libLinks = (this.getSharedLibraryLinks(libraries).filter(l => l) as string[]) || []; - libPaths = this.getSharedLibraryPathsAsArguments(libraries, undefined, toolchainPath); - staticLibLinks = (this.getStaticLibraryLinks(libraries).filter(l => l) as string[]) || []; + libPathsAsFlags = this.getSharedLibraryPathsAsArguments(libraries, undefined, toolchainPath, dirPath); + libPaths = this.getSharedLibraryPaths(libraries, dirPath); + staticLibLinks = (this.getStaticLibraryLinks(libraries, libPaths).filter(l => l) as string[]) || []; } userOptions = this.filterUserOptions(userOptions) || []; @@ -1107,7 +1121,7 @@ export class BaseCompiler implements ICompiler { inputFilename, libIncludes, libOptions, - libPaths, + libPathsAsFlags, libLinks, userOptions, staticLibLinks, @@ -1636,6 +1650,18 @@ export class BaseCompiler implements ICompiler { return this.runCompiler(compiler, options, inputFilename, execOptions); } + protected maskArgumentsForCompilation(args: string[]): string[] { + if (this.executionType === 'nsjail' || this.executionType === 'cewrapper') { + const maskedArgs: string[] = []; + for (const arg of args) { + maskedArgs.push(utils.simplifyRootdirInArgs(arg)); + } + return maskedArgs; + } else { + return args; + } + } + async getRequiredLibraryVersions(libraries): Promise<Record<string, LibraryVersion>> { const libraryDetails = {}; _.each(libraries, selectedLib => { @@ -1753,7 +1779,7 @@ export class BaseCompiler implements ICompiler { ); const execOptions = this.getDefaultExecOptions(); - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries); + execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries, dirPath); this.applyOverridesToExecOptions(execOptions, overrides); @@ -1763,7 +1789,7 @@ export class BaseCompiler implements ICompiler { ...result, downloads, executableFilename: outputFilename, - compilationOptions: compilerArguments, + compilationOptions: this.maskArgumentsForCompilation(compilerArguments), }; } @@ -1936,7 +1962,10 @@ export class BaseCompiler implements ICompiler { }; } - executeParameters.ldPath = this.getSharedLibraryPathsAsLdLibraryPathsForExecution(key.libraries); + executeParameters.ldPath = this.getSharedLibraryPathsAsLdLibraryPathsForExecution( + key.libraries, + buildResult.dirPath, + ); const result = await this.runExecutable(buildResult.executableFilename, executeParameters, buildResult.dirPath); return { ...result, @@ -2064,6 +2093,8 @@ export class BaseCompiler implements ICompiler { const overrides = this.sanitizeCompilerOverrides(backendOptions.overrides || []); + const downloads = await this.setupBuildEnvironment(key, dirPath, filters.binary || filters.binaryObject); + options = _.compact( this.prepareArguments( options, @@ -2077,7 +2108,7 @@ export class BaseCompiler implements ICompiler { ); const execOptions = this.getDefaultExecOptions(); - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); + execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([], dirPath); this.applyOverridesToExecOptions(execOptions, overrides); @@ -2096,7 +2127,6 @@ export class BaseCompiler implements ICompiler { const makeGccDump = backendOptions.produceGccDump && backendOptions.produceGccDump.opened && this.compiler.supportsGccDump; - const downloads = await this.setupBuildEnvironment(key, dirPath, filters.binary || filters.binaryObject); const [ asmResult, astResult, @@ -2163,7 +2193,7 @@ export class BaseCompiler implements ICompiler { : ''; asmResult.dirPath = dirPath; - if (!asmResult.compilationOptions) asmResult.compilationOptions = options; + if (!asmResult.compilationOptions) asmResult.compilationOptions = this.maskArgumentsForCompilation(options); asmResult.downloads = downloads; // Here before the check to ensure dump reports even on failure cases if (this.compiler.supportsGccDump && gccDumpResult) { @@ -2290,7 +2320,7 @@ export class BaseCompiler implements ICompiler { async doBuildstepAndAddToResult(result, name, command, args, execParams): Promise<BuildStep> { const stepResult: BuildStep = { ...(await this.doBuildstep(command, args, execParams)), - compilationOptions: args, + compilationOptions: this.maskArgumentsForCompilation(args), step: name, }; logger.debug(name); @@ -2306,7 +2336,7 @@ export class BaseCompiler implements ICompiler { ) { const cmakeExecParams = Object.assign({}, execParams); - const libIncludes = this.getIncludeArguments(libsAndOptions.libraries); + const libIncludes = this.getIncludeArguments(libsAndOptions.libraries, dirPath); const options: string[] = []; if (this.compiler.options) { @@ -2321,7 +2351,12 @@ export class BaseCompiler implements ICompiler { cmakeExecParams.ldPath = [dirPath]; // todo: if we don't use nsjail, the path should not be /app but dirPath - const libPaths = this.getSharedLibraryPathsAsArguments(libsAndOptions.libraries, '/app', toolchainPath); + const libPaths = this.getSharedLibraryPathsAsArguments( + libsAndOptions.libraries, + '/app', + toolchainPath, + dirPath, + ); cmakeExecParams.env.LDFLAGS = libPaths.join(' '); return cmakeExecParams; @@ -2385,18 +2420,12 @@ export class BaseCompiler implements ICompiler { const toolchainPath = this.getDefaultOrOverridenToolchainPath(key.backendOptions.overrides || []); - const doExecute = key.filters.execute; - const executeParameters: ExecutableExecutionOptions = { - ldPath: this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries), - args: key.executionParameters.args || [], - stdin: key.executionParameters.stdin || '', - env: {}, - }; - const cacheKey = this.getCmakeCacheKey(key, files); const dirPath = await this.newTempDir(); + const doExecute = key.filters.execute; + const outputFilename = this.getExecutableFilename(path.join(dirPath, 'build'), this.outputFilebase, key); let fullResult = !bypassExecutionCache(bypassCache) @@ -2507,6 +2536,13 @@ export class BaseCompiler implements ICompiler { fullResult.result.dirPath = dirPath; if (this.compiler.supportsExecute && doExecute) { + const executeParameters: ExecutableExecutionOptions = { + ldPath: this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries, dirPath), + args: key.executionParameters.args || [], + stdin: key.executionParameters.stdin || '', + env: {}, + }; + fullResult.execResult = await this.runExecutable(outputFilename, executeParameters, dirPath); fullResult.didExecute = true; } @@ -3107,7 +3143,7 @@ but nothing was dumped. Possible causes are: const execOptions = this.getDefaultExecOptions(); const versionFlag = this.compiler.versionFlag || ['--version']; execOptions.timeoutMs = 0; // No timeout for --version. A sort of workaround for slow EFS/NFS on the prod site - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); + execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([], undefined); try { return await this.execCompilerCached(this.compiler.exe, versionFlag, execOptions); diff --git a/lib/compilers/assembly.ts b/lib/compilers/assembly.ts index ff08ffee3..0ef165840 100644 --- a/lib/compilers/assembly.ts +++ b/lib/compilers/assembly.ts @@ -157,10 +157,11 @@ export class AssemblyCompiler extends BaseCompiler { ), ); + const downloads = await buildEnvironment; + const execOptions = this.getDefaultExecOptions(); - execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries); + execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths(key.libraries, dirPath); - const downloads = await buildEnvironment; const result = await this.buildExecutable(key.compiler.exe, compilerArguments, inputFilename, execOptions); const fullResult: BuildResult = { diff --git a/lib/compilers/clean.ts b/lib/compilers/clean.ts index 43d8a0c6f..169b964ea 100644 --- a/lib/compilers/clean.ts +++ b/lib/compilers/clean.ts @@ -27,10 +27,8 @@ import path from 'path'; import fs from 'fs-extra'; import type {ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; -import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {BaseCompiler} from '../base-compiler.js'; -import {propsFor} from '../properties.js'; import * as utils from '../utils.js'; export class CleanCompiler extends BaseCompiler { @@ -38,14 +36,6 @@ export class CleanCompiler extends BaseCompiler { return 'clean'; } - executionType: string; - - constructor(compiler: PreliminaryCompilerInfo, env) { - super(compiler, env); - const execProps = propsFor('execution'); - this.executionType = execProps('executionType', 'none'); - } - override optionsForFilter(filters: ParseFiltersAndOutputOptions) { if (filters.binary) { return []; diff --git a/lib/compilers/dart.ts b/lib/compilers/dart.ts index de67ec8b9..a3a6d578a 100644 --- a/lib/compilers/dart.ts +++ b/lib/compilers/dart.ts @@ -29,6 +29,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in import {BaseCompiler} from '../base-compiler.js'; import {DartAsmParser} from '../parsers/asm-parser-dart.js'; import * as utils from '../utils.js'; +import * as path from 'path'; import {BaseParser} from './argument-parsers.js'; import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js'; @@ -58,7 +59,7 @@ export class DartCompiler extends BaseCompiler { options = options.concat(utils.splitArguments(this.compiler.options)); } - const libIncludes = this.getIncludeArguments(libraries); + const libIncludes = this.getIncludeArguments(libraries, path.dirname(inputFilename)); const libOptions = this.getLibraryOptions(libraries); userOptions = this.filterUserOptions(userOptions) || []; diff --git a/lib/compilers/dosbox-compiler.ts b/lib/compilers/dosbox-compiler.ts index b4b08c716..73067573b 100644 --- a/lib/compilers/dosbox-compiler.ts +++ b/lib/compilers/dosbox-compiler.ts @@ -106,7 +106,7 @@ export class DosboxCompiler extends BaseCompiler { if (!options) { options = this.getDefaultExecOptions(); options.timeoutMs = 0; - options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); + options.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([], undefined); } const key = this.getCompilerCacheKey(compiler, args, options); diff --git a/lib/compilers/fortran.ts b/lib/compilers/fortran.ts index d69fbacdb..bc1fbf69a 100644 --- a/lib/compilers/fortran.ts +++ b/lib/compilers/fortran.ts @@ -34,6 +34,7 @@ import * as utils from '../utils.js'; import {GccFortranParser} from './argument-parsers.js'; import {SelectedLibraryVersion} from '../../types/libraries/libraries.interfaces.js'; import _ from 'underscore'; +import * as fs from 'fs'; export class FortranCompiler extends BaseCompiler { static get key() { @@ -48,22 +49,44 @@ export class FortranCompiler extends BaseCompiler { return 'Change the Fortran standard version of the compiler.'; } - override getSharedLibraryPaths(libraries: CompileChildLibraries[]) { + getExactStaticLibNameAndPath(lib: string, libPaths: string[]): string { + const libFilename = 'lib' + lib + '.a'; + + // note: fortran doesn't use -llibname, + // you have to add the full filename to the commandline instead + // this thus requires the libraries to be downloaded before we can figure out the compiler arguments + for (const dir of libPaths) { + const testpath = path.join(dir, libFilename); + if (fs.existsSync(testpath)) { + return testpath; + } + } + + return ''; + } + + override getStaticLibraryLinks(libraries: CompileChildLibraries[], libPaths: string[] = []) { + return this.getSortedStaticLibraries(libraries) + .filter(lib => lib) + .map(lib => this.getExactStaticLibNameAndPath(lib, libPaths)); + } + + override getSharedLibraryPaths(libraries: CompileChildLibraries[], dirPath?: string): string[] { return libraries .map(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); if (!foundVersion) return false; const paths = [...foundVersion.libpath]; - if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot) { - paths.push(`/app/${selectedLib.id}/lib`); + if (this.buildenvsetup && !this.buildenvsetup.extractAllToRoot && dirPath) { + paths.push(path.join(dirPath, selectedLib.id, 'lib')); } return paths; }) - .flat(); + .flat() as string[]; } - override getIncludeArguments(libraries: SelectedLibraryVersion[]): string[] { + override getIncludeArguments(libraries: SelectedLibraryVersion[], dirPath: string): string[] { const includeFlag = this.compiler.includeFlag || '-I'; return libraries.flatMap(selectedLib => { const foundVersion = this.findLibVersion(selectedLib); @@ -71,8 +94,10 @@ export class FortranCompiler extends BaseCompiler { const paths = foundVersion.path.map(path => includeFlag + path); if (foundVersion.packagedheaders) { - paths.push(`-I/app/${selectedLib.id}/mod`); - paths.push(includeFlag + `/app/${selectedLib.id}/include`); + const modPath = path.join(dirPath, selectedLib.id, 'mod'); + const includePath = path.join(dirPath, selectedLib.id, 'include'); + paths.push(`-I${modPath}`); + paths.push(includeFlag + includePath); } return paths; }); @@ -80,8 +105,9 @@ export class FortranCompiler extends BaseCompiler { override getSharedLibraryPathsAsArguments( libraries: CompileChildLibraries[], - libDownloadPath?: string, - toolchainPath?: string, + libDownloadPath: string, + toolchainPath: string, + dirPath: string, ) { const pathFlag = this.compiler.rpathFlag || this.defaultRpathFlag; const libPathFlag = this.compiler.libpathFlag || '-L'; @@ -100,8 +126,8 @@ export class FortranCompiler extends BaseCompiler { [pathFlag + libDownloadPath], this.compiler.libPath.map(path => pathFlag + path), toolchainLibraryPaths.map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => pathFlag + path), - this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => pathFlag + path), + this.getSharedLibraryPaths(libraries, dirPath).map(path => libPathFlag + path), ) as string[]; } diff --git a/lib/compilers/spirv.ts b/lib/compilers/spirv.ts index a709a43f8..c2b7fa1c5 100644 --- a/lib/compilers/spirv.ts +++ b/lib/compilers/spirv.ts @@ -79,7 +79,8 @@ export class SPIRVCompiler extends BaseCompiler { options = options.concat(unwrap(this.compiler.optArg)); } - const libIncludes = this.getIncludeArguments(libraries); + const dirPath = path.dirname(inputFilename); + const libIncludes = this.getIncludeArguments(libraries, dirPath); const libOptions = this.getLibraryOptions(libraries); let libLinks: string[] = []; let libPaths: string[] = []; @@ -87,7 +88,7 @@ export class SPIRVCompiler extends BaseCompiler { if (filters.binary) { libLinks = this.getSharedLibraryLinks(libraries); - libPaths = this.getSharedLibraryPathsAsArguments(libraries); + libPaths = this.getSharedLibraryPathsAsArguments(libraries, undefined, undefined, dirPath); staticLibLinks = this.getStaticLibraryLinks(libraries); } diff --git a/lib/compilers/win32.ts b/lib/compilers/win32.ts index 8f2cff314..9c793523b 100644 --- a/lib/compilers/win32.ts +++ b/lib/compilers/win32.ts @@ -116,7 +116,7 @@ export class Win32Compiler extends BaseCompiler { options = options.concat(unwrap(this.compiler.optArg)); } - const libIncludes = this.getIncludeArguments(libraries); + const libIncludes = this.getIncludeArguments(libraries, path.dirname(inputFilename)); const libOptions = this.getLibraryOptions(libraries); let libLinks: any[] = []; let libPaths: string[] = []; diff --git a/lib/utils.ts b/lib/utils.ts index 536c4d05a..db5e5c762 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -74,6 +74,20 @@ export function maskRootdir(filepath: string): string { } } +export function simplifyRootdirInArgs(filepath: string): string { + if (filepath) { + if (process.platform === 'win32') { + return filepath + .replace(/C:\/Users\/[\w\d-.]*\/AppData\/Local\/Temp\/compiler-explorer-compiler[\w\d-.]*\//, '/app/') + .replace(/C:\\Windows\\TEMP\\compiler-explorer-compiler[\w\d-.]*\\/, '/app/'); + } else { + return filepath.replace(/\/tmp\/compiler-explorer-compiler[\w\d-.]*\//, '/app/'); + } + } else { + return filepath; + } +} + const ansiColoursRe = /\x1B\[[\d;]*[Km]/g; function _parseOutputLine(line: string, inputFilename?: string, pathPrefix?: string) { |