diff options
author | Jessica Clarke <jrtc27@jrtc27.com> | 2021-04-01 14:34:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-01 08:34:07 -0500 |
commit | af686e81f7a8d06c12b44272aa67c73d1ebb069b (patch) | |
tree | a4572b0c70bc42b20c0cca4d4edba71f2bec3119 /lib/compilers | |
parent | 1e3da6eefdc2a6bfaca14af340971a8159557105 (diff) | |
download | compiler-explorer-af686e81f7a8d06c12b44272aa67c73d1ebb069b.tar.gz compiler-explorer-af686e81f7a8d06c12b44272aa67c73d1ebb069b.zip |
Support ELF Tool Chain and LLVM objdump (#2538)
* Remove redundant implementations of objdump function
* Add support for ELF Tool Chain and LLVM objdump
Only binutils supports --insn-width and LLVM uses --x86-asm-syntax=intel
rather than -M intel. The default remains binutils.
Diffstat (limited to 'lib/compilers')
-rw-r--r-- | lib/compilers/assembly.js | 17 | ||||
-rw-r--r-- | lib/compilers/dmd.js | 16 | ||||
-rw-r--r-- | lib/compilers/pascal.js | 17 | ||||
-rw-r--r-- | lib/compilers/win32.js | 17 | ||||
-rw-r--r-- | lib/compilers/wine-vc.js | 17 |
5 files changed, 8 insertions, 76 deletions
diff --git a/lib/compilers/assembly.js b/lib/compilers/assembly.js index f684b1ba6..a81cb472f 100644 --- a/lib/compilers/assembly.js +++ b/lib/compilers/assembly.js @@ -87,20 +87,7 @@ export class AssemblyCompiler extends BaseCompiler { return this.postProcess(asmResult, outputFilename, filters); } - async objdump(outputFilename, result, maxSize, intelAsm, demangle) { - const realOutputFilename = this.getGeneratedOutputFilename(outputFilename); - const dirPath = path.dirname(realOutputFilename); - let args = ['-d', realOutputFilename, '-l', '--insn-width=16']; - if (demangle) args = args.concat('-C'); - if (intelAsm) args = args.concat(['-M', 'intel']); - const objResult = await this.exec( - this.compiler.objdumper, args, {maxOutput: maxSize, customCwd: dirPath}); - result.asm = objResult.stdout; - if (objResult.code !== 0) { - result.asm = '<No output: objdump returned ' + objResult.code + '>'; - } else { - result.objdumpTime = objResult.execTime; - } - return result; + getObjdumpOutputFilename(defaultOutputFilename) { + return this.getGeneratedOutputFilename(defaultOutputFilename); } } diff --git a/lib/compilers/dmd.js b/lib/compilers/dmd.js index a175328f6..ee1feb189 100644 --- a/lib/compilers/dmd.js +++ b/lib/compilers/dmd.js @@ -62,22 +62,6 @@ export class DMDCompiler extends BaseCompiler { return this.runCompiler(compiler, options, inputFilename, execOptions); } - async objdump(outputFilename, result, maxSize, intelAsm, demangle) { - const dirPath = path.dirname(outputFilename); - let args = ['-d', outputFilename, '-l', '--insn-width=16']; - if (demangle) args = args.concat('-C'); - if (intelAsm) args = args.concat(['-M', 'intel']); - const objResult = await this.exec( - this.compiler.objdumper, args, {maxOutput: maxSize, customCwd: dirPath}); - result.asm = objResult.stdout; - if (objResult.code !== 0) { - result.asm = `<No output: objdump returned ${objResult.code}>`; - } else { - result.objdumpTime = objResult.execTime; - } - return result; - } - getArgumentParser() { return ClangParser; } diff --git a/lib/compilers/pascal.js b/lib/compilers/pascal.js index ef3b345be..32980271a 100644 --- a/lib/compilers/pascal.js +++ b/lib/compilers/pascal.js @@ -104,21 +104,8 @@ export class FPCCompiler extends BaseCompiler { return input; } - async objdump(outputFilename, result, maxSize, intelAsm, demangle) { - const dirPath = path.dirname(outputFilename); - outputFilename = this.getExecutableFilename(dirPath); - let args = ['-d', outputFilename, '-l', '--insn-width=16']; - if (demangle) args = args.concat(['-C']); - if (intelAsm) args = args.concat(['-M', 'intel']); - const objResult = await this.exec( - this.compiler.objdumper, args, {maxOutput: maxSize, customCwd: dirPath}); - if (objResult.code !== 0) { - result.asm = '<No output: objdump returned ' + objResult.code + '>'; - } else { - result.objdumpTime = objResult.execTime; - result.asm = FPCCompiler.preProcessBinaryAsm(objResult.stdout); - } - return result; + postProcessObjdumpOutput(output) { + return FPCCompiler.preProcessBinaryAsm(output); } async saveDummyProjectFile(filename) { diff --git a/lib/compilers/win32.js b/lib/compilers/win32.js index 957cbc26b..3d81cbf63 100644 --- a/lib/compilers/win32.js +++ b/lib/compilers/win32.js @@ -50,21 +50,8 @@ export class Win32Compiler extends BaseCompiler { return this.getOutputFilename(dirPath, outputFilebase) + '.exe'; } - async objdump(outputFilename, result, maxSize, intelAsm) { - const dirPath = path.dirname(outputFilename); - outputFilename = this.getExecutableFilename(path.dirname(outputFilename), 'output'); - - let args = ['-d', outputFilename]; - if (intelAsm) args = args.concat(['-M', 'intel']); - const objResult = await this.exec(this.compiler.objdumper, args, {maxOutput: 0, customCwd: dirPath}); - if (objResult.code !== 0) { - result.asm = '<No output: objdump returned ' + objResult.code + '>'; - } else { - result.objdumpTime = objResult.execTime; - result.asm = objResult.stdout; - } - - return result; + getObjdumpOutputFilename(defaultOutputFilename) { + return this.getExecutableFilename(path.dirname(defaultOutputFilename), 'output'); } getSharedLibraryPathsAsArguments(libraries) { diff --git a/lib/compilers/wine-vc.js b/lib/compilers/wine-vc.js index d440f5780..c2e03888b 100644 --- a/lib/compilers/wine-vc.js +++ b/lib/compilers/wine-vc.js @@ -62,21 +62,8 @@ export class WineVcCompiler extends BaseCompiler { return this.getOutputFilename(dirPath, outputFilebase) + '.exe'; } - async objdump(outputFilename, result, maxSize, intelAsm) { - const dirPath = path.dirname(outputFilename); - outputFilename = this.getExecutableFilename(dirPath, 'output'); - - let args = ['-d', outputFilename]; - if (intelAsm) args = args.concat(['-M', 'intel']); - const objResult = await this.exec(this.compiler.objdumper, args, {maxOutput: 0, customCwd: dirPath}); - if (objResult.code !== 0) { - result.asm = '<No output: objdump returned ' + objResult.code + '>'; - } else { - result.objdumpTime = objResult.execTime; - result.asm = objResult.stdout; - } - - return result; + getObjdumpOutputFilename(defaultOutputFilename) { + return this.getExecutableFilename(path.dirname(defaultOutputFilename), 'output'); } getSharedLibraryPathsAsArguments() { |