facebook / infer

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

ocamlopt crashed when building native(opt) Infer #1272

Open zyh1121 opened 4 years ago

zyh1121 commented 4 years ago

Please make sure your issue is not addressed in the FAQ.

Please include the following information:

Could you please let me know what I should check next? Thanks.

jvillard commented 4 years ago

Thanks for the report. Looks like you may have found a bug in OCaml's PowerPC backend, I'm not sure there's much we can do about it. You can try building infer without flambda in case it's a problem in the flambda optimisation pass in the OCaml compiler:

$ opam switch create ocaml-base-compiler.4.09.1
$ ./build-infer.sh --user-opam-switch

Can you paste the contents of clang_ast_j.pp.ml somewhere? It would be useful to post an issue about this in OCaml's repo together with a simple way to reproduce the issue: https://github.com/ocaml/ocaml/

zyh1121 commented 4 years ago

Thanks! I did a fresh build (deleted and re-inited the opam dependencies) using the ocaml without flambda. The build crashed before reaching Building native(opt) Infer....

I also uploaded clang_ast_j.pp.ml.gz to google drive https://drive.google.com/file/d/1KJDrZcO0CPipuTdewtivCfNqgJuAgDvA/view?usp=sharing. Hopefully, the link works for you.

$git diff opam.locked 
diff --git a/opam.locked b/opam.locked
index 219052c..3431b89 100644
--- a/opam.locked
+++ b/opam.locked
@@ -74,7 +74,7 @@ depends: [
   "ocaml-compiler-libs" {= "v0.12.1"}
   "ocaml-config" {= "1"}
   "ocaml-migrate-parsetree" {= "1.7.3"}
-  "ocaml-variants" {= "4.09.1+flambda"}
+  "ocaml-base-compiler" {= "4.09.1"}
   "ocamlbuild" {= "0.14.0"}
   "ocamlfind" {= "1.8.1"}
   "ocamlgraph" {= "1.8.8"}

$git diff build-infer.sh 
diff --git a/build-infer.sh b/build-infer.sh
index 8250a4d..95d160b 100755
--- a/build-infer.sh
+++ b/build-infer.sh
@@ -17,7 +17,7 @@ DEPENDENCIES_DIR="$INFER_ROOT/facebook/dependencies"
 PLATFORM="$(uname)"
 SANDCASTLE=${SANDCASTLE:-}
 NCPU="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)"
-INFER_OPAM_DEFAULT_SWITCH="ocaml-variants.4.09.1+flambda"
+INFER_OPAM_DEFAULT_SWITCH="ocaml-base-compiler.4.09.1"
 INFER_OPAM_DEFAULT_COMPILER="$INFER_OPAM_DEFAULT_SWITCH"
 INFER_OPAM_SWITCH=${INFER_OPAM_SWITCH:-$INFER_OPAM_DEFAULT_SWITCH}
 INFER_OPAM_COMPILER=${INFER_OPAM_COMPILER:-$INFER_OPAM_DEFAULT_COMPILER}
+ echo 'testing installed clang'
testing installed clang
+ /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin
+ echo 'deleting temp dir '\'''\''...'
deleting temp dir ''...
+ '[' -n '' ']'
+ rm -rf /tmp/clang-setup.AxXb91
+ record_installed
+ pushd /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang
+ sha256sum src/llvm_clang_compiler-rt_libcxx_libcxxabi_openmp-9.0.0.tar.xz setup.sh
+ popd
[05:31:24][105401] Building clang plugin...
[     47s][105401] SUCCESS Building clang plugin
[05:32:11][105562] Building clang plugin OCaml interface...
[*ERROR**][105562] *** ERROR 'Building clang plugin OCaml interface'
[*ERROR**][105562] *** command: ' make INTERACTIVE=1 -C /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang-ocaml all build/clang_ast_proj.ml build/clang_ast_proj.mli CC=clang CXX=clang++ CFLAGS=-g -O2 CXXFLAGS=-g -O2 CPP=clang -E LDFLAGS= LIBS= LOCAL_CLANG=/gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang CLANG_PREFIX=/gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install CLANG_INCLUDES=/gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/include SDKPATH= '
[*ERROR**][105562] *** CWD: '/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer'
[*ERROR**][105562] *** stdout:
[*ERROR**][105562] make[1]: Entering directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang-ocaml'
[*ERROR**][105562] make[2]: Entering directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/libtooling'
[*ERROR**][105562] make[2]: Leaving directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/libtooling'
[*ERROR**][105562] ../libtooling/atdlib/extract_atd_from_cpp.py ../libtooling/build/ASTExporter.h.p | ../libtooling/atdlib/normalize_names_in_atd.py > build/ast_inline.atd.p
[*ERROR**][105562] /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang -cc1 -E -traditional-cpp -w -P -main-file-name - -o - build/ast_inline.atd.p > build/ast_inline.atd
[*ERROR**][105562] cat build/ast_inline.atd.p | grep '^#' > build/ast_inline.atd.inc
[*ERROR**][105562] cat clang_ast_proj.mli.p | /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang -cc1 -E -traditional-cpp -w -P -main-file-name - -o - -include build/ast_inline.atd.inc > build/clang_ast_proj.mli
[*ERROR**][105562] cat build/ast_inline.atd.inc | sed 's/*/,/g; s/ list/_list/g' > build/ast_inline.pat.inc
[*ERROR**][105562] atdcat -i build/ast_inline.atd > build/clang_ast.atd && { [ -s build/clang_ast.atd ] || { rm build/clang_ast.atd; exit 1; }; }
[*ERROR**][105562] /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang -cc1 -E -P -x c -main-file-name - -o - -I/gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/include clang_ast_proj.ml.p -o - | ../libtooling/atdlib/normalize_names_in_atd.py | /gpfs/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang/install/bin/clang -cc1 -E -traditional-cpp -w -P -main-file-name - -o - -include build/ast_inline.pat.inc > build/clang_ast_proj.ml
[*ERROR**][105562] atdgen -t -o build/clang_ast build/clang_ast.atd
[*ERROR**][105562] atdgen -j -o build/clang_ast build/clang_ast.atd
[*ERROR**][105562] atdgen -v -o build/clang_ast build/clang_ast.atd
[*ERROR**][105562] ocamldep -native -I build utils_test.ml clang_ast_main_test.ml clang_ast_yojson_validator.ml clang_ast_visit.ml yojson_utils.ml clang_ast_types.ml process.ml clang_ast_converter.ml clang_ast_named_decl_printer.ml yojson_utils_test.ml clang_ast_proj_test.ml utils.ml clang_ast_main.ml process_test.ml yojson_utils.mli process.mli utils.mli build/clang_ast_t.mli build/clang_ast_t.ml build/clang_ast_j.mli build/clang_ast_j.ml build/clang_ast_v.mli build/clang_ast_v.ml build/clang_ast_proj.mli build/clang_ast_proj.ml | sed -e 's/\([a-zA-Z0-9_]*\.cm.\)/build\/\1/g' | sed -e 's/build\/build\//build\//g' > .depend
[*ERROR**][105562] make[1]: Leaving directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang-ocaml'
[*ERROR**][105562] make[1]: Entering directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang-ocaml'
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_types.cmx -c clang_ast_types.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/process.cmi -c process.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/utils.cmi -c utils.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/yojson_utils.cmi -c yojson_utils.mli
[*ERROR**][105562] make[1]: `build/clang_ast_proj.ml' is up to date.
[*ERROR**][105562] make[1]: `build/clang_ast_proj.mli' is up to date.
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/process.cmx -c process.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/utils.cmx -c utils.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_t.cmi -c build/clang_ast_t.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/yojson_utils.cmx -c yojson_utils.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_t.cmx -c build/clang_ast_t.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_j.cmi -c build/clang_ast_j.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_proj.cmi -c build/clang_ast_proj.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_v.cmi -c build/clang_ast_v.mli
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_proj.cmx -c build/clang_ast_proj.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_visit.cmx -c clang_ast_visit.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_v.cmx -c build/clang_ast_v.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_j.cmx -c build/clang_ast_j.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_main.cmx -c clang_ast_main.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_converter.cmx -c clang_ast_converter.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -o build/clang_ast_named_decl_printer.cmx -c clang_ast_named_decl_printer.ml
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -linkpkg -o build/clang_ast_converter build/clang_ast_types.cmx build/clang_ast_t.cmx build/clang_ast_j.cmx build/process.cmx build/utils.cmx build/yojson_utils.cmx build/clang_ast_converter.cmx
[*ERROR**][105562] ocamlfind ocamlopt -package unix,atdgen,atdgen-runtime,camlzip -I build -safe-string -linkpkg -o build/clang_ast_named_decl_printer build/clang_ast_types.cmx build/clang_ast_t.cmx build/clang_ast_j.cmx build/clang_ast_proj.cmx build/clang_ast_visit.cmx build/clang_ast_v.cmx build/clang_ast_main.cmx build/clang_ast_named_decl_printer.cmx
[*ERROR**][105562] make[1]: Leaving directory `/gpfs/automountdir/r92gpfs02/zhengyu/local_setup/infer/facebook-clang-plugins/clang-ocaml'
[*ERROR**][105562] *** stderr:
[*ERROR**][105562] File "utils.ml", line 12, characters 49-67:
[*ERROR**][105562] 12 | let open_in name = if name = "-" then stdin else Pervasives.open_in name
[*ERROR**][105562]                                                       ^^^^^^^^^^^^^^^^^^
[*ERROR**][105562] Alert deprecated: module Stdlib.Pervasives
[*ERROR**][105562] Use Stdlib instead.
[*ERROR**][105562] 
[*ERROR**][105562] If you need to stay compatible with OCaml < 4.07, you can use the 
[*ERROR**][105562] stdlib-shims library: https://github.com/ocaml/stdlib-shims
[*ERROR**][105562] File "utils.ml", line 15, characters 51-70:
[*ERROR**][105562] 15 | let open_out name = if name = "-" then stdout else Pervasives.open_out name
[*ERROR**][105562]                                                         ^^^^^^^^^^^^^^^^^^^
[*ERROR**][105562] Alert deprecated: module Stdlib.Pervasives
[*ERROR**][105562] Use Stdlib instead.
[*ERROR**][105562] 
[*ERROR**][105562] If you need to stay compatible with OCaml < 4.07, you can use the 
[*ERROR**][105562] stdlib-shims library: https://github.com/ocaml/stdlib-shims
[*ERROR**][105562] /tmp/camlasm501034.s: Assembler messages:
[*ERROR**][105562] /tmp/camlasm501034.s: Warning: TOC section size exceeds 64k
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__string_of__2_1369':
[*ERROR**][105562] :(.text+0x618): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+103f8
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__read_access_specifier_1420':
[*ERROR**][105562] :(.text+0x1060): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+105e0
[*ERROR**][105562] :(.text+0x11b0): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+105e0
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__write_attribute_kind_1428':
[*ERROR**][105562] :(.text+0x1684): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10588
[*ERROR**][105562] :(.text+0x1e18): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10250
[*ERROR**][105562] :(.text+0x1ee0): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10000
[*ERROR**][105562] :(.text+0x2034): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+107b8
[*ERROR**][105562] :(.text+0x20fc): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+107c0
[*ERROR**][105562] :(.text+0x21ec): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+102f0
[*ERROR**][105562] :(.text+0x2228): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10368
[*ERROR**][105562] :(.text+0x250c): additional relocation overflows omitted from the output
[*ERROR**][105562] collect2: error: ld returned 1 exit status
[*ERROR**][105562] File "caml_startup", line 1:
[*ERROR**][105562] Error: Error during linking
[*ERROR**][105562] make[1]: *** [build/clang_ast_converter] Error 2
[*ERROR**][105562] make[1]: *** Waiting for unfinished jobs....
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__string_of__2_1369':
[*ERROR**][105562] :(.text+0x618): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+103f8
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__read_access_specifier_1420':
[*ERROR**][105562] :(.text+0x1060): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+105e0
[*ERROR**][105562] :(.text+0x11b0): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+105e0
[*ERROR**][105562] build/clang_ast_j.o: In function `camlClang_ast_j__write_attribute_kind_1428':
[*ERROR**][105562] :(.text+0x1684): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10588
[*ERROR**][105562] :(.text+0x1d64): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+ff78
[*ERROR**][105562] :(.text+0x1e18): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10250
[*ERROR**][105562] :(.text+0x1ee0): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+10000
[*ERROR**][105562] :(.text+0x2034): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+107b8
[*ERROR**][105562] :(.text+0x20fc): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+107c0
[*ERROR**][105562] :(.text+0x21ec): relocation truncated to fit: R_PPC64_TOC16_DS against `.toc'+102f0
[*ERROR**][105562] :(.text+0x2228): additional relocation overflows omitted from the output
[*ERROR**][105562] collect2: error: ld returned 1 exit status
[*ERROR**][105562] File "caml_startup", line 1:
[*ERROR**][105562] Error: Error during linking
[*ERROR**][105562] make[1]: *** [build/clang_ast_named_decl_printer] Error 2
make: *** [clang_plugin] Error 2

 $which ocamlopt
/gpfs/automountdir/r92gpfs02/zhengyu/opam_repo/ocaml-base-compiler.4.09.1/bin/ocamlopt

$which ocaml
/gpfs/automountdir/r92gpfs02/zhengyu/opam_repo/ocaml-base-compiler.4.09.1/bin/ocaml