Skip to content
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

ocamlbuild -where on MinGW produces wrong path #4575

Closed
vicuna opened this issue Jul 2, 2008 · 5 comments
Closed

ocamlbuild -where on MinGW produces wrong path #4575

vicuna opened this issue Jul 2, 2008 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jul 2, 2008

Original bug ID: 4575
Reporter: hansr
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:31:20Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.2
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues

Bug description

$ ocamlbuild -classic-display -no-log
Failure: Cannot find "ocamlbuildlib.cmxa" in ocamlbuild -where directory.
$ ocamlbuild -where
/ocamlbuildFiles\Objective Caml\lib

Seems to overwrite the path instead of appending to it.

Workaround:
ocamlbuild -install-lib-dir C:\Programfiler\Objective Caml\lib\ocamlbuild ...

This seems to have been noticed in version 3.10.0 as well
http://caml.inria.fr/pub/ml-archives/caml-list/2000/09/4b40f92c435feedad2c78316cb97ac12.en.html
but I could not find it reported as a bug.

Hans Ole

@vicuna
Copy link
Author

vicuna commented Oct 1, 2008

Comment author: @ygrek

Search for "program files" in ocamlbuild.exe - it has '\r' character in path (hence console output). Tracking source leads to my_std.ml String.chomp
let chomp s =
let ls = length s in
if ls = 0 then s
else if s.[ls-1] = '\n' then sub s 0 (ls - 1)
else s

Taking into account Mac OS too, maybe something like this will do :

open String

let chomp s =
let is_bad ch = match ch with | '\n' | '\r' -> true | _ -> false in
let rec cut n =
if n = 0 then 0 else if is_bad s.[n-1] then cut (n-1) else n
in
let ls = length s in
let n = cut ls in
if n = ls then s else sub s 0 n

let test s s1 = print_endline (if s1 = chomp s then "ok" else "failed")

let _ =
test "dsds" "dsds";
test "dsds\n" "dsds";
test "dsds\r" "dsds";
test "dsds\r\n" "dsds";
test "dsds\r\r\n" "dsds";
test "dsds\n\r" "dsds";
test "\r\n" "";
test "" ""

@vicuna
Copy link
Author

vicuna commented Oct 1, 2008

Comment author: ertai

Thanks for pointing out the bug in chomp. I've applied your change to the CVS tree, let me now if it fixes the whole problem with -where on MinGW

@vicuna
Copy link
Author

vicuna commented Oct 6, 2008

Comment author: @ygrek

I don't use mingw. But this issue was present on msvc build too (though it showed only as console output otherwise everything worked ok). So I grabbed cvs and built with msvc. Unfortunately the resulting ocamlbuild couldn't run because of AV in ocamlrun. It is built without symbols so I couldn't debug it.

But at least the offending string in ocamlbuild.exe doesn't contain \r character.

@vicuna
Copy link
Author

vicuna commented Oct 6, 2008

Comment author: @ygrek

Rebuilt with pdb and found that it picked dlls from OCAMLLIB (for 3.10) hence crash.
Now it works ok :

ocamlbuild.exe -where
D:\temp\ocaml-cvs-build\lib\ocamlbuild

@vicuna
Copy link
Author

vicuna commented Oct 7, 2008

Comment author: hansr

Tested against version 3.11+dev19 Private_abbrevs+natdynlink+lazy_patterns+fscanf debug (2008-10-06)

in bash:
/cygdrive/c/ocamlmgw/bin/ocamlbuild.exe -where
C:/ocamlmgw/lib/ocamlbuild

in cmd:
C:\Documents and Settings\rafhan>c:\ocamlmgw\bin\ocamlbuild.exe -where
C:\ocamlmgw\lib\ocamlbuild

(Though, it has some problems running /cygdrive/c/ocamlmgw/bin/ocamlbuild.exe
Fatal error: unknown C primitive `caml_set_parser_trace'
and similar in a CMD window which lacks mkdir and bash. Probably some error I did while building it/running it.)

So that problem seems to be fixed with that patch.

Thanks,

Hans Ole

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant