Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX migration #315

Merged
merged 11 commits into from
Aug 30, 2016
Merged

OSX migration #315

merged 11 commits into from
Aug 30, 2016

Conversation

tmsblgh
Copy link
Contributor

@tmsblgh tmsblgh commented May 31, 2016

@@ -2,17 +2,27 @@

if [[ "$OSTYPE" == "linux-gnu" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we merge these two if statements for setting TEST_TESTS_DIR and TEST_CODECHECKER_PACKAGE_DIR environment variables?
If OSTYPE is not set the default value should be linux-gnu.

@gyorb
Copy link
Contributor

gyorb commented Jun 8, 2016

More descriptive comment messages would be better instead of "Small changes..." 😉

@gyorb gyorb modified the milestone: release 5.5 Aug 5, 2016
@r0mai
Copy link

r0mai commented Aug 15, 2016

Official OS X support would be very welcome. I'm in the process of trying to make this branch work on my machine. I'll report the issues I encounter.

LOG.debug_analyzer("with ld logger ...")
log_env = analyzer_env.get_log_env(logfile, context, original_env)
if 'CC_LOGGER_GCC_LIKE' not in log_env:
log_env['CC_LOGGER_GCC_LIKE'] = 'gcc:g++:clang:clang++:cc:c++'

LOG.debug_analyzer(log_env)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an ugly python error if we get here and check_intercept returned false and we're not on Linux.

[ERROR] - Failed to run: intercept-build"
[ERROR] - local variable 'log_env' referenced before assignment
Traceback (most recent call last):
  File "/Users/r0mai/codechecker_package/CodeChecker/cc_lib/python2.7/codechecker_lib/arg_handler.py", line 226, in handle_check
    context)
  File "/Users/r0mai/codechecker_package/CodeChecker/cc_lib/python2.7/codechecker_lib/build_manager.py", line 167, in generate_log_file
    silent=silent)
  File "/Users/r0mai/codechecker_package/CodeChecker/cc_lib/python2.7/codechecker_lib/build_manager.py", line 65, in perform_build_command
    LOG.debug_analyzer(log_env)
UnboundLocalError: local variable 'log_env' referenced before assignment

A more user friendly error message would be nice :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I forgot about this option. I've made some changes, you can check it. Thanks for your help :) @r0mai

@gyorb
Copy link
Contributor

gyorb commented Aug 28, 2016

Do you still experience some issues @r0mai ?

@r0mai
Copy link

r0mai commented Aug 28, 2016

I didn't have much time as I expected, but here where I'm now:

I followed the documentation more or less blindly https://github.com/tmsblgh/codechecker-osx-migration/blob/7ed507526723fab6bde1b601bf6f6825da416d9f/README.md#os-x

At the ./build_package.py -o ~/codechecker_package line I get the following output:

$ ./build_package.py -o ~/codechecker_package
[INFO] - Checking source: thrift
[INFO] - Done.
[INFO] - Checking source: codemirror
[INFO] - Done.
[INFO] - Checking source: jsplumb
[INFO] - Done.
[INFO] - Checking source: marked
[INFO] - Done.
[INFO] - Checking source: dojotoolkit
[INFO] - Done.
[INFO] - Checking source: highlightjs
[INFO] - Done.
[INFO] - Checking source: highlightjs_css
[INFO] - Done.
[INFO] - Getting external dependecies done.
[INFO] - Removing previous package
[INFO] - Creating package layout
[INFO] - Checking source: llvm scan-build-py (intercept)
[ERROR] - Not exists, build ld logger in Linux only
[INFO] - Generating thrift files ...
[INFO] - Generating documentation ...
[INFO] - Creating package finished successfully.

Later in the documentation it is mentioned, that codecheker has to be able to find intercept-build or scan-build, so I tried adding it to the path:

