thierry-martinez / stdcompat

Stdcompat: compatibility module for OCaml standard library
BSD 2-Clause "Simplified" License
31 stars 13 forks source link

./configure overwrites /dev/null #18

Closed marc-chevalier closed 2 years ago

marc-chevalier commented 2 years ago

When installing (with opam) in root and without sandbox, or manually (I have my reasons: I'm fighting with a terrible non-ocaml build system), the ./configure step overwrite /dev/null. To reproduce, as root:

export OPAMROOT=/opt/.opam  # For instance
opam init --bare --disable-sandboxing
opam switch create 4.14.0
opam install ocamlfind seq  # can also work with result or uchar instead of seq
# Everything is fine here
opam install stdcompat
# Now /dev/null is replaced by a normal file

I think I found the cause of that:

4028:      if $OCAMLFIND c -package result configure_test.ml -o /dev/null >/dev/null 2>&1; then :
4053:      if $OCAMLFIND c -package seq configure_test.ml -o /dev/null >/dev/null 2>&1; then :
4078:      if $OCAMLFIND c -package uchar configure_test.ml -o /dev/null >/dev/null 2>&1; then :

The -o dev/null seems dangerous in this case. Maybe one could remove it and change the next line from

rm configure_test.ml

to

rm configure_test.*

? Not sure this if this is good enough. But it seems to work for me. I can submit a PR if this fix suits you.

EDIT: I mean, change it in configure.ac of course.

thierry-martinez commented 2 years ago

Thank you very much, @marc-chevalier, for reporting this and sorry for the delay. I fixed this along the lines you described (but just removing the -o option and deleting all configure_test.* files are not enough because ocamlc outputs in a.out by default: instead, I replaced -o /dev/null by -o configure_test.out). I don't think this behavior of ocamlc is expected: I reported an OCaml issue.

marc-chevalier commented 2 years ago

Maybe a stupid question: why going with an improved version of my fix rather than using ocamlopt? If I understand your issue on ocaml correctly, it should work as expected.

thierry-martinez commented 2 years ago

There used to be some environments which did not support native code compilation and where bytecode compiler was the only option. Not sure if it is true anymore.