Openj9: Add OMRChecker linter in the continuous integration build process

Created on 1 Dec 2017  路  6Comments  路  Source: eclipse/openj9

OMRChecker is a clang-based linter tool. Its pupose is to catch any extensible class hierarchy implementation/usage errors. It is currently enabled and run for any PR created in the eclipse/omr project, such as this one:
https://travis-ci.org/eclipse/omr/jobs/308654788

Since eclipse/openj9 also uses extensible class hierarchy and derives a number of classes from eclipse/omr, OMRChecker should be enabled and run for eclipse/openj9 PRs as well.

build jit

Most helpful comment

@DanHeidinga I will work with @nbhuiyan. We need to first run the checker on current openj9 source code and fix any errors the tool finds before we enable it as a part of the travis ci build process.

All 6 comments

@xliang6 How long does the checker take to run on the OpenJ9 code base? Which platforms can the checker run on?

FYI @AdamBrousseau This may need your help to enable on Jenkins.

I was able to run the linter for OpenJ9 for Linux on x86_64 manually using the steps below, thanks to the help I received from @mgaudet and the build instructions here.

Not sure how long it would take on Jenkins or Travis CI, but the checker took ~5 minutes to run on the OpenJ9 code base on the linux machine I used.

Here are the steps to run the linter manually:

  1. git clone https://github.com/ibmruntimes/openj9-openjdk-jdk9.git
  2. Copy/download this Dockerfile
  3. Build the Docker image: docker build -t openj9build -f Dockerfile .
  4. Run the docker image with the cloned repo in step 1 mounted: docker run --rm -it -v$PWD:/sandbox -v$HOME/open/jdk-9+181.openj9:/sdk openj9build /bin/bash
  5. The Dockerfile is not set up to install llvm and clang packages that are required for OMRChecker. Therefore, run the following command to get what is required: apt-get update && apt-get install clang-3.8 llvm-3.8 libclang-3.8-dev llvm-3.8-dev
  6. root@9280bacfa0b7:~# cd /sandbox/openj9-openjdk-jdk9/
  7. root@9280bacfa0b7:/sandbox/openj9-openjdk-jdk9/# bash ./get_source.sh
  8. root@9280bacfa0b7:/sandbox/openj9-openjdk-jdk9/# bash ./configure --with-freemarker-jar=/root/freemarker.jar
  9. root@9280bacfa0b7:/sandbox/openj9-openjdk-jdk9/# make images
  10. The next step is to find where the linter.mk file is located under build/. It should be in build/linux-x86_64-normal-server-release/vm/compiler/trj9
  11. In openj9-openjdk-jdk9/omr/tools/compiler/OMRChecker/ modify the variable base in the constructor for class OMRChecker such that it looks like this:
class OMRChecker(tool.Tool):
   '''A wrapper providing an interface for interacting with OMRChecker.'''

   def __init__(self, checker):
      base = [os.environ['CLANG'], '-fsyntax-only', '-Xclang', '-load', '-Xclang', checker, '-Xclang', '-add-plugin', '-Xclang', 'omr-checker']
      super(OMRChecker, self).__init__(lambda args: base + args)
  1. In the same directory, you will need to modify the Makefile to build the plugin shared library object using clang-3.8. For that, you would have to replace CXX under # Build rules with CLANG. It should look like this:
#
# Build rules
#
$(OMRCHECKER_OBJECT): $(CHECKER_O)
    $(CLANG) $(LDFLAGS) -o $@ $^

$(CHECKER_O): $(CHECKER_CPP) $(CHECKER_HPP) 
    $(CLANG) $(CXXFLAGS) -c -o $@ $<
  1. cd to /build/linux-x86_64-normal-server-release/vm/compiler/trj9
  2. Set environment variables: export J9SRC=/sandbox/openj9-openjdk-jdk9/build/linux-x86_64-normal-server-release/vm/ OMRCHECKER_DIR=/sandbox/openj9-openjdk-jdk9/omr/tools/compiler/OMRChecker/ LLVM_CONFIG=llvm-config-3.8 CLANG=clang++-3.8 CXX_PATH=clang++-3.8
  3. Now, run the linter: root@9280bacfa0b7:/sandbox/openj9-openjdk-jdk9/build/linux-x86_64-normal-server-release/vm/compiler/trj9# make -f linter.mk

@DanHeidinga AFAIK the checker was only run on x86-64 Linux platform.

@xliang6 Can you propose the required changes to travis.yaml file to get this enabled?

@DanHeidinga I will work with @nbhuiyan. We need to first run the checker on current openj9 source code and fix any errors the tool finds before we enable it as a part of the travis ci build process.

Closing as complete.

Was this page helpful?
0 / 5 - 0 ratings