ocamldep: Argument list too long

时间:2015-10-09 16:21:44

标签: ocaml

I'm having the infamous Argument list too long error when running ocamldep with a large number of input files.

This issue only happens when using a native Windows OCaml compiler + Cygwin: in this configuration, ARG_MAX returns 32000, an awfully low value, which I believe is a limit imposed by Windows itself, not Cygwin.

The usual solution for this kind of error is to use xargs, if we can split the arguments, such as when using ls or rm, but I don't know how it could work with ocamldep. Since it expects all files to be given in the command line at the same time (to properly compute dependencies), and there seems to be no option to give the list of files in a file (as in -f filelist.txt), is there a way to avoid this issue?

1 个答案:

答案 0 :(得分:0)

您可以使用xargs,因为您不需要一次列出ocamldep的所有文件。

例如,在OCaml编译器的源代码中,要了解GraphicsX11相对于Graphics的依赖关系,您不需要列出graphcs.ml

$ cd otherlibs/graphics
$ ocamldep graphicsX11.ml
graphicsX11.cmo : graphics.cmi graphicsX11.cmi
graphicsX11.cmx : graphics.cmx graphicsX11.cmi

但是,您必须使dependees可访问ocamldep,否则将被忽略。实际上GraphicsX11也依赖于Hashtbl,并且可以找到-I dir选项:

# Seek dependencies over stdlib modules too:
$ ocamldep -I ../../stdlib/ graphicsX11.ml
graphicsX11.cmo : ../../stdlib/hashtbl.cmi graphics.cmi graphicsX11.cmi
graphicsX11.cmx : ../../stdlib/hashtbl.cmx graphics.cmx graphicsX11.cmi

(我个人从未见过OCaml项目超过32000 ml / mli文件。哇。)