diff options
author | Haz <hyphens@pm.me> | 2021-09-03 05:51:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 05:51:15 +0200 |
commit | b3628b2c31a1af4d303f1f44ff964a42119d2cd4 (patch) | |
tree | 7be9c7c699b936d15941cb5cead0a35afb992e39 | |
parent | 6a1dbe14f75eeebde0d658e455728d3910bb711a (diff) | |
download | compiler-explorer-b3628b2c31a1af4d303f1f44ff964a42119d2cd4.tar.gz compiler-explorer-b3628b2c31a1af4d303f1f44ff964a42119d2cd4.zip |
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>
-rw-r--r-- | etc/config/ocaml.amazon.properties | 1 | ||||
-rw-r--r-- | etc/config/ocaml.defaults.properties | 19 | ||||
-rw-r--r-- | lib/compilers/ocaml.js | 30 |
3 files changed, 32 insertions, 18 deletions
diff --git a/etc/config/ocaml.amazon.properties b/etc/config/ocaml.amazon.properties index ff7052990..5159753c6 100644 --- a/etc/config/ocaml.amazon.properties +++ b/etc/config/ocaml.amazon.properties @@ -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 diff --git a/etc/config/ocaml.defaults.properties b/etc/config/ocaml.defaults.properties index 1e34120f3..b928b0acc 100644 --- a/etc/config/ocaml.defaults.properties +++ b/etc/config/ocaml.defaults.properties @@ -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 ################################# ################################# diff --git a/lib/compilers/ocaml.js b/lib/compilers/ocaml.js index 46b396773..1bbd9a6cf 100644 --- a/lib/compilers/ocaml.js +++ b/lib/compilers/ocaml.js @@ -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; } } |