I can observe weird performance bottlenecks on my machine caused by
the use of 'cp' in the 'install' scripts of OCaml. When installing
into a directory that is already populated by an existing
installation, 'make install' can routinely take 10s on my machine¹. After this
change it reliably takes 1.5s, independently of whether the
destination is already populated or not.
¹: a brtfs filesystem on an old-ish SSD
Why I care
----------
An extra 10s delay due to 'make install' can be noticeable in tight
change-build-install-test feedback loops for a compiler change where
we change the compiler, have a fast 'make world.opt' due to
incremental builds, install the change and test it -- possibly after
installing a couple opam packages, which can be fairly quick.
Partial diagnosis
-----------------
The performance issue seems to be caused by the fact that 'cp' (at
least the GNU coreutils version), when the file already exists,
replaces it by opening it in writeonly+truncate mode and writing the
file content ('strace' shows that the delay is caused within an
'openat' call). In particular, using the --remove-destination option
(which changes 'cp' to just remove the destination file before
copying) removes the performance issue, but this option seems missing
from the BSD/OSX 'cp' so it could cause portability issue.
Change
------
The present commit rewrites the 'install' targets of all Makefiles to
use the 'install' command instead. 'install' by default gives
executable-like permission to the destination file, instead of reusing
the source file's permissions, so we specify manually the permission
modes, depending on whether the installed file is an executable (or
dynamically-linked library) or just data (including other compiled
object files).
Testing
-------
I checked manually that the permissions of the installed files are
identical to the ones of the current 'cp'-using targets, except for
some '.mli' file in middle_end which currently have +x bits enabled
for no good reason.
Remark: To test this, playing with the DESTDIR variable is very useful
(this lets you install to a new directory (or the same as before)
without having to re-run the configure script). I used the following,
fairly slow shell script to collect permissions:
for f in $(find $DESTDIR); do \
echo $(basename $f) $(ls -l $f | cut -d' ' -f1); \
done | sort
Remark: it is important to run `sync` in-between 'make install' runs
to avoid timing effects due to filesystem or disk caching
strategies. I believe that this corresponds to the natural time delay
(and unrelated disk activity) that would occur in realistic
change-install-test feedback loops.
-(un)safe-string becomes -(no-)force-safe-string
-(un)safe-string-default becomes -default-unsafe-string
Config.safe_string (and Clflags.unsafe_string) keep their name for
backward-compatibility, as well as the C define CAML_SAFE_STRING
(which corresponds to -force-safe-string).
In $(INSTALL_LIBDIR) there can be leftover files from an earlier installation of OCaml, including files from the now defunct otherlibs/num library. Those files can cause findlib/ocamlfind to think that the Num library is still provided by the core OCaml distribution.
This is a temporary hack, to be cleaned up in 4.07 for example.
This commit moves:
- config/m.h to byterun/caml/m.h
- config/s.h to byterun/caml/s.h
Consequently, m.h and s.h now get installed alongside other
OCaml header files.
This commit also updates the .depend files, introducing updates in the
dependencies which are not consequences of this commit itself.
With this commit, 'make alldepend' will stop and report an error as
soon as one of the invoked command fails, which was not the case before.
This commit thus makes it possible to test that 'make alldepend' works
in an automated way.
Require flexlink.opt to be specified. Old behaviour:
make flexdll world.opt install
now becomes:
make flexdll world.opt flexlink.opt install
Without flexlink.opt, a bytecode version of flexlink.exe is installed.
The install-flexdll target now puts the object files for FlexDLL in a
subdirectory flexdll of the Standard Library instead of in the Standard
Library itself.
A configuration tweak means that -I +flexdll is effectively added to all
compiler invocations and also a pseudo-option -L+flexdll to ocamlmklib
calls to Config.mkdll which fixes PR#7373.
The code in this commit was written by Marcell Fischbach & Benedikt Meurer.
See [Mantis#5324](http://caml.inria.fr/mantis/view.php?id=5324) for some
context.
The code (which was originally written against 3.12) was ported to trunk by
doing
```bash
git clone https://github.com/bmeurer/ocaml-experimental/
cd ocaml-experimental
git diff master...linear-scan-register-allocator > t.diff
```
and then applying the diff by hand.
Run 'make lintapidiff' in the root of a git checkout to get a list of
potentially missing or wrong @since annotations.
The tool is not built by default, you have to first run 'make
world.opt', and then run 'make lintapidiff'.
lintapidiff doesn't support stop comments: add explicit list of changes to ignore.
see copyright header for license.
This target thus becomes available under Windows (Makefile.nt did not
define it).
Since no other rule makes use of this target, its usefulness needs to be
confirmed.
Before this commit, the rule was more sequential on the Unix build system
than on the Windows one. The more sequential version has been kept
so as not to break parallel builds.
Note: since commit dd74659c68, the
coreboot target on the Unix build system calls make promote with
CAMLRUN=byterun/ocamlrun, which the equivalent target on the Windows
system did not use before the present commit.
The present commit uses CAMLRUN=byterun/ocamlrun on both build systems.
On Unix core builds coldstart and coreall while on Windows core builds runtime
and coreall. This behaviour has been preserved but needs to be
clarified.
On the Unix build system, this recipe was creating stdlib/caml as a symlink
to byterun/caml. This is no longer done because it is not done on
Windows either and seems not useful.
It will however be available only on Unix because checkstack does not
yet work on Windows.
This commit removes the '@' character in front of the commands of
the checkstack rule to make debugging easier.
It also fixes the target by ensuiring that the $(EXE) extension
is used everywhere.
On Unix the otherlibraries target depends on ocamltools, which was not
the case under Windows before this commit. This commit keeps the Unix
version to make sure no constraint is lost.
On Windows the ocamllex and ocamllex.opt target did not depend on
anything, whereas they did on Unix. The dependencies have been kept as
they were under Unix to make sure no constraint is lost.
However the dependencies between ocamllex and ocamllex.opt do not seem
very coherent either.
Before this commit, ocamlyacc.byte was installed as ocamlyacc
unconditionally and then overwritten by ocamlyacc.opt, if available.
After this commit, ocamlyacc is provided as a symlink to (or copy of)
ocamlyacc.byte only if the native code version is not available.
This commit also makes sure the man pages get installed only on Unix
systems. This is useless at the moment but will become useful once the
install rule will be shared.
If appropriate, install flexdll/flexlink.opt as
$(INSTALL_BINDIR)/flexlink$(EXE). This will not happen under Unix where
flexlink is not compiled but makes this target identical to its Windows
counterpart.
This commit replaces idioms like ``cd dir; $(MAKE) foo'' and
``cd dir && $(MAKE) foo'' by ``$(MAKE) -C dir foo''.
In Makefile.nt, the command ``$(MAKEREC) installoptopt'' has also been
replaced by ``$(MAKE) installoptopt''.
This commit affects the recipe used to generate utils/config.ml
from utils/config.mlp. It adds an expression to the sed command to
replace the %%FLEXLINK_FLAGS%% token by a value. Given that this
variable is not defined for Unix build this will have no effect, except
making the recipe identical to the one used on the Windows build system.
The recipes to build utils/config.ml from utils/config.ml in Makefile
and Makefile.nt essentially are sed invocations with several
expressions. This commit sorts the expressions in alphabetical order in
both files and also makes sure all the expressions use the same
quoting style, namely single quotes.
This has no practical effect but makes the two recipes easier to
compare.
This commit removes the line introduced by commit
59853fa694
Since the proposal to have separate variables for warning
options has been implemented, such a precaution should no longer be
necessary. Moreover, this had been implemented for the Unix build system
only, not for the Windows one.
These variables represent the C compilers ocamlc and ocamlopt should use
to compile a third-party C source file when no -cc command-line option
has been specified.
Thanks to these variables, the substitutions performed in Makefile and
Makefile.nt to generate utils/config.ml from utils/config.ml become
similar.
(The NATIVE_C_COMPILER variable is not really necessary but it has still
been introduced to preserve symetry.)
This variable is used to give a value to standard_runtime in
utils/config.ml.
Before this commit, its values were hard-coded in Makefile and
Makefile.nt, in the rules generating utils/config.ml from utils/config.mlp.
This commit gets rid of this hardcoding, to prepare the sharing of the
rules mentionned above.
This commit modifies these two behaviours:
1. ``make install'' installs libraries with profiling support only when
this makes sense.
2. On platforms that do not support profiling with gprof, the -p option of
ocamlopt produces an error message.
On such platforms, ``make install'' was installing dummy profiling
libraries and ocamlopt's -p option was silently ignored.
In addition, this commit modifies the values of the PROFILING make
variable. Before the commit it was either prof or noprof. After the
commit it is either true or false.
In the asmrun directory, the call to ranlib for libasmrunp.a has also been
removed from the install target because this command is already invoked
in the rule that builds libasmrunp.a.
ocamlc/ocamlopt -config now prints the state of profiling support
This reverts commit 8adfe15f18.
This is a temporary revert caused by Continuous Integration
failure. We'll investigate the issue and merge again when it is fixed.
This commit modifies these two behaviours:
1. ``make install'' installs libraries with profiling support only when
this makes sense.
2. On platforms that do not support profiling with gprof, the -p option of
ocamlopt produces an error message.
On such platforms, ``make install'' was installing dummy profiling
libraries and ocamlopt's -p option was silently ignored.
In addition, this commit modifies the values of the PROFILING make
variable. Before the commit it was either prof or noprof. After the
commit it is either true or false.
In the asmrun directory, the call to ranlib for libasmrunp.a has also been
removed from the install target because this command is already invoked
in the rule that builds libasmrunp.a.
ocamlc/ocamlopt -config now prints the state of profiling support
Before this commit, there was no distinction between the options
used to compile C source files coming with the OCaml distribution
and third-party C source files compiled by calling ocamlc or ocamlopt.
This commit makes it possible to use options when compiling C source
files that come with OCaml without imposing these options to the compilation
of third-party code.
More specifically, the options in the BYTECCCOMPOPTS and NATIVECCCOMPOPTS
variables are not passed to the C compiler when called by ocamlc and
ocamlopt any longer.
This commit also documents the role of each concerned variable.
In addition:
- On Unix:
* The -Wall and -Werror options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
- For the MinGW port:
* The -O option has been removed from the SHAREDCCCOMPOPTS variable
* The -Wall and -Wno-unused options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
- For the msvc port: the
* The -Ox option has been removed from the SHAREDCCCOMPOPTS variable.
* The -Wall and -Wno-unused options are no longer passed to the C
compiler by ocamlc and ocamlopt for third-party C source files
Before this commit, 'make ocamlnat' was building 'ocamlnat' without any
extension, even on Windows. The extension was added by 'make install', though.
With this commit, 'ocamlnat' is given its $(EXE) extension already
at build time.
When configured with -safe-string, the OCaml tools will default to the
safe-string mode and ignore -unsafe-string command-line arguments. This
is intended to serve two purposes:
- Facilitate the detection of packages that are not ready
for -safe-string ready. (Perhaps with some OPAM switch?)
- Enable some optimizations that assume that all linked units are
compiled with -safe-string.
Note: currently, there is no check that units compiled with an OCaml
configured without -safe-string are not linked in.
Previously, `ocamlc`, `ocamlopt`, `ocamllex`, and `ocamldep` defaulted
to the bytecode versions of the tools. However, there is normally no
advantage to the bytecode versions if the native-code versions are
available, except in unusual circumstances. Instead, install the
native-code versions without the `.opt` suffix. They are still
installed with the `.opt` suffix for backwards compatibility. Finally,
install the bytecode versions with the `.byte` suffix, and build
native-code versions of tools that are not currently built in native
code.
Also, remove some duplication in tools/Makefile.shared.
Supersedes GPR #512.
The stripping is done during bootstrap, when copying the new ocamlc, ocamllex and ocamldep to boot/. The new "stripdebug" tool performs this task.
As a consequence, comparing the new compilers with the boot/ compilers at the end of bootstrap is more complicated, since the debug section must be ignored. A new tool, "cmpbyt" in tools/, performs this comparison.
(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
The risk of breakage of 3rd-party libraries is too high.
There might be cleaner ways to achieve this effect, e.g. split BYTECCCOMPOPTS into BYTECCCOMPOPTS and BYTECCEXTRAWARNINGS.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/cc-optim@16337 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02