New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in set_binary_mode out for cygwin #3818
Comments
Comment author: administrator I have done my own experiment and I saw translation to \r\n: let _ = set_binary_mode_out stdout true in I checked with emacs hexl-mode and I saw that \r\n is present there. Ah, I installed cygwin in DOS mode!!! This must be it. But this still argues that set_binary_mode_out should do something, because you do not know how cygwin was installed. But here is the actual thing that hit me: If you try to use camlp4 the ocamlc compiler crashes: ocamlc -pp "camlp4o pa_macro.cmo" -I +camlp4 -c foo.ml
I can work around this problem in two ways. I can add pr_o.cmo to the camlp4o command above, which will make camlp4 print Ocaml source not binary AST. Or, I can change ocamlc to not pipe the results of the pretty printer to stdout, but send it directly to the temporary file (change format string in driver/pparse.ml to use format string "%s %s -o %s"). Clearly in this later case the code in pr_dump.ml is able to set the binary mode because it uses open_out_bin instead of set_binary_mode_out. As you can see, if you do not fix the set_binary_mode_out (which I think should be done), we must fix how the preprocessor is invoked in ocamlc. George.
|
Comment author: administrator George, As you noticed, set_binary_mode_out has no effect on Cygwin. However, I'm not sure this is the source of your problem: stdout seems Do you have a small example showing the bug in camlp4? Cheers, -- Michel necula@cs.berkeley.edu wrote:
-- Mail: michel@mauny.net |
Comment author: administrator Merci beaucoup! Ca marche. George.
|
Comment author: administrator
Right. I activated set_binary_mode_out (as well as the predicate The patch is easy: diff -r1.71 byterun/io.c
|
Comment author: administrator Don't do the suggested change in driver/pparse.ml, it would break using sed as Fixed 2005-10-25 -MM |
Original bug ID: 3818
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: George Necula
Version: 3.08.4
OS: Win XP/cygwin
Submission from: adsl-63-204-134-90.dsl.snfc21.pacbell.net (63.204.134.90)
I have discovered that "set_binary_mode_out c true" has no effect on cygwin. In
fact, this function does nothing except when compiling for Windows (but not for
cygwin).
This is a big problem because it prevents the use of the -pp option for ocamlc
on cygwin. camlp4 will print the AST to stdout and will use set_binary_mode_out.
When ocamlc reads in the AST it segfaults. The workaround is to make sure you
add pr_o.cmo to the preprocessor command, to ensure that Ocaml source is piped
to stdout.
The text was updated successfully, but these errors were encountered: