facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.83k stars 2k forks source link

Infer cannot be supported by Macbook M1 #1718

Open cshezhang opened 1 year ago

cshezhang commented 1 year ago

I think Infer cannot be installed via Homebrew in Macbook M1 devices. Can you provide some suggestions or improve the framework?

dsmiley commented 1 year ago

If there was an official Docker image (not merely instructions on how to build your own), this would be an option. But there isn't.

jay7x commented 1 year ago

I was able to build the docker image from master branch with some minor fixes on my Macbook Pro M1. It took me a while because the requirements were surprisingly high.. The build succeed with 24Gb RAM and 200Gb of disk space allocated to the VM where the docker was running.

Below is the Dockerfile diff I did. I was too lazy to fix it properly so just went the build-infer.sh way. Then I was looking for just C analysis so I've enabled clang only.

LD was changed to gold in attempt to solve RAM consumption.. though I saw 2x ld processes consuming ~15Gb and ~8Gb each anyway.. not sure if it worth the change.

diff --git a/docker/master/Dockerfile b/docker/master/Dockerfile
index cf0d77d148..ad7f367171 100644
--- a/docker/master/Dockerfile
+++ b/docker/master/Dockerfile
@@ -44,12 +44,11 @@ RUN cd / && \
 # Build opam deps first, then clang, then infer. This way if any step
 # fails we don't lose the significant amount of work done in the
 # previous steps.
-RUN cd /infer && ./build-infer.sh --only-setup-opam
-RUN cd /infer && \
-    eval $(opam env) && \
-    ./autogen.sh && \
-    ./configure && \
-    ./facebook-clang-plugins/clang/setup.sh
+RUN \
+    ls -sf /usr/bin/aarch64-linux-gnu-ld.gold /usr/bin/aarch64-linux-gnu-ld && \
+    ld --version && \
+    cd /infer && \
+    ./build-infer.sh -y clang

 # Generate a release
 RUN cd /infer && \
$ docker run -it --rm infer:latest infer --version
Infer version v1.1.0-aa58dd18
Copyright 2009 - present Facebook. All Rights Reserved.
NathanDotTo commented 8 months ago

I have just built Infer on an M1 MBP from a clone of the repo:

Darwin XXX 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

infer --version Infer version v1.1.0-f168e40ef Copyright 2009 - present Facebook. All Rights Reserved.