facebook / infer

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

Building Infer models error when executing build-infer.sh clang #1002

Closed harmim closed 4 years ago

harmim commented 6 years ago

Command: ./build-infer.sh clang OS: macOS 10.13.6

$ ./build-infer.sh clang
...
[19:41:07][97874] Building Infer models...
[*ERROR**][97874] *** ERROR 'Building Infer models'
[*ERROR**][97874] *** command: ' /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 infer_models'
[*ERROR**][97874] *** CWD: '/Users/harmim/Programs/infer'
[*ERROR**][97874] *** stdout:
[*ERROR**][97874] *** inner Building clang plugin
[*ERROR**][97874] *** inner command:  /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C /Users/harmim/Programs/infer/facebook-clang-plugins/libtooling all CC="clang" CXX="clang++" CFLAGS="-g -O2" CXXFLAGS="-g -O2" CPP="clang -E" LDFLAGS="" LIBS="" LOCAL_CLANG=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/bin/clang CLANG_PREFIX=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install CLANG_INCLUDES=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/include
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer
[*ERROR**][97874] make[2]: Nothing to be done for `all'.
[*ERROR**][97874] *** inner Building clang plugin OCaml interface
[*ERROR**][97874] *** inner command:  /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C /Users/harmim/Programs/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=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/bin/clang CLANG_PREFIX=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install CLANG_INCLUDES=/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/include
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer
[*ERROR**][97874] make[2]: Nothing to be done for `all'.
[*ERROR**][97874] make[2]: `build/clang_ast_proj.ml' is up to date.
[*ERROR**][97874] make[2]: `build/clang_ast_proj.mli' is up to date.
[*ERROR**][97874] *** inner Generating source dependencies
[*ERROR**][97874] *** inner command:  /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C /Users/harmim/Programs/infer/infer/src INFER_BUILD_DIR=_build/opt src_build_common
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer
[*ERROR**][97874] make[2]: Nothing to be done for `src_build_common'.
[*ERROR**][97874] *** inner Building native(opt) Infer
[*ERROR**][97874] *** inner command:  /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C /Users/harmim/Programs/infer/infer/src INFER_BUILD_DIR=_build/opt infer
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer
[*ERROR**][97874] make[2]: Nothing to be done for `infer'.
[*ERROR**][97874] /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C /Users/harmim/Programs/infer/infer/models all
[*ERROR**][97874] rm -f /Users/harmim/Programs/infer/infer/lib/specs/*.specs /Users/harmim/Programs/infer/infer/lib/specs/clang_models
[*ERROR**][97874] rm -rf glib.o infer_builtins.o libc_basic.o math.o wchar.o wctype.o xlib.o 
[*ERROR**][97874] rm -rf c_src/glib_cxx.o c_src/infer_builtins_cxx.o c_src/libc_basic_cxx.o c_src/math_cxx.o c_src/wchar_cxx.o c_src/wctype_cxx.o c_src/xlib_cxx.o shared_ptr.o throw_wrappers.o type_info.o
[*ERROR**][97874] *** inner Capturing C models
[*ERROR**][97874] *** inner command:  /Users/harmim/Programs/infer/infer/bin/infer capture --jobs 1 --biabduction-only --results-dir infer-out --models-mode --continue -- /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C c/src all
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer/infer/models
[*ERROR**][97874] clang -c -w glib.c -o glib.o
[*ERROR**][97874] clang -c -w infer_builtins.c -o infer_builtins.o
[*ERROR**][97874] clang -c -w libc_basic.c -o libc_basic.o
[*ERROR**][97874] clang -c -w math.c -o math.o
[*ERROR**][97874] clang -c -w wchar.c -o wchar.o
[*ERROR**][97874] clang -c -w wctype.c -o wctype.o
[*ERROR**][97874] clang -c -w xlib.c -o xlib.o
[*ERROR**][97874] *** inner Capturing C++ models
[*ERROR**][97874] *** inner command:  /Users/harmim/Programs/infer/infer/bin/infer capture --jobs 1 --biabduction-only --results-dir infer-out --models-mode --continue -- /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C cpp/src all
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer/infer/models
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/glib.c -o c_src/glib_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/infer_builtins.c -o c_src/infer_builtins_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/libc_basic.c -o c_src/libc_basic_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/math.c -o c_src/math_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/wchar.c -o c_src/wchar_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/wctype.c -o c_src/wctype_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include c_src/xlib.c -o c_src/xlib_cxx.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include shared_ptr.cpp -o shared_ptr.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include throw_wrappers.cpp -o throw_wrappers.o
[*ERROR**][97874] clang++ -c -w -std=c++11 -isystem../include type_info.cpp -o type_info.o
[*ERROR**][97874] *** inner Capturing ObjCPP models
[*ERROR**][97874] *** inner command:  /Users/harmim/Programs/infer/infer/bin/infer capture --jobs 1 --biabduction-only --results-dir infer-out --models-mode --continue -- /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C objcpp/src all
[*ERROR**][97874] *** inner CWD: /Users/harmim/Programs/infer/infer/models
[*ERROR**][97874] clang++ -g -O2 -Wno-deprecated-objc-isa-usage --target=x86_64-apple-darwin14 -x objective-c++ -c -mios-simulator-version-min=8.2 -isysroot /Library/Developer/CommandLineTools/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk objc_src/NSNotificationCenter.m -o objc_src/NSNotificationCenter_cxx.o
[*ERROR**][97874] *** stderr:
[*ERROR**][97874] Capturing in make/cc mode...
[*ERROR**][97874] Capturing in make/cc mode...
[*ERROR**][97874] Capturing in make/cc mode...
[*ERROR**][97874] objc_src/NSNotificationCenter.m:8:9: fatal error: 'Foundation/NSObject.h' file not found
[*ERROR**][97874] #import <Foundation/NSObject.h>
[*ERROR**][97874]         ^~~~~~~~~~~~~~~~~~~~~~~
[*ERROR**][97874] 1 error generated.
[*ERROR**][97874] Error: the following clang command did not run successfully:
[*ERROR**][97874]     /Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/bin/clang-7.0
[*ERROR**][97874]     @/var/folders/1d/4rv4wh9j6csdpm_6yqw6fwc80000gn/T/clang_command_.tmp.39a37a.txt
[*ERROR**][97874]   ++Contents of '/var/folders/1d/4rv4wh9j6csdpm_6yqw6fwc80000gn/T/clang_command_.tmp.39a37a.txt':
[*ERROR**][97874]     "-cc1" "-load"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
[*ERROR**][97874]     "-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
[*ERROR**][97874]     "-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
[*ERROR**][97874]     "-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
[*ERROR**][97874]     "x86_64-apple-ios8.2.0-simulator" "-Wdeprecated-objc-isa-usage"
[*ERROR**][97874]     "-Werror=deprecated-objc-isa-usage"
[*ERROR**][97874]     "-Werror=implicit-function-declaration" "-emit-obj" "-disable-free"
[*ERROR**][97874]     "-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
[*ERROR**][97874]     "NSNotificationCenter.m" "-mrelocation-model" "pic" "-pic-level" "2"
[*ERROR**][97874]     "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose"
[*ERROR**][97874]     "-munwind-tables" "-faligned-alloc-unavailable" "-target-cpu" "core2"
[*ERROR**][97874]     "-dwarf-column-info" "-debug-info-kind=standalone" "-dwarf-version=2"
[*ERROR**][97874]     "-debugger-tuning=lldb" "-target-linker-version" "351.8"
[*ERROR**][97874]     "-coverage-notes-file"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/infer/models/objcpp/src/objc_src/NSNotificationCenter_cxx.gcno"
[*ERROR**][97874]     "-resource-dir"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/facebook-clang-plugins/clang/install/lib/clang/7.0.0"
[*ERROR**][97874]     "-isysroot"
[*ERROR**][97874]     "/Library/Developer/CommandLineTools/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
[*ERROR**][97874]     "-include"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
[*ERROR**][97874]     "-stdlib=libc++" "-O2" "-Wno-deprecated-objc-isa-usage"
[*ERROR**][97874]     "-Wno-ignored-optimization-argument" "-Wno-everything"
[*ERROR**][97874]     "-fdeprecated-macro" "-fdebug-compilation-dir"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/infer/models/objcpp/src" "-ferror-limit"
[*ERROR**][97874]     "19" "-fmessage-length" "0" "-stack-protector" "1" "-fblocks"
[*ERROR**][97874]     "-fencode-extended-block-signature" "-fobjc-runtime=ios-8.2.0"
[*ERROR**][97874]     "-fobjc-exceptions" "-fcxx-exceptions" "-fexceptions"
[*ERROR**][97874]     "-fmax-type-align=16" "-fdiagnostics-show-option" "-vectorize-loops"
[*ERROR**][97874]     "-vectorize-slp" "-o" "objc_src/NSNotificationCenter_cxx.o" "-x"
[*ERROR**][97874]     "objective-c++" "objc_src/NSNotificationCenter.m" "-O0" "-include"
[*ERROR**][97874]     "/Users/harmim/Programs/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
[*ERROR**][97874]     "-Wno-everything"
[*ERROR**][97874]   
[*ERROR**][97874] 
[*ERROR**][97874] 
[*ERROR**][97874] make[3]: *** [objc_src/NSNotificationCenter_cxx.o] Error 1
[*ERROR**][97874] External Error: *** capture command failed:
[*ERROR**][97874] *** /Library/Developer/CommandLineTools/usr/bin/make INTERACTIVE=1 -C objcpp/src all
[*ERROR**][97874] *** exited with code 2
[*ERROR**][97874] 
[*ERROR**][97874] Error backtrace:
[*ERROR**][97874] Raised at file "format.ml" (inlined), line 242, characters 35-52
[*ERROR**][97874] Called from file "format.ml", line 469, characters 8-33
[*ERROR**][97874] Called from file "format.ml", line 484, characters 6-24
[*ERROR**][97874] Re-raised at file "base/Die.ml" (inlined), line 26, characters 8-56
[*ERROR**][97874] Called from file "base/Die.ml", line 30, characters 6-39
[*ERROR**][97874] Called from file "integration/Driver.ml", line 305, characters 2-29
[*ERROR**][97874] Called from file "infer.ml", line 20, characters 2-36
[*ERROR**][97874] Called from file "infer.ml", line 128, characters 8-54
[*ERROR**][97874] 
[*ERROR**][97874] Run the command again with `--keep-going` to try and ignore this error.
[*ERROR**][97874] make[2]: *** [/Users/harmim/Programs/infer/infer/lib/specs/clang_models] Error 3
[*ERROR**][97874] make[1]: *** [infer_models] Error 2
make: *** [infer] Error 2
jvillard commented 6 years ago

You may need to install the Xcode command line tools with xcode-select --install. Does that help?

harmim commented 6 years ago

Well, I'm aware of it and it should be installed.

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
vojnar commented 5 years ago

I have just hit the very same problem. I can see the file NSObject.h in the directory /usr/include/objc on my machine, but, apparently, that does not help.

vojnar commented 5 years ago

Btw., I got the same result using ./autogen.sh and ./configure.

Z-hui commented 5 years ago

same error

vojnar commented 5 years ago

In between, we resolved the problem with Dominik by commenting out all references to ObjectiveC in the infer/models/Makefile file in the distribution of Infer. This is, we commented out all lines containing OBJC or OBJCPP. It is a dirty hack, but it worked perfectly for us (and we are, anyway, currently not interested in ObjectiveC).

WishQi commented 5 years ago

same error. How to resolve it?

vojnar commented 5 years ago

same error. How to resolve it?

Have you tried the way I mentioned in my comment above? I mean this comment https://github.com/facebook/infer/issues/1002#issuecomment-448507844.

WishQi commented 5 years ago

I have tried that, but it did not work in my case. My mac is macOS Mojave Version 10.14.2 (18C54)

vojnar commented 5 years ago

I have the very same version. Hard to say why it fails. For completeness, here is the full contents of my infer/models/Makefile:

# Copyright (c) 2015-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

ROOT_DIR = ../..
include $(ROOT_DIR)/Makefile.config

C_MODELS_DIR = c/src
CPP_MODELS_DIR = cpp/src
JAVA_MODELS_DIR = java
OBJC_MODELS_DIR = objc/src
OBJCPP_MODELS_DIR = objcpp/src

MODELS_INFER_OUT = infer-out
MODELS_INFER_OPTIONS = --jobs 1 --biabduction-only --results-dir $(MODELS_INFER_OUT) --models-mode

all:

.PHONY: clean_specs
clean_specs:
    $(REMOVE) $(SPECS_LIB_DIR)/*.specs $(MODELS_RESULTS_FILE)

# clang models specs only for now
# The clang deps have changed, so the models need to be rebuilt. If infer itself has changed, we
# need to nuke the previous specs files in case the serialization has changed, otherwise we might
# encounter a segfault reading them.
$(MODELS_RESULTS_FILE): $(MAKEFILE_LIST) $(CLANG_DEPS_NO_MODELS)
    $(QUIET)$(MAKE) clean_specs
    $(QUIET)$(REMOVE_DIR) $(MODELS_INFER_OUT)
#   [make clean] each time to recompile all the models
ifeq ($(BUILD_C_ANALYZERS),yes)
    $(QUIET)$(MAKE) -C $(C_MODELS_DIR) clean
    $(QUIET)$(MAKE) -C $(CPP_MODELS_DIR) clean
ifneq (no, $(XCODE_SELECT))
    # $(QUIET)$(MAKE) -C $(OBJC_MODELS_DIR) clean
    # $(QUIET)$(MAKE) -C $(OBJCPP_MODELS_DIR) clean
endif
    $(QUIET)$(call silent_on_success,Capturing C models,\
      $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(C_MODELS_DIR) all)
    $(QUIET)$(call silent_on_success,Capturing C++ models,\
      $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(CPP_MODELS_DIR) all)
ifneq (no, $(XCODE_SELECT))
    # $(QUIET)$(call silent_on_success,Capturing ObjCPP models,\
      $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(OBJCPP_MODELS_DIR) all)
    # $(QUIET)$(call silent_on_success,Capturing ObjC models,\
      $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(OBJC_MODELS_DIR) all)
endif
endif
    $(QUIET)$(call silent_on_success,Analyzing clang models,\
      $(INFER_BIN) analyze $(MODELS_INFER_OPTIONS))
    $(QUIET)$(INSTALL_DATA) $(MODELS_INFER_OUT)/specs/*.specs $(SPECS_LIB_DIR)
    $(QUIET)touch $@

.PHONY: java
java:
    $(QUIET)$(MAKE) -C $@ install

ifeq ($(BUILD_C_ANALYZERS),yes)
all: $(MODELS_RESULTS_FILE)
endif
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
all: java
endif

.PHONY: clean
clean: clean_specs
    $(QUIET)$(MAKE) -C $(JAVA_MODELS_DIR) clean
    $(QUIET)$(MAKE) -C $(C_MODELS_DIR) clean
    $(QUIET)$(MAKE) -C $(CPP_MODELS_DIR) clean
ifneq (no, $(XCODE_SELECT))
    # $(QUIET)$(MAKE) -C $(OBJC_MODELS_DIR) clean
    # $(QUIET)$(MAKE) -C $(OBJCPP_MODELS_DIR) clean
endif
jvillard commented 5 years ago

I cannot reproduce this issue. Has anyone who encountered it managed to solve it? For completeness sake I did the following to get infer to build with Mojave:

export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Amar1729 commented 5 years ago

Tried it out on a clean system. Looks like the full Xcode.app provides that header file (my build failed with same error with only xcode CLT installed, but succeeds with the app).

jvillard commented 4 years ago

I think this issue has been solved, maybe by 346c89c71748281dd38042226ebb97348516bcf7.

harmim commented 3 years ago

Note: resolved by PR https://github.com/facebook/infer/pull/1345.