facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 205 forks source link

Can't build on Mac #158

Open voidcenter opened 6 years ago

voidcenter commented 6 years ago

Hi, I'm having trouble getting pfff built on Mac and the error message is:

Error: The implementation common.ml does not match the interface common.cmi:
       Values do not match:
         val read_file : string -> bytes
       is not included in
         val read_file : filename -> string
       File "/Users/{}/git/pfff/commons/common.mli", line 55, characters 0-34:
         Expected declaration
       File "/Users/{}/git/pfff/commons/common.ml", line 838, characters 4-13:
         Actual declaration
make[2]: *** [common.cmo] Error 2

Seems like there is a signature mismatch for the read_file function. Wonder if anyone else is having the same problem?

macOS High Sierra 10.13.4

$ uname -a
Darwin {} 17.5.0 Darwin Kernel Version 17.5.0: {}; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,4 Darwin

The OCaml toplevel, version 4.06.1

Thx~

aryx commented 6 years ago

Do you use opam? Can you try to switch to ocaml 4.02.3 and check it it works? I think recent ocaml versions make a strong difference between strings and bytes (they use to be the same type).

voidcenter commented 6 years ago

Hi @aryx , thanks for the reply. I uninstalled ocaml 4.06.1 and switched to ocaml 4.02.3:

$ opam config list
# Global OPAM configuration variables

user                 {}
group                staff
make                 make
os                   darwin
root                 /Users/{}/.opam
prefix               /Users/{}/.opam/system
lib                  /Users/{}/.opam/system/lib
bin                  /Users/{}/.opam/system/bin
sbin                 /Users/{}/.opam/system/sbin
doc                  /Users/{}/.opam/system/doc
stublibs             /Users/{}/.opam/system/lib/stublibs
toplevel             /Users/{}/.opam/system/lib/toplevel
man                  /Users/{}/.opam/system/man
share                /Users/{}/.opam/system/share
etc                  /Users/{}/.opam/system/etc

# Global variables from the environment

ocaml-version        4.02.3               # The version of the currently used OCaml compiler
opam-version         1.2.2                # The currently running OPAM version
compiler             system               # The name of the current OCaml compiler (may be more specific than the version, eg: "4.01.0+fp", or "system")
preinstalled         true                 # Whether the compiler was preinstalled on the system, or installed by OPAM
switch               system               # The local name (alias) of the current switch
jobs                 4                    # The number of parallel jobs set up in OPAM configuration
ocaml-native         true                 # Whether the OCaml native compilers are available
ocaml-native-tools   true                 # Whether the native ".opt" version of the OCaml toolchain is available
ocaml-native-dynlink true                 # Whether native dynlink is available on this installation
arch                 x86_64               # The current arch, as returned by "uname -m"

# Package variables ('opam config list PKG' to show)

PKG:name                                  # Name of the package
PKG:version                               # Version of the package
PKG:depends                               # Resolved direct dependencies of the package
PKG:installed                             # Whether the package is installed
PKG:enable                                # Takes the value "enable" or "disable" depending on whether the package is installed
PKG:pinned                                # Whether the package is pinned
PKG:bin                                   # Binary directory for this package
PKG:sbin                                  # System binary directory for this package
PKG:lib                                   # Library directory for this package
PKG:man                                   # Man directory for this package
PKG:doc                                   # Doc directory for this package
PKG:share                                 # Share directory for this package
PKG:etc                                   # Etc directory for this package
PKG:build                                 # Directory where the package was built
PKG:hash                                  # Hash of the package archive

But when I do make depend I got the following errors:

Fatal error: unknown C primitivecaml_add_debug_info'`

I did some search but the answer seems not helpful. Wonder how shall I solve this problem?

Thx!

QuyTran commented 6 years ago

same on my side also,

➜ pfff git:(master) make /Library/Developer/CommandLineTools/usr/bin/make rec /Library/Developer/CommandLineTools/usr/bin/make -C commons ocamlc.opt -g -dtypes -bin-annot -absname -thread -w +9 -I ocamlextra -I ocollection -c common.ml File "/Users/quytran/Working/pfff/commons/common.ml", line 252, characters 16-25: Warning 3: deprecated: Obj.final_tag Replaced by custom_tag. File "/Users/quytran/Working/pfff/commons/common.ml", line 841, characters 12-25: Warning 3: deprecated: String.create Use Bytes.create instead. File "/Users/quytran/Working/pfff/commons/common.ml", line 1: Error: The implementation common.ml does not match the interface common.cmi: Values do not match: val read_file : string -> bytes is not included in val read_file : filename -> string File "/Users/quytran/Working/pfff/commons/common.mli", line 55, characters 0-34: Expected declaration File "/Users/quytran/Working/pfff/commons/common.ml", line 838, characters 4-13: Actual declaration make[2]: [common.cmo] Error 2 make[1]: [rec] Error 2 make: *** [all] Error 2

is there any work around for it? thanks

aryx commented 6 years ago

Ok, I've added a fix in my fork of pfff: try https://github.com/aryx/pfff (I do not have commit write anymore to this repository since I left facebook).

note that before make depend you will also need to do make -C external (follow the instructions shown by ./configure)

QuyTran commented 6 years ago

thanks @aryx, let me try again

zoidyzoidzoid commented 6 years ago

@aryx There are a lot of commits in your fork. Would it be possible to try get Facebook to deprecate their repo and recommend yours instead? Or at least give you commit rights to this repo?

aryx commented 6 years ago

I'm the main author of Pfff but I don't work at Facebook anymore so I doubt I can get the commit rights. Just use my fork. @phooji may know if it's possible for Facebook to deprecate facebook/pfff or at least edit the readme or project line to redirect to my repo.