$ PATH="$PATH:$HOME/build/clang-for-codechecker/llvm/tools/clang/tools/scan-build-py/bin" ./build_package.py -o ~/codechecker_package
[INFO] - Checking source: thrift
[INFO] - Done.
[INFO] - Checking source: codemirror
[INFO] - Done.
[INFO] - Checking source: jsplumb
[INFO] - Done.
[INFO] - Checking source: marked
[INFO] - Done.
[INFO] - Checking source: dojotoolkit
[INFO] - Done.
[INFO] - Checking source: highlightjs
[INFO] - Done.
[INFO] - Checking source: highlightjs_css
[INFO] - Done.
[INFO] - Getting external dependecies done.
[INFO] - Removing previous package
[INFO] - Creating package layout
[INFO] - Checking source: llvm scan-build-py (intercept)
[INFO] - Available
[INFO] - Generating thrift files ...
[INFO] - Generating documentation ...
[INFO] - Creating package finished successfully.

So first thing to note, that the documentation here could be improved by adding this PATH requirement to the install & setup section.

After that I tried it on a test project with a pretty obvious bug: (full gist)

int main() {
    int a[11];
    a[123] = 15;
}
$ mkdir build && cmake ..
[...]
$ CodeChecker check -n test_project -b "make"
[INFO] - Starting build ...
Scanning dependencies of target cc-test
[ 50%] Building CXX object CMakeFiles/cc-test.dir/main.cpp.o
/Users/r0mai/prezi/codechecker-test/main.cpp:3:2: warning: array index 123 is past the end of the array (which contains 11 elements) [-Warray-bounds]
        a[123] = 15;
        ^ ~~~
/Users/r0mai/prezi/codechecker-test/main.cpp:2:2: note: array 'a' declared here
        int a[11];
        ^
1 warning generated.
[100%] Linking CXX executable cc-test
[100%] Built target cc-test
[INFO] - Build finished successfully.
[INFO] - Waiting for check results on [49733]
[INFO] - Static analysis is starting ...
[INFO] - clangsa analyzed main.cpp successfully.
[INFO] - clang-tidy analyzed main.cpp successfully.
[INFO] - ----==== Summary ====----
[INFO] - Total compilation commands: 2
[INFO] - Successfully analyzed
[INFO] -   clangsa: 1
[INFO] -   clang-tidy: 1
[INFO] - ----=================----
[INFO] - Analysis length: 0.315434932709 sec.
[INFO] - Analysis has finished.
[INFO] - To view results run:
CodeChecker server -w /Users/r0mai/.codechecker

Starting the server and opening the localhost address opens a website with a single run. But clicking on that run shows no results, nothing:

screen shot 2016-08-28 at 22 49 26

Maybe this simple program doesn't trigger any checker and that's why there are no issues? Here I'd suggest adding to the repo a simple example cpp file, build scripts and some instructions to the readme on how to check it right after the installation instructions, so the user can easily make sure that the whole infrastructure works before analyzing their big project.

I'm here now. I'll report back if I find out other stuff.

Also, I talked with @tmsblgh in private about having installer scripts which can take care of the whole installation process easily without all this manual hassle (like cloning and building a clang locally, setting up environment variables and setting files to point to that private clang build, etc).

@gyorb
Copy link
Contributor

gyorb commented Aug 29, 2016

I checked your example on my linux machine and I got the result in the web viewer.
Which clang/clang-tidy version do you use?
Can you view the results in the command line? CodeChecker cmd results -p 8001 -n test_project

I'd like to close and merge this pull request, because we are starting the integrating the codechecker source to the clang source tree.
If you find any problems or have any suggestions please create new issues/pull requests for them, thanks!

@r0mai
Copy link

r0mai commented Aug 29, 2016

No:

$ CodeChecker cmd results -p 8001 -n test_project
-------------------------------
File | Checker | Severity | Msg
-------------------------------
-------------------------------

I'll try to run it on something bigger project tonight. Can you give me some example cpp which should surely produce some report?

@gyorb gyorb mentioned this pull request Aug 29, 2016
@gyorb
Copy link
Contributor

gyorb commented Aug 29, 2016

We run codechecker multiple times on bzip2, xerces, vim.
Please try to use the newer version #363 it is updated for the latest codechecker.

You could try to enable debug mode for the analysis and for the server viewing the results by setting the environment variable export CODECHECKER_VERBOSE=debug in the shell.
Let me know if there are any error/warning messages.

@gyorb gyorb merged commit 7ed5075 into Ericsson:master Aug 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants