Commit Graph

107 Commits (master)

Author SHA1 Message Date
Stephen Dolan fd1bb255e1 More partial application warnings 2020-06-02 12:11:41 +01:00
Nicolás Ojeda Bär 9b748843bb
Use List.find_map (#9589) 2020-05-21 08:51:16 +02:00
Fourchaux 1f9474c63c Fixing typos (#9162) 2019-12-04 19:38:02 +00:00
Gabriel Scherer 9d81d6a10e new Misc.Magic_number module for magic number handling
This module was originally inspired by js_of_ocaml Misc.MagicNumber module
https://github.com/ocsigen/js_of_ocaml/blob/151b811/compiler/util.cppo.ml#L277-L347

It provides parsing and validation function for magic numbers, that
can tell the difference between "not a valid magic number" and "a
valid magic number, but with another version", and print user-friendly
user messages about it.

It does not contain any knowledge for where to find the magic number
in an OCaml file (this depends on the file format); the parsing
function should be called with an input channel already at the right
position for whichever format is expect.
2019-12-03 00:08:29 +01:00
Gabriel Scherer f5252e9840 Misc.protect_refs: use Fun.protect to protect the backtrace
Currently Fun.protect and Misc.try_finally can be used in code that
tries carefully to preserve the first-failure backtrace, but
Misc.protect_refs cannot. This PR fixes the discrepancy. See #9057 for
a use-case.

See the GPR ( https://github.com/ocaml/ocaml/pull/9060 ) for an
in-depth discussion of the potential performance impact of this
change.
2019-11-07 14:43:17 +01:00
Leo White c19e8b2350 Refactor environment lookup functions 2019-08-15 15:56:50 +01:00
Leo White acd06f1eff Remove Misc.may_map and similar 2019-05-23 16:27:58 +01:00
Stefan Muenzel 5a88aeb0a5 Simplify matches that are an affine function of the input (#8547) 2019-04-09 22:52:24 +02:00
Mark Shinwell e141d9e240
Add a few utility functions in Misc (#2284) 2019-03-15 11:28:19 +00:00
Mark Shinwell 36c163248d Remove support for compiler plugins (#2276)
After consultation on the core developers' list I am proposing this patch to remove support for compiler plugins.

The main motivations for removing compiler plugins are:
- They are a potential security risk.
 - They increase the complexity of the build system and make maintenance of the Dynlink libraries more difficult (although actually, this complexity could probably be reduced after #2268 is merged).
 - Many applications of plugins should be able to be expressed by building custom compiler drivers that link against compilerlibs.

* Remove compiler plugins and hooks
* Add new function Dynlink.unsafe_get_global_symbol but keep it outside the documented API.
* Remove otherlibs/dynlink/nodynlink.ml
* Update Changes
2019-03-13 11:46:37 +01:00
Mark Shinwell c975b15de4 List prefix functions for Misc.Stdlib.List (#2283) 2019-03-06 11:59:03 +01:00
Armaël Guéneau 00411d41f4 ocamltest: explicitly set OCAML_ERROR_STYLE
Explicitly set OCAML_ERROR_STYLE to its default value when running tests,
instead of inheriting the one coming from the outside environment.
2019-02-27 15:13:56 +01:00
Gabriel Scherer dcc8a366aa env refactoring: move EnvLazy to utils/misc.ml 2019-02-16 11:40:28 +01:00
Gabriel Scherer 9847940c01 refactoring: new type aliases Misc.{filepath,modname,crcs,alerts} 2019-01-30 22:37:13 +01:00
Jeremie Dimino 7e0862a212 Refactor load path management and initial environment
- Add a Load_path module which caches files lookup

- Instead of falling back to the external environment, allow to
  declare in the environment that a module comes from the external
  world. This allows persistent structures to shadows non-persistent
  ones
2019-01-30 16:36:38 +00:00
Thomas Refis 742c65d30b List.filter_map (#2185) 2018-12-12 16:29:50 +01:00
Mark Shinwell c237f42521 Fix crc_interfaces stuff 2018-11-13 13:43:38 +00:00
Armaël Guéneau 6b16bcc4fe Add option -error-style and environment variable OCAML_ERROR_STYLE 2018-10-20 17:11:35 +02:00
Armaël Guéneau f954160614 Add source highlighting for errors & warnings in batch mode 2018-10-19 23:38:25 +02:00
Nicolás Ojeda Bär 2bf30a2fb2 Fix regression: return empty list of directories when PATH-like env var is empty 2018-10-10 14:55:04 +02:00
Nicolás Ojeda Bär 223f2e2ffa Add Misc.split_path_contents 2018-10-10 14:54:47 +02:00
Florian Angeletti 558530a8b4 manual: compiler-libs.mld -> compiler_libs.mld 2018-09-12 16:32:37 +02:00
Florian Angeletti ef135a71ae
MPR7546, manual: preambles and warnings for compiler-libs modules (#2020)
* preambles for compiler-libs modules

* Compilerlibs intro and warning link
2018-09-12 09:51:47 +02:00
Jérémie Dimino 9124ab82d1
Deprecate Pervasives (#1605)
- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.

- remove special case for Stdlib.Pervasives in printtyp.ml
2018-08-27 12:42:14 +01:00
Drup abc0b7e3ed Add compile_common.ml which contains the basic compilation pipeline.
Factorize the part from compile.ml and optcompile.ml.
2018-07-27 15:07:43 +02:00
Xavier Clerc 7e29162582 Pass the elements from `BUILD_PATH_PREFIX_MAP` to the assembler (#1930) 2018-07-27 12:25:23 +02:00
François Bobot da3f9f34f5 Use reraise_raw_backtrace in Misc.try_finally
And add labels ~always for previous cleanup function and
    ~exceptionally for new cleanup function in exceptional case
2018-07-25 17:58:32 +02:00
Gabriel Radanne 1be47bf7ab Just some tbl things. (#1699) 2018-07-23 13:19:41 +01:00
Xavier Clerc cd06e22582 Shadow the polymorphic comparison in the middle-end (#1811) 2018-07-11 13:50:02 +02:00
Gabriel Scherer 15c89485f3
Merge pull request #1723 from stedolan/remove-meta-static
Remove Meta.static_{alloc, free}.
2018-05-28 16:14:52 +02:00
Gabriel Scherer 559206b4e0 ocamlc -config: new -config-var option to print specific configuration variables
The proposed behavior of `-config-var s` is as follows:
- if `s` is an existing configuration variable, print its value as
  a string and exit with a success return value (0)
- if `s` is not an existing configuration variable, print nothing
  and exit with a failure return value (non-0)

Note that we do not print a newline after the value of the
configuration variable. In particular, if the value is an empty
string, the output is undistinguishable from the output for
non-existing variables, the return value has to be considered instead.

The following alternative behaviors were considered:

- We could print a newline after the configuration value, which
  would let users distinguish empty values from non-existing variables
  by counting the lines of output, and would also be more pleasant for
  users invoking the option from the command-line. However, the way
  bash works on Windows means that $(ocamlc -config-var foo) would keep
  a trailing \r in its output, and portable scripts would have to use
  $(ocamlc -config-var foo | tr -d '\r') instead, which is a pain.
  (This issue was pointed out by David Allsopp)

- We could print a message on the error output if the configuration
  variable does not exist. This is clearer to a human user, but it is
  annoying for scripts if they forget to silence the error output and
  get their output mixed with our error messages. The main use of this
  new feature is for scripting purposes.
2018-04-27 19:54:08 +02:00
Stephen Dolan 7f76b23531 Add LongString.blit_string 2018-04-13 17:11:37 +01:00
Stephen Dolan aa1dc8063a Remove Meta.static_{alloc, free}.
The bytecode runtime now represents code to be loaded as LongString.t,
rather than as a naked pointer to a bytecode block.

(This commit breaks Dynlink of bytecode, due to an issue about digests)
2018-04-13 16:29:33 +01:00
octachron e30e82a219 PR#7363: start documentation headers at {1 2017-10-04 13:05:05 +02:00
Xavier Leroy 071866c447 Create .cmi files atomically (MPR#7472) (#1307)
* MPR#7472: create .cmi files atomically

This is done by writing the data to a temporary file, compute the checksum, finish writing the data, and only then rename the temporary file to the destination .cmi file.

Writing .cmi files this way should avoid the corruption of .cmi files reported in MPR#4991.  This corruption can occur when a .cmi file is produced simultaneously by a run of ocamlc and a run of ocamlopt.

"Atomic" here means "as atomic as the underlying file system guarantees".  The atomicity guarantees of Windows file systems aren't entirely clear.

* Create .annot and .cmt files atomically, like .cmi files

Follow-up to MPR#7472.  The pattern "write to temporary file then rename"
is abstracted in the new function Misc.output_to_file_via_temporary
and applied to .cmi, .cmt and .annot files.
2017-09-06 20:01:15 +02:00
Pierre Chambart 177713ec02 Optimize away some physical equality (#850) 2017-08-01 08:04:03 +01:00
octachron 60ad2d8145 GPR#1187: Minimal documentation for compiler plugins 2017-06-01 18:22:09 +02:00
Max Mouratov d29f3f7104 Fixed erroneous comments 2017-03-28 16:02:05 +02:00
Hannes Mehnert 76bf7c568e Respect OCAML_COLOR environment variable for deciding whether to use colors
Since 4.03, OCaml supports coloring its messages to standard output and standard
error, depending on the "-color" argument ({always,never,auto}).  This commit
adds support for the environment variable "OCAML_COLOR" (which value can as well
be {always,never,auto}).

The command line argument "-color" takes precedence, "OCAML_COLOR" is only
taken into consideration if no "-color" is provided.

The motivation for this is that the user should have control over coloring
OCaml's output messages.  OCamlbuild, a widely used build tool executes OCaml
not under a tty (and OCaml does not colorize errors and warnings), which lead
various packages use `color(always)` in their `_tags` files, which breaks with
other (non-interactive) programs (i.e.  editor helpers).

Further discussion was done at https://github.com/ocaml/ocamlbuild/issues/87 and
https://github.com/ocaml/ocaml/pull/1098.
2017-03-15 08:24:13 +00:00
octachron c4d49c89c1 Add cross-reference detected by ocamldoc 2017-02-01 20:20:02 +01:00
Damien Doligez 0b4fbc2b30 fix whitespace, long lines, headers 2016-08-01 16:06:59 +02:00
alainfrisch d9f43d733e Wrap hook exceptions and have them printed with the standard mechanism instead of stopping the process. 2016-07-12 18:10:08 +02:00
Fabrice Le Fessant bfc36003aa Add hooks on some compilation phases 2016-07-12 17:59:58 +02:00
alainfrisch 19d513466e Misc.Stdlib.String.split -> String.split_on_char. 2016-07-11 15:01:32 +02:00
alainfrisch 15e83644b5 Misc.split -> String.split_on_char. 2016-07-11 14:55:40 +02:00
alainfrisch aa4f427591 Add Filename.extension and Filename.remove_extension.
The definition was suggested by Daniel Bunzli. It considers
that ".", "..", ".foo" all have an empty extension.

This commit also fixes chop_extension to align with this definition
and adds remove_extension which behaves as chop_extension but
does not fail when the extension is empty.

There used to be a Misc.chop_extension_if_any in the compiler code base.
The commit also replaces it with the new Filename.remove_extension.
2016-07-10 00:16:48 +02:00
Jeremie Dimino 68feb5f286 Add Misc.delete_eol_spaces 2016-03-01 10:36:24 +00:00
Jeremie Dimino b98461c3f3 Add Misc.protect_refs 2016-03-01 10:36:24 +00:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
David Allsopp 469810f822 Normalise \r\n to \n for deprecated warnings
The formatters used for printing warnings have text mode translation
enabled which means that any Windows endings which creep into warning
texts from deprecated attributes result in \r\r\n in the output.

The effect is largely innocuous, except that it causes the
deprecated_module_use test to fail on Windows.
2016-01-18 16:40:03 +00:00