mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 09:23:52 -05:00
OCaml Improvements: objdump and a few refactorings (#2913)
* OCaml properties fixes - Improve defaults by adding local and system versions - Make no assumptions about whether local and system are the same - Enable OPAM workflows which rely on updating PATH - Fix version flag - Fix objdumper * OCaml output refactoring * Add an arg parser for OCaml Derived from Pascal (for now) * Rename default OCaml compiler ids * Add alias of old OCaml default compiler id Co-authored-by: Rubén Rincón Blanco <ruben@rinconblanco.es>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
compilers=&ocaml
|
||||
defaultCompiler=ocaml4120flambda
|
||||
objdumper=/opt/compiler-explorer/gcc-snapshot/bin/objdump
|
||||
|
||||
group.ocaml.compilers=ocaml4120flambda:ocaml4120:ocaml4112flambda:ocaml4112:ocaml4111flambda:ocaml4111:ocaml4102flambda:ocaml4102:ocaml4101flambda:ocaml4101:ocaml4100flambda:ocaml4100:ocaml4091flambda:ocaml4091:ocaml4090flambda:ocaml4090:ocaml4081flambda:ocaml4081:ocaml4071flambda:ocaml4071:ocaml4061:ocaml4042
|
||||
group.ocaml.isSemVer=true
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
compilers=/usr/bin/ocamlopt
|
||||
compilerType=ocaml
|
||||
supportsBinary=true
|
||||
supportsExecute=true
|
||||
compilerType=ocaml
|
||||
versionFlag=-v |sed 1q #nicer output than -vnum
|
||||
objdumper=objdump
|
||||
versionFlag=-v
|
||||
|
||||
compilers=&ocamlopt
|
||||
defaultCompiler=ocamlsystem
|
||||
|
||||
group.ocamlopt.compilers=ocamlsystem:ocamllocal
|
||||
|
||||
compiler.ocamlsystem.baseName=System OCaml
|
||||
compiler.ocamlsystem.exe=/usr/bin/ocamlopt
|
||||
compiler.ocamlsystem.objdumper=/usr/bin/objdump
|
||||
compiler.ocamlsystem.alias=/usr/bin/ocamlopt
|
||||
|
||||
compiler.ocamllocal.baseName=Local Switch
|
||||
compiler.ocamllocal.exe=ocamlopt
|
||||
compiler.ocamllocal.objdumper=objdump
|
||||
|
||||
#################################
|
||||
#################################
|
||||
|
||||
@@ -22,35 +22,37 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import { BaseCompiler } from '../base-compiler';
|
||||
|
||||
import { PascalParser } from './argument-parsers';
|
||||
|
||||
export class OCamlCompiler extends BaseCompiler {
|
||||
static get key() { return 'ocaml'; }
|
||||
|
||||
constructor(compilerInfo, env) {
|
||||
super(compilerInfo, env);
|
||||
// override output base because ocaml's -S -o has different semantics.
|
||||
// namely, it outputs a full binary exe to the supposed asm dump.
|
||||
// with this override and optionsForFilter override, that pecularity..
|
||||
// ..is bypassed entirely.
|
||||
this.outputFilebase = 'example';
|
||||
}
|
||||
|
||||
getSharedLibraryPathsAsArguments() {
|
||||
return [];
|
||||
}
|
||||
|
||||
optionsForFilter(filters, outputFileName) {
|
||||
let options = ['-g', '-S'];
|
||||
const options = ['-g'];
|
||||
if (filters.binary) {
|
||||
options = options.concat('-o', this.filename(outputFileName));
|
||||
options.unshift('-o', outputFileName);
|
||||
} else {
|
||||
options = options.concat('-c');
|
||||
options.unshift('-S', '-c');
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
getOutputFilename(dirPath, outputFilebase, key) {
|
||||
const filename = key.backendOptions.customOutputFilename ||
|
||||
`${path.basename(this.compileFilename, this.lang.extensions[0])}.s`;
|
||||
return path.join(dirPath, filename);
|
||||
}
|
||||
|
||||
getExecutableFilename(dirPath, outputFilebase, key) {
|
||||
const filename = key.backendOptions.customOutputFilename || outputFilebase;
|
||||
return path.join(dirPath, filename);
|
||||
getArgumentParser() {
|
||||
return PascalParser;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user