summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
...
* | Some cleanup to explicit transl_implementation_flambda return valuesPierre Chambart2016-07-081-4/+4
| |
* | Allow to force linking modules without generating dummy codePierre Chambart2016-07-081-4/+6
| |
* | Make Pparse functions type-safeGabriel Scherer2016-06-292-51/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to remove some redundancy, the Pparse modules used a dirty Obj.magic trick to manipulate either structure or signature values (ASTs parsed from source files). This unsafe approach means that programming mistakes may result in broken type soudness, and indeed I myself had to track a very puzzling Segfault during the development of my Menhir backend (due to a copy-paste error I was passing Parse.implementation instead of Parse.interface somewhere). Wondering why your parser generator seems to generate segfaulting parsers is Not Fun. This change means that the external interface of Pparse has changed a bit. There is no way to fulfill the type of Pparse.file in a type-safe way val file : formatter -> tool_name:string -> string -> (Lexing.lexbuf -> 'a) -> string -> 'a as it promises to be able to process any ast type 'a depending on the magic number (the last string argument). The knew type-safe interface is val file : formatter -> tool_name:string -> string -> (Lexing.lexbuf -> 'a) -> 'a ast_kind -> 'a where ['a ast_kind] is a GADT type: type 'a ast_kind = | Structure : Parsetree.structure ast_kind | Signature : Parsetree.signature ast_kind
* | Rigorously handle -o and -c options in presence of multiple arguments.whitequark2016-06-142-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses PR#6475. In 4.02 the behavior of ocamlc/ocamlopt with regards to these options was as follows: * options and arguments are parsed left-to-right in the exact order in which they are passed, with compilation taking into account only the options leftwards from it; * "foo.c" is compiled to "foo.o" in current directory; * when "-c" is not specified: * "foo.ml" is compiled to "foo.cmo"/"foo.cmxo" in current directory; * after all files have been compiled, if any .ml files are passed, all provided files are linked as: * when "-o" is not specified: "a.out" in current directory; * when "-o out" is specified: "out". * when "-c" is specified: * "foo.ml" is compiled to: * when "-o" is not specified: "foo.cmo"/"foo.cmxo" in current directory; * when "-o out" is specified: "out.cmo"/"out.cmxo"; and then compilation proceeds as if the last "-o" option has disappeared. * no final link is performed. The behavior where the build product of the C sources always ended up in the current directory was problematic: it required buildsystem hacks to move the file in its proper place and ultimately was racy, as multiple files with the same basename in different directories may well end up overwriting each other with e.g. ocamlbuild. On top of that, the behavior was quite confusing, since it is not only stateful and dependent on argument order, but also the mere act of compilation changed state. The commit 1d8e590c has attempted to rectify that by looking at the "-o" option when compiling C files, too. After that commit, the behavior of ocamlc/ocamlopt was as follows (only the handling of C files was changed, but the entire chart is provided for posterity): * options and arguments are parsed left-to-right in the exact order in which they are passed, with compilation taking into account only the options leftwards from it; * "foo.c" is compiled to: * when "-o" is not specified: "foo.o" in current directory; * when "-o out" is specified: "out". * when "-c" is not specified: * "foo.ml" is compiled to "foo.cmo"/"foo.cmxo" in current directory; * after all files have been compiled, if any .ml files are passed, all provided files are linked as: * when "-o" is not specified: "a.out" in current directory; * when "-o out" is specified: "out". * when "-c" is specified: * "foo.ml" is compiled to: * when "-o" is not specified: "foo.cmo"/"foo.cmxo" in current directory; * when "-o out" is specified: "out.cmo"/"out.cmxo"; and then compilation proceeds as if the last "-o" option has disappeared. * no final link is performed. There is a non-obvious bug here. Specifically, what happens if more than one C source file is passed together with a "-o" option? Also, what happens if a C source file is passed together with a "-o" option and then a final link is performed? The answer is that the intermediate build product gets silently overwritten, with quite opaque errors as a result. There is some code (and even buildsystems) in the wild that is relying on the fact that the -o option does not affect compilation of C source files, e.g. by running commands such as (from ocamlnet): ocamlc -custom -o t tend.c t.ml It might seem that the solution would be to make the behavior of the compiler drivers for C files match that for the OCaml files; specifically, pretend that the "-o" option has disappeared once the C compiler has written a build product to the specified place. However, this would still break the existing code, and moreover does not address the underlying problem: that the option parsing of the OCaml compiler driver is confusing and prone to creating latent bugs. Instead, this commit finishes (after 1d8e590c and 55d2d420) overhauls the way option parsing in ocamlc/ocamlopt works to behave as follows: * options are parsed left-to-right in the order they are specified; * after all options are parsed, arguments are parsed left-to-right in the order they were specified; * when "-o out" and "-c" are specified: * when more than one file is passed, an error message is displayed. * when one file is passed: * "foo.c" is compiled to "out"; * "foo.ml" is compiled to "out.cmo"/"out.cmxo". * when "-o out" is not specified or "-c" is not specified: * "foo.c" is compiled to "foo.o" in current directory; * "foo.ml" is compiled to "foo.cmo"/"foo.cmxo" in current directory; * when "-c" is not specified: * after all files have been compiled, if any .ml files are passed, all provided files are linked as: * when "-o" is not specified: "a.out" in current directory; * when "-o out" is specified: "out". In short, the combination of "-o", "-c" and a single source file compiles that one file to the corresponding intermediate build product. Otherwise, passing "-o" will either set the name of the final build product only or error out. This preserves compatibility with old code, makes the handling of C and OCaml sources consistent, and overall makes the behavior of the option parser more straightforward. However, this may break code that relies on the fact that options are parsed in-order, e.g. ocamlc -o t a.ml -g b.ml where debug info would be built only for "b.ml". Some alternative implementation paths I have considered: * Collect the C sources and process them after OCaml sources, while paying attention to any "-o" or "-c" that may have been set. This doesn't work because compilation of C sources is also affected by many flags, e.g. "-I", and so this would have the same drawbacks but none of the benefits; * Compile C and OCaml sources in-order as usual, but error out when an improper combination of flags is encountered in the middle of a compilation. This is technically feasible, and is the option that maximally preserves compatibility, but it is very complex: it doubles the amount of implicitly mutated global state, and there's no guarantee I will get all edge cases right. Moreover, the option parsing remains confusing, and I strongly believe that the current behavior should not remain in place. On top of that it is hard to imagine cases where setting new options in the middle of compilation would actually be desirable, because this mechanism is very inexpressive: it can only add new options and option values, since there is no way to negate or clear most of the driver's state. Most likely is that any code that does so, does it in error and remains operational by pure chance.
* | Interpret all command-line options before compiling any files.whitequark2016-06-142-14/+29
|/ | | | | | | | | | | | | | | | The behavior of ocamlc and ocamlopt drivers before this commit is that the command-line options and arguments are processed exactly sequentially; encountered options (e.g. "-o") modify the state of the driver, and encountered arguments (e.g. "t.ml") compile the corresponding file with whatever state the driver had at the time. This can be quite confusing, because compiler drivers (e.g. gcc/g++, clang/clang++, rustc, javac, go, ...) either parse the entire command line before going on to compile files or reject options after the first argument (only in the case of go). Thus the behavior of ocamlc and ocamlopt is unexpected. The following commit provides another reason for this change.
* Add the -no-version option to the toplevel.Sébastien Hinderer2016-05-092-0/+8
| | | | | This option requests the toplevel not to print its version number at startup.
* Option sharing between byetcode and native toplevels.Sébastien Hinderer2016-05-022-26/+24
|
* Add `-alias-deps` and `-app-funct`Demi Obenour2016-04-194-2/+29
| | | | This was meant for GPR #514, but I forgot to include it.
* Add explicit command-line flags for currently-default settingsDemi Obenour2016-04-184-6/+88
| | | | | | | | -no-keep-docs -no-keep-locs -no-principal -no-rectypes -no-strict-formats
* Attend to final Flambda CR comments for 4.03 releaseMark Shinwell2016-03-301-2/+8
|
* More warnings when compiling the compiler.alainfrisch2016-03-152-22/+34
|
* Merge pull request #480 from mshinwell/flambda_unbox-closuresMark Shinwell2016-02-264-0/+15
| | | | GPR#480: Flambda fix: try to make Unbox_closures behave more reasonably
* Update headers for the new license.Damien Doligez2016-02-1821-231/+294
| | | | Remains to be done: remove all headers in testsuite/tests.
* Tidy up new command-line parametersLeo White2016-02-115-75/+103
|
* Make warning 59 less unhelpful (includes work by Runhang Li)Mark Shinwell2016-02-111-0/+1
|
* Enable opaque option in ocamlcLeo White2016-02-113-3/+5
|
* Reformatting only (to the standards of tools/check-typo)Mark Shinwell2016-02-105-21/+41
|
* Revert "PR#6475: accept -o in ocamlc when compiling C files"Damien Doligez2016-02-102-3/+2
| | | | | | | | | | | | This reverts commit 1d8e590c54dcd888503c3ea2944533255ef87343. Conflicts: Changes bytecomp/bytelink.ml driver/optcompile.ml ocamlbuild/ocaml_specific.ml ocamlbuild/testsuite/internal.ml utils/ccomp.ml
* Bug fixes etc for FlambdaMark Shinwell2016-02-093-6/+15
|
* Import latest Flambda changesMark Shinwell2016-02-095-15/+25
|
* Rename to max_arguments_for_tailcalls; revise numbers assuming no unboxed ↵Mark Shinwell2016-02-081-1/+1
| | | | floats using the OCaml calling conventions
* max_arguments_without_passing_on-stackMark Shinwell2016-01-291-3/+3
|
* Enable flambdaPierre Chambart2016-01-286-19/+440
|
* Add module Ast_invariantsJeremie Dimino2016-01-271-4/+11
| | | | | | | | | This module checks all the AST invariants. This is to ensure that all invariants are written down in one place and are consistently checked between the various clients of the AST (typer, pprintast, ...). The invariants are checked in Pparsee, after applying the ppx rewriters.
* Rename compiler_configuration filePierre Chambart2016-01-251-1/+3
| | | | Renamed to ocaml_compiler_internal_params.
* Update main and ocamldepPierre Chambart2016-01-251-3/+3
|
* Reindent compenvPierre Chambart2016-01-251-146/+146
|
* Add handling of OCAMLPARAM as a filePierre Chambart2016-01-253-28/+119
|
* Useless bindings, unit patterns, whitespace.alainfrisch2016-01-191-2/+2
|
* Merge remote-tracking branch 'ocaml/trunk' into flambda_prereq-clflagsMark Shinwell2016-01-151-0/+1
|\
| * Support 'opaque' in OCAMLPARAMMark Shinwell2016-01-151-0/+1
| |
* | code reviewMark Shinwell2016-01-141-3/+11
| |
* | Clflags stuff and Arg_helperMark Shinwell2016-01-144-11/+10
|/
* use Timings.source_provenance in more placesThomas Refis2015-12-311-3/+3
|
* Rename type build_kind and sourcefile arguments to source_provenancePierre Chambart2015-12-181-1/+1
|
* Clean up and time separately parsing and preprocessingPierre Chambart2015-12-181-7/+7
|
* Record the source file name being built in CompilenvPierre Chambart2015-12-181-1/+2
|
* Remove last use of Timining.start/stop in {opt,}compile.mlPierre Chambart2015-12-182-11/+12
|
* Avoid using Timings.start/stopPierre Chambart2015-12-185-26/+21
|
* Record compiler runtimePierre Chambart2015-12-188-1/+33
|
* Add module to deal with 'front-end' built-in attributes.alainfrisch2015-12-022-2/+2
|
* Keep deprecation flag on compilation unit, extracted from a floating ↵alainfrisch2015-11-272-2/+4
| | | | attribute in the .mli file.
* PR#7008: Fatal error in ocamlc with empty compilation unit nameDamien Doligez2015-10-191-0/+1
| | | | git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16523 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* whitespace cleanup, cut long lines, add some missing headersDamien Doligez2015-09-112-12/+18
| | | | git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16415 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* add option handling for colors in compiler, OCAMLPARAM and ocamlbuildGabriel Scherer2015-08-155-0/+39
| | | | | | | | | | | (Simon Cruanes and Gabriel Scherer) Use one of -color auto -color always -color never git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16348 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* Typo.Alain Frisch2015-07-241-1/+0
| | | | git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16242 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev ↵Damien Doligez2015-07-1710-61/+87
| | | | | | 16205) git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16214 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* Attach documentation comments to ParsetreeLeo White2015-06-285-0/+11
| | | | git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16189 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* PR#6636: add a --version option (Peter Zotov)Gabriel Scherer2015-05-241-0/+9
| | | | git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16141 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
* Cleanup + better interaction between -intf and -pack (the .cmi file was not ↵Alain Frisch2015-05-072-12/+10
| | | | | | added to the list of objects in that case). git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16100 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02