Skip to content

Commit

Permalink
Make OCaml examples executable and objdumpable (compiler-explorer#2853)
Browse files Browse the repository at this point in the history
Changes:

- ocaml.default.properties:
  - add the relevant flags for execution and emitting binaries
  - add nicer version number reporting
  - let CE know `objdump` can be used on ocaml objects

- ocaml.js:
  - update optionsForFilter for both executable and object handling
  - override the getter for executable to work within ocamlopt context
  • Loading branch information
hyphenrf committed Aug 14, 2021
1 parent b6c2380 commit 60db8ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion etc/config/ocaml.defaults.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
compilers=/usr/bin/ocamlopt
supportsBinary=false
supportsBinary=true
supportsExecute=true
compilerType=ocaml
versionFlag=-v |sed 1q #nicer output than -vnum
objdumper=objdump


#################################
Expand Down
14 changes: 12 additions & 2 deletions lib/compilers/ocaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ export class OCamlCompiler extends BaseCompiler {
return [];
}

optionsForFilter() {
return ['-S', '-g', '-c'];
optionsForFilter(filters, outputFileName) {
let options = ['-g', '-S'];
if (filters.binary) {
options = options.concat('-o', this.filename(outputFileName));
} else {
options = options.concat('-c');
}
return options;
}

getOutputFilename(dirPath) {
return path.join(dirPath, `${path.basename(this.compileFilename, this.lang.extensions[0])}.s`);
}

getExecutableFilename(dirPath, outputFilebase) {
return path.join(dirPath, outputFilebase);
}
}

0 comments on commit 60db8ba

Please sign in to comment.