Skip to content

Running the linter for OpenJ9

Nazim Bhuiyan edited this page Dec 7, 2017 · 7 revisions
  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/test.py 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
Clone this wiki locally