ocaml-ppx / ppx_getenv

A sample syntax extension using OCaml's new extension points API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to compile on OS X

johnwhitington opened this issue · comments

We get...

feast:ppx_getenv john$ make
ocaml setup.ml -build 
W: No exported module defined for library ppx_getenv
W: No exported module defined for library ppx_getenv
Finished, 0 targets (0 cached) in 00:00:00.
+ /Users/john/.opam/4.02.0/bin/ocamlfind ocamlopt -a -o lib/ppx_getenv.cmxa
ar: no archive members specified
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
File "_none_", line 1:
Error: Error while creating the library lib/ppx_getenv.a
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in 00:00:00.
E: Failure("Command ''/Users/john/.opam/4.02.0/bin/ocamlbuild' lib/ppx_getenv.cma lib/ppx_getenv.cmxa lib/ppx_getenv.a lib/ppx_getenv.cmxs lib/ppx_getenv.native -use-ocamlfind -tag debug' terminated with error code 10")

Google suggests that, on OS X, ar does not like an empty archive, and this is the reason for the failure.

This is basically a problem with OASIS. I can get rid of it by getting rid of OASIS and migrating to topkg for packaging. Not sure if that's what you would expect.

Thanks. Anything which works would be great.

I tried using a Linux VM, but OPAM failed on installing one of the prerequisites -- so I can't find a platform I can build ppx_getenv on yet. I'll submit that bug elsewhere.

What I'm trying to write is, I think, a pretty trivial ppx extension. I want to convert the annotated string [%blob "file.dat"] to the string which contains, instead, the contents of file.dat. This will allow the inclusion of binary blobs of data as strings in the AST without having to worry about OCaml's lexical conventions. So I can then compress such data, and reduce executable size.

Essentially ocamlify, right? I approve :)

Exactly. http://www.github.com/cpdf-source needs to be a self-contained binary, but it also needs all sorts of font tables and data, which it parses on first use -- at the moment they make up about 600k of a 2Mb executable, but zipped they would be more like 150k (and cpdf uses camlzip for other things anyway).

Concerning OASIS:
You are actually creating a "fake" library with "Library ppx_getenv". This library has no modules and this is the warning you see when running (I should transform it into an error).

To solve your problem, you just have to

  • remove the fake library
  • write a META file and place it in "FilesAB: src/META.ab"
    version = "$(pkg_version)"
    ppx = "ppx_getenv"
  • Add a PostInstallCommand: $ocamlfind install src/META

Note that the failure of creating empty archives is an OSX-specific bug. It has been reported on the OCaml bugtracker (PR#6550), but in the end it's a bug in the OS X toolchain, which Apple knows about and isn't interested in. Use a better operating system.