[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#786913: Bug#794583: ocaml: Allow setting arbitrary RNG seed in ocamlopt



Le 04/08/2015 18:41, Valentin Lorentz a écrit :
> While working on the “reproducible builds” effort [1], we have noticed
> that ocamlopt relies on temporary files whose names are generated
> randomly and are part of the output files' symbols.

See #795784, #796336 and #786913.

> Therefore, we need a way to make these names determinist. [...]

I don't agree with this conclusion; I'd rather use a way to not record
those random names in the first place, or set them to some sane value
without messing with file names.

GCC also uses temporary files whose names are generated randomly (this
can be seen with the -v option). But it arranges for these random names
to not appear in compiled objects.

For example, with assembly files, the name of the "source" file (which
is then recorded in compiled objects) can be given with a ".file"
directive. gcc adds them to its assembly files. And adding such
directives to assembly files generated by ocamlopt solves #795784 and
#796336.

For #786913, temporary files are C files. Ideally, a ".file" counterpart
should exist for C files (I thought of "#line" cpp directives, but they
don't work... maybe we should make them work?). However, I've found a
way to tell gcc to not record the file name, using stdin: gcc -x c -c -o
foo.o < foo.c. I would very much prefer a ".file"-like directive, though.

> [...] For instance,
> reading an environment variable in the main function of ocamlopt
> (driver/optmain.ml) and calling “Random.seed 0” if it is set would be
> perfect.
> Using OCAMLPARAM (driver/compenv.ml) would work as well.

I am not thrilled by this proposition. Filename.temp_file is the
equivalent of mkstemp, and mkstemp doesn't have this "feature".


Cheers,

-- 
Stéphane


Reply to: