diff options
Diffstat (limited to 'lib/compilers')
39 files changed, 124 insertions, 4 deletions
diff --git a/lib/compilers/_all.js b/lib/compilers/_all.js new file mode 100644 index 000000000..fe935c331 --- /dev/null +++ b/lib/compilers/_all.js @@ -0,0 +1,39 @@ +module.exports = { + AdaCompiler: require('./ada'), + AnalysisTool: require('./analysis-tool'), + AssemblyCompiler: require('./assembly'), + Cc65Compiler: require('./cc65'), + ClangCompiler: require('./clang'), + CleanCompiler: require('./clean'), + DefaultCompiler: require('./default'), + DMDCompiler: require('./dmd'), + EllccCompiler: require('./ellcc'), + EWAVRCompiler: require('./ewavr'), + FakeCompiler: require('./fake-for-test'), + FortranCompiler: require('./fortran'), + GCCCompiler: require('./gcc'), + GolangCompiler: require('./golang'), + HaskellCompiler: require('./haskell'), + ISPCCompiler: require('./ispc'), + JavaCompiler: require('./java'), + LDCCompiler: require('./ldc'), + LLCCompiler: require('./llc'), + LLVMmcaTool: require('./llvm-mca'), + NimCompiler: require('./nim'), + NvccCompiler: require('./nvcc'), + OCamlCompiler: require('./ocaml'), + OptCompiler: require('./opt'), + FPCCompiler: require('./pascal'), + PPCICompiler: require('./ppci'), + PtxAssembler: require('./ptxas'), + PythonCompiler: require('./python'), + RustCompiler: require('./rust'), + SdccCompiler: require('./sdcc'), + SwiftCompiler: require('./swift'), + TenDRACompiler: require('./tendra'), + Win32Compiler: require('./win32'), + Win32VcCompiler: require('./win32-vc'), + WineVcCompiler: require('./wine-vc'), + WslVcCompiler: require('./wsl-vc'), + ZigCompiler: require('./zig'), +}; diff --git a/lib/compilers/ada.js b/lib/compilers/ada.js index c77d7c02f..56ed8fe09 100644 --- a/lib/compilers/ada.js +++ b/lib/compilers/ada.js @@ -27,6 +27,8 @@ const BaseCompiler = require('../base-compiler'), path = require('path'); class AdaCompiler extends BaseCompiler { + static get key() { return 'ada'; } + constructor(info, env) { super(info, env); this.supportsOptOutput = false; diff --git a/lib/compilers/analysis-tool.js b/lib/compilers/analysis-tool.js index 1ef49d1c5..e7bcd2f6b 100644 --- a/lib/compilers/analysis-tool.js +++ b/lib/compilers/analysis-tool.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'); // Plain compiler, which just runs the tool and returns whatever the output was class AnalysisTool extends BaseCompiler { + static get key() { return 'analysis-tool'; } + constructor(info, env) { // Default is to disable all "cosmetic" filters if (!info.disabledFilters) diff --git a/lib/compilers/assembly.js b/lib/compilers/assembly.js index ef792ca3a..536dae77b 100644 --- a/lib/compilers/assembly.js +++ b/lib/compilers/assembly.js @@ -31,6 +31,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class AssemblyCompiler extends BaseCompiler { + static get key() { return 'assembly'; } + constructor(info, env) { super(info, env); this.asm = new AsmRaw(); diff --git a/lib/compilers/cc65.js b/lib/compilers/cc65.js index e611c42a2..533ee3b8d 100644 --- a/lib/compilers/cc65.js +++ b/lib/compilers/cc65.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'); class Cc65Compiler extends BaseCompiler { + static get key() { return 'cc65'; } + optionsForFilter(filters, outputFilename) { return ['-g', '-o', this.filename(outputFilename)]; } diff --git a/lib/compilers/clang.js b/lib/compilers/clang.js index 050e14a5c..011e9df2f 100644 --- a/lib/compilers/clang.js +++ b/lib/compilers/clang.js @@ -27,6 +27,8 @@ const path = require('path'); class ClangCompiler extends BaseCompiler { + static get key() { return 'clang'; } + runCompiler(compiler, options, inputFilename, execOptions) { if (!execOptions) { execOptions = this.getDefaultExecOptions(); diff --git a/lib/compilers/clean.js b/lib/compilers/clean.js index 704a55444..477a19e04 100644 --- a/lib/compilers/clean.js +++ b/lib/compilers/clean.js @@ -29,6 +29,8 @@ const utils = require('../utils'); class CleanCompiler extends BaseCompiler { + static get key() { return 'clean'; } + optionsForFilter(filters) { if (filters.binary) { return []; diff --git a/lib/compilers/default.js b/lib/compilers/default.js index de0d9c502..a5ce3b614 100644 --- a/lib/compilers/default.js +++ b/lib/compilers/default.js @@ -25,6 +25,7 @@ const BaseCompiler = require('../base-compiler'); class DefaultCompiler extends BaseCompiler { + static get key() { return 'default'; } } module.exports = DefaultCompiler; diff --git a/lib/compilers/dmd.js b/lib/compilers/dmd.js index 562108bfe..d50d4b3bb 100644 --- a/lib/compilers/dmd.js +++ b/lib/compilers/dmd.js @@ -27,6 +27,8 @@ const BaseCompiler = require('../base-compiler'), path = require('path'); class DMDCompiler extends BaseCompiler { + static get key() { return 'dmd'; } + constructor(compiler, env) { super(compiler, env); this.compiler.supportsIntel = true; diff --git a/lib/compilers/ellcc.js b/lib/compilers/ellcc.js index 7d74a1eca..be90e8eb8 100644 --- a/lib/compilers/ellcc.js +++ b/lib/compilers/ellcc.js @@ -25,6 +25,8 @@ const ClangCompiler = require('./clang'); class EllccCompiler extends ClangCompiler { + static get key() { return 'ellcc'; } + getSharedLibraryPathsAsArguments() { const pathFlag = this.compiler.rpathFlag || '-Wl,-rpath,'; diff --git a/lib/compilers/ewavr.js b/lib/compilers/ewavr.js index 93ed9b1bb..5de44a72f 100644 --- a/lib/compilers/ewavr.js +++ b/lib/compilers/ewavr.js @@ -29,6 +29,8 @@ const BaseCompiler = require('../base-compiler'), AsmEWAVRParser = require('../asm-parser-ewavr'); class EWAVRCompiler extends BaseCompiler { + static get key() { return 'ewavr'; } + constructor(info, env) { info.supportsDemangle = false; info.supportsLibraryCodeFilter = false; diff --git a/lib/compilers/fake-for-test.js b/lib/compilers/fake-for-test.js index ff0c43a7d..e2b1c49ae 100644 --- a/lib/compilers/fake-for-test.js +++ b/lib/compilers/fake-for-test.js @@ -25,6 +25,8 @@ const _ = require('underscore'); class FakeCompiler { + static get key() { return 'fake-for-test'; } + constructor(info) { this.compiler = { id: info.id || 'fake-for-test', diff --git a/lib/compilers/fortran.js b/lib/compilers/fortran.js index 6ea062c1e..54b3cba2f 100644 --- a/lib/compilers/fortran.js +++ b/lib/compilers/fortran.js @@ -28,6 +28,8 @@ const BaseCompiler = require('../base-compiler'), utils = require('../utils'); class FortranCompiler extends BaseCompiler { + static get key() { return 'fortran'; } + async runCompiler(compiler, options, inputFilename, execOptions) { if (!execOptions) { execOptions = this.getDefaultExecOptions(); diff --git a/lib/compilers/gcc.js b/lib/compilers/gcc.js index 8dd6cb2cb..6c9a1e1ca 100644 --- a/lib/compilers/gcc.js +++ b/lib/compilers/gcc.js @@ -25,6 +25,7 @@ const BaseCompiler = require('../base-compiler'); class GCCCompiler extends BaseCompiler { + static get key() { return 'gcc'; } } module.exports = GCCCompiler; diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js index 9c6761f7b..434e3a693 100644 --- a/lib/compilers/golang.js +++ b/lib/compilers/golang.js @@ -43,6 +43,8 @@ const jumpPrefixes = [ ]; class GolangCompiler extends BaseCompiler { + static get key() { return 'golang'; } + convertNewGoL(code) { const re = /^\s+(0[Xx]?[\dA-Za-z]+)?\s?(\d+)\s*\(([^:]+):(\d+)\)\s*([A-Z]+)(.*)/; const reUnknown = /^\s+(0[Xx]?[\dA-Za-z]+)?\s?(\d+)\s*\(<unknown line number>\)\s*([A-Z]+)(.*)/; diff --git a/lib/compilers/haskell.js b/lib/compilers/haskell.js index bc0522ec8..5b5742b5f 100644 --- a/lib/compilers/haskell.js +++ b/lib/compilers/haskell.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class HaskellCompiler extends BaseCompiler { + static get key() { return 'haskell'; } + optionsForFilter(filters, outputFilename) { return ['-S', '-g', '-o', this.filename(outputFilename)]; } diff --git a/lib/compilers/index.js b/lib/compilers/index.js new file mode 100644 index 000000000..3da4214c5 --- /dev/null +++ b/lib/compilers/index.js @@ -0,0 +1,6 @@ +const makeKeyedTypeGetter = require('../keyed-type').makeKeyedTypeGetter; +const all = require('./_all'); + +module.exports = { + getCompilerTypeByKey: makeKeyedTypeGetter('compiler', all), +}; diff --git a/lib/compilers/ispc.js b/lib/compilers/ispc.js index 92ec9f71c..d38976037 100644 --- a/lib/compilers/ispc.js +++ b/lib/compilers/ispc.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class ISPCCompiler extends BaseCompiler { + static get key() { return 'ispc'; } + optionsForFilter(filters, outputFilename) { let options = ['--target=avx2-i32x8', '--emit-asm', '-g', '-o', this.filename(outputFilename)]; if (this.compiler.intelAsm && filters.intel && !filters.binary) { diff --git a/lib/compilers/java.js b/lib/compilers/java.js index fc45a2975..9453c5581 100644 --- a/lib/compilers/java.js +++ b/lib/compilers/java.js @@ -30,6 +30,8 @@ const BaseCompiler = require('../base-compiler'), logger = require('../logger').logger; class JavaCompiler extends BaseCompiler { + static get key() { return 'java'; } + constructor(compilerInfo, env) { // Default is to disable all "cosmetic" filters if (!compilerInfo.disabledFilters) { diff --git a/lib/compilers/ldc.js b/lib/compilers/ldc.js index eab2d235a..fc3d1a66f 100644 --- a/lib/compilers/ldc.js +++ b/lib/compilers/ldc.js @@ -30,6 +30,8 @@ const BaseCompiler = require('../base-compiler'), semverParser = require('semver'); class LDCCompiler extends BaseCompiler { + static get key() { return 'ldc'; } + constructor(info, env) { super(info, env); this.compiler.supportsIntel = true; diff --git a/lib/compilers/llc.js b/lib/compilers/llc.js index a57d06196..3bc22a396 100644 --- a/lib/compilers/llc.js +++ b/lib/compilers/llc.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class LLCCompiler extends BaseCompiler { + static get key() { return 'llc'; } + constructor(info, env) { super(info, env); this.compiler.supportsIntel = true; diff --git a/lib/compilers/llvm-mca.js b/lib/compilers/llvm-mca.js index eb885e21a..26459731c 100644 --- a/lib/compilers/llvm-mca.js +++ b/lib/compilers/llvm-mca.js @@ -27,6 +27,8 @@ const AnalysisTool = require('./analysis-tool'), // Plain compiler, which just runs the tool and returns whatever the output was class LLVMmcaTool extends AnalysisTool { + static get key() { return 'llvm-mca'; } + supportsObjdump() { return false; } getOutputFilenameArgs(filename) { diff --git a/lib/compilers/nim.js b/lib/compilers/nim.js index 26a7ff482..cec0471e1 100644 --- a/lib/compilers/nim.js +++ b/lib/compilers/nim.js @@ -37,6 +37,8 @@ const NimCommands = [ ]; class NimCompiler extends BaseCompiler { + static get key() { return 'nim'; } + constructor(info, env) { super(info, env); this.compiler.supportsIntel = true; diff --git a/lib/compilers/nvcc.js b/lib/compilers/nvcc.js index d8e33c1be..97f27a513 100644 --- a/lib/compilers/nvcc.js +++ b/lib/compilers/nvcc.js @@ -28,6 +28,8 @@ const BaseCompiler = require('../base-compiler'), AsmParserSass = require('../asm-parser-sass'); class NvccCompiler extends BaseCompiler { + static get key() { return 'nvcc'; } + constructor(info, env) { super(info, env); diff --git a/lib/compilers/ocaml.js b/lib/compilers/ocaml.js index d5fe2cfa7..bc92d5438 100644 --- a/lib/compilers/ocaml.js +++ b/lib/compilers/ocaml.js @@ -28,6 +28,8 @@ const BaseCompiler = require('../base-compiler'), path = require('path'); class OCamlCompiler extends BaseCompiler { + static get key() { return 'ocaml'; } + optionsForFilter() { return ['-S', '-g', '-c']; } diff --git a/lib/compilers/opt.js b/lib/compilers/opt.js index 406a81f78..4b5697ec3 100644 --- a/lib/compilers/opt.js +++ b/lib/compilers/opt.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class OptCompiler extends BaseCompiler { + static get key() { return 'opt'; } + optionsForFilter(filters, outputFilename) { return ['-o', this.filename(outputFilename), '-S']; } diff --git a/lib/compilers/pascal.js b/lib/compilers/pascal.js index 2df9deaae..b30a0c312 100644 --- a/lib/compilers/pascal.js +++ b/lib/compilers/pascal.js @@ -31,6 +31,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class FPCCompiler extends BaseCompiler { + static get key() { return 'pascal'; } + constructor(info, env) { super(info, env); diff --git a/lib/compilers/ppci.js b/lib/compilers/ppci.js index cd23c9121..9ff086d99 100644 --- a/lib/compilers/ppci.js +++ b/lib/compilers/ppci.js @@ -33,6 +33,8 @@ const forbiddenOptions = new Set([ ]); class PPCICompiler extends BaseCompiler { + static get key() { return 'ppci'; } + filterUserOptions(args) { return args.filter((item) => { if (typeof item !== 'string') return true; diff --git a/lib/compilers/ptxas.js b/lib/compilers/ptxas.js index ad5fd1d04..7a5361a75 100644 --- a/lib/compilers/ptxas.js +++ b/lib/compilers/ptxas.js @@ -30,6 +30,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class PtxAssembler extends BaseCompiler { + static get key() { return 'ptxas'; } + constructor(info, env) { super(info, env); this.compileFilename = 'example.ptxas'; diff --git a/lib/compilers/python.js b/lib/compilers/python.js index a35b34b5e..843024552 100644 --- a/lib/compilers/python.js +++ b/lib/compilers/python.js @@ -27,6 +27,7 @@ const BaseCompiler = require('../base-compiler'), path = require('path'); class PythonCompiler extends BaseCompiler { + static get key() { return 'python'; } constructor(compilerInfo, env) { super(compilerInfo, env); diff --git a/lib/compilers/rust.js b/lib/compilers/rust.js index 78a06c7b6..9806f4275 100644 --- a/lib/compilers/rust.js +++ b/lib/compilers/rust.js @@ -28,6 +28,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class RustCompiler extends BaseCompiler { + static get key() { return 'rust'; } + constructor(info, env) { super(info, env); this.compiler.supportsIntel = true; diff --git a/lib/compilers/sdcc.js b/lib/compilers/sdcc.js index 97e84f7fb..6f1b352f3 100644 --- a/lib/compilers/sdcc.js +++ b/lib/compilers/sdcc.js @@ -25,6 +25,8 @@ const GccCompiler = require('./gcc'); class SdccCompiler extends GccCompiler { + static get key() { return 'sdcc'; } + optionsForFilter(filters, outputFilename) { let options = ['-o', this.filename(outputFilename)]; if (!filters.binary) options = options.concat('-S'); diff --git a/lib/compilers/swift.js b/lib/compilers/swift.js index cef6c8941..f1fa0137c 100644 --- a/lib/compilers/swift.js +++ b/lib/compilers/swift.js @@ -26,6 +26,8 @@ const BaseCompiler = require('../base-compiler'), argumentParsers = require('./argument-parsers'); class SwiftCompiler extends BaseCompiler { + static get key() { return 'swift'; } + getSharedLibraryPathsAsArguments() { return []; } diff --git a/lib/compilers/tendra.js b/lib/compilers/tendra.js index 3b7f14da2..2301521f7 100644 --- a/lib/compilers/tendra.js +++ b/lib/compilers/tendra.js @@ -2,6 +2,8 @@ const GccCompiler = require('./gcc'); class TenDRACompiler extends GccCompiler { + static get key() { return 'tendra'; } + optionsForFilter(filters, outputFilename) { let options = ['-o', this.filename(outputFilename)]; if (!filters.binary) options = options.concat('-S'); diff --git a/lib/compilers/win32-vc.js b/lib/compilers/win32-vc.js index 932d0fdeb..51ed4a9c4 100644 --- a/lib/compilers/win32-vc.js +++ b/lib/compilers/win32-vc.js @@ -27,6 +27,8 @@ const Win32Compiler = require('./win32'), AsmParser = require('../asm-parser-vc'); class Win32VcCompiler extends Win32Compiler { + static get key() { return 'win32-vc'; } + constructor(info, env) { super(info, env); this.asm = new AsmParser(this.compilerProps); diff --git a/lib/compilers/win32.js b/lib/compilers/win32.js index 56e809104..cd8af33f7 100644 --- a/lib/compilers/win32.js +++ b/lib/compilers/win32.js @@ -28,9 +28,12 @@ const BaseCompiler = require('../base-compiler'), temp = require('temp'), path = require('path'), _ = require('underscore'), - PELabelReconstructor = require('../pe32-support').labelReconstructor; + PELabelReconstructor = require('../pe32-support').labelReconstructor, + MapFileReaderVS = require('../map-file-vs').MapFileReader; class Win32Compiler extends BaseCompiler { + static get key() { return 'win32'; } + newTempDir() { return new Promise((resolve, reject) => { temp.mkdir({prefix: 'compiler-explorer-compiler', dir: process.env.TMP}, (err, dirPath) => { @@ -123,9 +126,10 @@ class Win32Compiler extends BaseCompiler { optionsForFilter(filters, outputFilename) { if (filters.binary) { const mapFilename = outputFilename + '.map'; + const mapFileReader = new MapFileReaderVS(mapFilename); filters.preProcessBinaryAsmLines = (asmLines) => { - const reconstructor = new PELabelReconstructor(asmLines, mapFilename, false, 'vs'); + const reconstructor = new PELabelReconstructor(asmLines, false, mapFileReader); reconstructor.run('output.s.obj'); return reconstructor.asmLines; diff --git a/lib/compilers/wine-vc.js b/lib/compilers/wine-vc.js index 8c831e840..16cb02a63 100644 --- a/lib/compilers/wine-vc.js +++ b/lib/compilers/wine-vc.js @@ -26,9 +26,12 @@ const BaseCompiler = require('../base-compiler'), AsmParser = require('../asm-parser-vc'), argumentParsers = require('./argument-parsers'), path = require('path'), - PELabelReconstructor = require('../pe32-support').labelReconstructor; + PELabelReconstructor = require('../pe32-support').labelReconstructor, + MapFileReaderVS = require('../map-file-vs').MapFileReader; class WineVcCompiler extends BaseCompiler { + static get key() { return 'wine-vc'; } + constructor(info, env) { info.supportsFiltersInBinary = true; super(info, env); @@ -80,9 +83,10 @@ class WineVcCompiler extends BaseCompiler { optionsForFilter(filters, outputFilename) { if (filters.binary) { const mapFilename = outputFilename + '.map'; + const mapFileReader = new MapFileReaderVS(mapFilename); filters.preProcessBinaryAsmLines = (asmLines) => { - const reconstructor = new PELabelReconstructor(asmLines, mapFilename, false, 'vs'); + const reconstructor = new PELabelReconstructor(asmLines, false, mapFileReader); reconstructor.run('output.s.obj'); return reconstructor.asmLines; diff --git a/lib/compilers/wsl-vc.js b/lib/compilers/wsl-vc.js index a3cc3060b..d78219d18 100644 --- a/lib/compilers/wsl-vc.js +++ b/lib/compilers/wsl-vc.js @@ -32,6 +32,8 @@ const Win32VcCompiler = require('./win32-vc'), temp = require('temp'); class WslVcCompiler extends Win32VcCompiler { + static get key() { return 'wsl-vc'; } + constructor(info, env) { super(info, env); this.asm = new AsmParser(); diff --git a/lib/compilers/zig.js b/lib/compilers/zig.js index bf4b18908..c7d2bb4a7 100644 --- a/lib/compilers/zig.js +++ b/lib/compilers/zig.js @@ -28,6 +28,8 @@ const BaseCompiler = require('../base-compiler'), Semver = require('semver'); class ZigCompiler extends BaseCompiler { + static get key() { return 'zig'; } + constructor(info, env) { super(info, env); this.compiler.supportsIntel = true; |