Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Wrong output of "camlp4 -where" #37

Open
murmour opened this issue Jan 28, 2016 · 10 comments
Open

Wrong output of "camlp4 -where" #37

murmour opened this issue Jan 28, 2016 · 10 comments

Comments

@murmour
Copy link

murmour commented Jan 28, 2016

OCaml binaries are installed in c:\OCaml, and ocamlc -where returns this path, yet camlp4 -where returns C:/ocamlmgw/lib\camlp4.

This seems to break compilation of Camlp4-related packages, e.g. type_conv.

@murmour
Copy link
Author

murmour commented Jan 28, 2016

And yes, the OCAMLLIB environment variable has a correct value of C:\OCaml\lib.

@msprotz
Copy link
Collaborator

msprotz commented Jan 28, 2016

Urgh. I can't rely on OPAM to install camlp4 properly because you still need a silly patch to make camlp4 compile on Windows... see camlp4/camlp4#41 (comment)

Or maybe you can try it? The issue says that you should be able to do it...?

@murmour
Copy link
Author

murmour commented Jan 28, 2016

I have built and installed the 4.02 branch of Camlp4 (by pinning the git repo), and camlp4 -where returns the correct path now: /cygdrive/c/OCaml/bin/camlp4. However, I still can't install type_conv, getting the same error message as before:

#=== ERROR while installing type_conv.113.00.02 ===============================#
# opam-version 1.2.2
# os           cygwin
# command      make
# path         /home/mrm/.opam/system/build/type_conv.113.00.02
# compiler     system (4.02.3)
# exit-code    2
# env-file     /home/mrm/.opam/system/build/type_conv.113.00.02/type_conv-2464-ffb3fd.env
# stdout-file  /home/mrm/.opam/system/build/type_conv.113.00.02/type_conv-2464-ffb3fd.out
# stderr-file  /home/mrm/.opam/system/build/type_conv.113.00.02/type_conv-2464-ffb3fd.err
### stdout ###
# [...]
# pkg_camlp4_extend: ................................... C:/OCaml/lib/camlp4
#
# ./setup.exe -build
# mkdir 'C:\wodi32\home\mrm\.opam\system\build\type_conv.113.00.02\_build'
# ''ocamlfind ocamlc unix.cma -I 'C:\OCaml\lib\ocamlbuild' 'C:\OCaml\lib\ocamlbuild/ocamlbuildlib.cma' -linkpkg myocamlbuild.ml 'C:\OCaml\lib\ocamlbuild/ocamlbuild.cmo' -o myocamlbuild.exe
# mkdir src
# ''C:/wodi32/home/mrm/.opam/system/bin/ocamlfind.EXE ocamldep -syntax camlp4o -package camlp4.quotations -package camlp4.extend -modules src/pa_type_conv.mli > src/pa_type_conv.mli.depends
# Exit code 2 while executing this command:
#   ''C:/wodi32/home/mrm/.opam/system/bin/ocamlfind.EXE ocamldep -syntax camlp4o -package camlp4.quotations -package camlp4.extend -modules src/pa_type_conv.mli > src/pa_type_conv.mli.depends
# Makefile:21: ошибка выполнения рецепта для цели «build»
### stderr ###
# Camlp4: Uncaught exception: DynLoader.Error ("Camlp4OCamlRevisedParser.cmo", "file not found in path")
#
# File "src/pa_type_conv.mli", line 1:
# Error: Error while running external preprocessor
# Command line: camlp4 "-I" "C:/OCaml/lib/camlp4" "-I" "C:/OCaml/lib/camlp4" "-I" "C:/OCaml/lib/camlp4" "-I" "C:/OCaml/lib/camlp4" "-parser" "o" "-parser" "op" "-printer" "p" "-parser" "Camlp4QuotationCommon" "-parser" "Camlp4OCamlRevisedQuotationExpander" "-ignore" "foo" "-parser" "Camlp4GrammarParser"  "src/pa_type_conv.mli" > C:\wodi32\tmp\ocamlpp6a61ab
#
# E: Failure("Command 'C:\\OCaml\\bin\\ocamlbuild.EXE -classic-display -no-log -no-links -install-lib-dir C:\\OCaml\\lib\\ocamlbuild -byte-plugin src/pa_type_conv.cma src/pa_type_conv.cmxa src/pa_type_conv.a src/pa_type_conv.cmxs -use-ocamlfind -tag debug' terminated with error code 2")
# make: *** [build] Ошибка 1

As if Camlp4 couldn't locate C:/OCaml/lib/camlp4/Camlp4Parsers...

@murmour
Copy link
Author

murmour commented Jan 28, 2016

The root of the problem seems to be neither in OASIS nor in ocamlbuild:

$ camlp4 -I "C:/OCaml/lib/camlp4" "-parser" "o"
Camlp4: Uncaught exception: DynLoader.Error ("Camlp4OCamlRevisedParser.cmo", "file not found in path")

@msprotz
Copy link
Collaborator

msprotz commented Jan 28, 2016

huh. the dynloader should try to load a cmxs, shouldn't it?

@murmour
Copy link
Author

murmour commented Jan 28, 2016

camlp4 is a byte-compiled executable, so it needs a .cmo.

@murmour
Copy link
Author

murmour commented Jan 28, 2016

Suddenly, this works:

camlp4 -I "C:/OCaml/lib/camlp4" "-parser" Camlp4Parsers/Camlp4OCamlRevisedParser.cmo

And even without specifying the search path:

camlp4 "-parser" Camlp4Parsers/Camlp4OCamlRevisedParser.cmo

Puzzling. Seems like a yet another path-handling-related bug in Camlp4.

@murmour
Copy link
Author

murmour commented Jan 28, 2016

This did the trick:

export CAMLP4LIB=C:/OCaml/lib/camlp4

I'm not sure how or why does it work, but the installer can also set this variable, at least as a temporary workaround. Something is probably wrong with handling those paths in Camlp4, but I haven't figured that out yet.

@msprotz
Copy link
Collaborator

msprotz commented Jan 29, 2016

Can you submit a pull request?

(I'm short on time right now.)

Thanks,

Jonathan

@murmour
Copy link
Author

murmour commented Feb 7, 2017

Hello. I haven't figured out how to add this environment variable into the installation script (I'm not familiar with NSIS), and I didn't have time to test the modified installer, so I put that "export" line into my .bashrc and it didn't bother me after that.

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

No branches or pull requests

2 participants