This article describes how to compile the OpenJDK project code on MacOS and Ubuntu, and run/debug the OpenJDK using the IDE tool JetBrains CLion (hereinafter called CLion). This article only includes methods for two specific versions of the operating system (MacOS 10.15 and Ubuntu 16.04), and there may be some differences between different versions. Hope to have certain reference value to the reader.

Overall, compiling OpenJDK11 is less of a hurdle on either system than OpenJDK8. Compiling OpenJDK8 is easy on Ubuntu, but tedious on MacOS.

Basic steps for compiling and debugging OpenJDK

The process of compiling and debugging OpenJDK can be divided into the following steps:

  1. To obtainOpenJDKProject source code
  2. Download an appropriate versionJDKAs aBootJDK
  3. Download the required tool chain, including compilers, debuggers, build tools, and so on
  4. Download the required dependency libraries
  5. Running Configure(configuration)
  6. Running Make(build)
  7. The importCLionAnd carry onRun/Debugconfiguration

Among them, step 3-6 varies greatly according to different operating systems and OpenJDK versions, while the rest of the steps vary little. Therefore, the order of this article is to first introduce part 1-2, part 7 and some pre-knowledge in detail. In the specific scenarios (different operating systems + different OpenJDK versions), these parts will be specified with special differences.

Prior to the start

How do I get OpenJDK source code?

The first step of compiling and debugging is to obtain the source code of OpenJDK, which can be obtained in the following three ways:

1. ByOpenJDKThe officialMercurialWarehouse to download

The OpenJDK officially uses Mercurial for versioning. Mercurial Repository address: hg.Openjdk.java.net/

project address
jdk hg.openjdk.java.net/jdk/jdk
jdk8u Hg.openjdk.java.net/jdk8u/jdk8u…
jdk11u Hg.openjdk.java.net/jdk-updates…

To download the source code this way, you need to first install the Mercurial tool and use Hg Clone < URL > to download the source code. For example, to download jdk8u, run the following command:

hg clone http://hg.openjdk.java.net/jdk8u/jdk8u/
Copy the code

This method is slow to download and may cause interruption. It is not recommended.

2. Through the mirrorGitWarehouse to download

The OpenJDK repository image is available on GitHub. The home page is github.com/openjdk, and the main project address is:

project address
jdk github.com/openjdk/jdk
jdk11u Github.com/openjdk/jdk…
jdk12u Github.com/openjdk/jdk…

However, there is no version below JDK11 in the official Git repository.

There are also some unofficial Git repositories that mirror Git. For example, AdoptOpenJDK project, the home page: github.com/AdoptOpenJD… , Main project address:

project address
jdk Github.com/AdoptOpenJD…
jdk8u Github.com/AdoptOpenJD…
jdk11u Github.com/AdoptOpenJD…

To do this, you need to install git tools and use Git Clone

to download the source code. For example, to download jdk8u, run the following command:

git clone https://github.com/AdoptOpenJDK/openjdk-jdk8u
Copy the code

The Git tool is easy to use and much faster than downloading from the official Mercurial repository and is recommended.

3. DownloadMercurialWarehouse orGitWarehouse package file

In addition, the official OpenJDK Mercurial repository also provides a direct way to download the packages. The bZ2, ZIP, and gz links are available on the left side of each project page. As shown in the figure below:

Also on GitHub, each project can be downloaded as a ZIP package. As shown in the figure below:

The obvious downside to this approach is the lack of version control, the inability to recover if changes have been made to the project code, and the lack of easy access to the latest code changes, but it is faster to download than the previous two methods and does not require any additional tools.

How do I download the JDK?

Paradoxically, we need an already compiled JDK to act as the Boot JDK before we can compile it. Generally, the required JDK version is the JDK version before the compilation version. For example, to compile JDK8, you need JDK7, and to compile JDK11, you need JDK10. There are several ways to download the JDK:

  1. inOracle’s websitedownloadOracle JDK. Download requires a login account
  2. downloadOpenJDK
    • injdk.java.net/You can find theOracleProvided based onOpenJDKReference implementation of. But most of them areLinuxversion
    • It can also be precompiled by other organizationsOpenJDK. Such asAdoptOpenJDK, but nojdk8The following version
  3. inLinuxSystem, also through the package manager (such asUbuntuUnder theapt.CentosUnder theyum) Download installationJDK

JSON Compilation Database

CLion is friendly to CMake built projects, but OpenJDK projects are built on Make, and for projects built using Make, CLion can still import the project through Compilation Database without changing it to a CMake project. At the same time, code analysis, jump and other functions can be realized through the Compilation Database, which is very helpful for our code debugging.

For the introduction of Compilation Database, please refer to these articles:

  • ClangThe officialCompilation DatabaseIntroduction page:JSON Compilation Database Format Specification — Clang 11 Documentation
  • This article describes generation in different scenariosCompilation databaseA variety of tools:Compilation Database — Sarcasm notebook
  • CLionThe help page is briefly introducedCompilation DatabaseAnd, inCLionThe use of:Compilation Database – Help | CLion

For OpenJDK projects built on Make, there are tools to generate the Compilation Database, such as the following:

  • Github.com/rizsotto/Be…
  • Github.com/rizsotto/sc…
  • Github.com/nickdiego/c…

The Compilation Database is usually generated by default as a compile_commands. Json file.

In addition, in OpenJDK 11U and later versions, OpenJDK officially provides support for IDE. You can use the “make compile-commands” command to generate Compilation Database without using additional tools. The specific command can be viewed in the source code directory \doc\ide.md

How do I import an OpenJDK project into CLion and run/debug it

The reader may choose to skip this section and import debugging from this section after completing the previous steps.

Managing Makefile Projects In CLion is described in detail in CLion’s official help document: Managing Makefile Projects.

Refer to the above documentation for a brief introduction to importing and running/debugging an OpenJDK project in CLion. Please note that the figure shown in the section is based on Ubuntu 16.04 + CLion 2020.1.1 environment, and the steps generally apply to CLion of the same version on MacOS.

  1. Download and install CLion and install the Makefile Support plug-in. The latest version is recommended; older versions do not support make-built projects.

  2. Import the project. Open CLion, select Open Or Import, select compile_commands. Json in the Project directory, select Open as Project, and wait for the file to be indexed.

    The method and location for generating compile_commands. Json vary with OpenJDK versions. For details, see the following scenarios.

  3. Create a custom Build Target. Click on the File menu bar, Settings | Build, Execution, Deployment | Custom Build Targets, click + to create a new Target.

    • Name:TargetAfter the name is createdRun/DebugYou’ll see that name when you configure it
    • Click on theBuildorCleanThree points on the right, click in the popup+Two newExternal ToolThe configuration is as follows:
      # The first configuration is as follows, which specifies the build directive
      # Program and Arguments together form the command to execute "make all"Name: make Program: make Arguments: all Working directory:# The second configuration is as follows to clean up the build output
      # Program and Arguments together form the command to execute "make clean"Name: make clean Program: make Arguments: Clean Working directory: {root directory of project}Copy the code
    • ToolChainchooseDefault;BuildchoosemakeThe first one created aboveExternal Tool);Cleanchoosemake clean(The second created aboveExternal Tool)

    In two of the External Tool configurations, the make parameter can be changed as needed. Generally, the configuration used for Build is the same as the target made at the time of the Build.

  4. Create a custom Run/Debug configuration. Click on the Run menu bar,Edit Configurations, click + and select Custom Build Application. The configuration is as follows:

    Executable and Program Arguments can be selected based on the information needed for debugging
    # NameL: The name of the Configure
    Name: linux-x86_64-normal-server-slowdebug
    # Target: Select the "Custom Build Target" created in the previous step
    Target: linux-x86_64-normal-server-slowdebug
    Executable: Program execution entry, that is, the program that needs debuggingExecutable: Here we debug 'Java' by selecting '{source_root}/build/{build_name}/ JDK /bin/ Java'.# Program arguments: Used with "Executable" to specify its argumentsProgram Arguments: Here we select '-version' and simply print the 'Java' version.Copy the code

    If you don’t want to do the Build operation Before every run/debug (in this case, the Make Build process, which is time-consuming), you can delete the Build entry in the Before Launch box at the bottom of the edit page.

  5. Click Run/Debug to start running/debugging.

    • If the debugger used isgdb(UbuntuYou may find this when debugginggdbError:Signal: SIGSEGV (Segmentation fault). The solution is to create user home directory creation.gdbinit, the contents are as follows:
      handle SIGSEGV pass noprint nostop
      handle SIGBUS pass noprint nostop
      Copy the code
    • If the debugger used islldb(MacOSYou may find this when debugginglldbError:SIGSEGV (signal SIGSEGV). The solution is to create it in the user’s home directory.lldbinit, the contents are as follows:
      break set -n main -C "process handle --pass true --stop false SIGSEGV" -C "process handle --pass true --stop false SIGBUS"
      Copy the code
  6. Automatically update the Compilation Database with File Watchers plugin (optional)

    If the project code is modified, the Compilation Database needs to be generated again. In general, the Compilation Database needs to be rebuilt.

    If you don’t want to have to rebuild manually every time, you can use the Files Watcher plug-in to automatically regenerate listening for changes. See: www.jetbrains.com/help/clion/…

Ubuntu 16.04 environment

OpenJDK 8

1. Download the OpenJDK8 source code

We chose to download the source code from the GitHub repository of AdoptOpenJDK.

# First need to install git tools (if not available)
sudo apt-get install git
# Clone project code, which may take a long time
git clone [email protected]:AdoptOpenJDK/openjdk-jdk8u.git
Copy the code

2. Install the tool chain and its dependencies

# First you need to download and install JDK7 as BootJDKMethods see aboveInstall the compiler and build tools
sudo apt-get install gcc g++ gdb make
Download and install dependency packages
sudo apt-get install libasound2-dev libfreetype6-dev libcups2-dev libfontconfig1-dev libxext-dev libxrender-dev libxtst-dev libxt-dev
Copy the code

3. Configure and build

OpenJDK8 OpenJDK8 OpenJDK8
# configurationsh ./configure --with-debug-level=slowdebug --disable-zip-debug-info --with-target-bits=64 - with - the boot - JDK = / home/jiajiawang/software/JDK/jdk1.7.0 _80 - with - freetype - include = / usr/include/freetype2 --with-freetype-lib=/usr/lib/x86_64-linux-gnu/Copy the code

Configure Parameter description:

parameter meaning
–with-debug-level Debug information level. The available values arerelease.fastdebug.slowdebug
–disable-zip-debug-info Disables compression of debugging information. Set to true for debugging purposes
–with-target-bits The value can be 32-bit or 64-bit, depending on the operating system
–with-boot-jdk BootJDKThe location of the
–with-freetype-include

–with-freetype-lib
The specifiedfreetypeDepending on location, if prompt cannot be foundfreetype, the two parameters need to be configured

See OpenJDK 8 Build Readme-configure for more descriptions of the parameters and more parameters

We can use two tools to generate the Compilation Database

Use the Bear tool

Download the Bear tool
sudo apt-get install bear
# Build the Compilation Database and use bear tool to generate the Compilation Database
bear make all
Copy the code

Use the compiledb tool

You need to ensure that you have a Python environment
# installation PIP
sudo apt-get install python-pip
# PIP install compiledb
pip install compiledb
# Build and generate the Compilation Database using compiledb
compiledb make all
Copy the code

For more information about make target, see OpenJDK 8 Build readme-make

If no errors are reported, you should be able to find the compiled JDK in./build/linux-x86_64-normal-server-slowdebug/ JDK and verify that it was successful

To:cd build/linux-x86_64-normal-server-slowdebug/jdk/bin/
~: ./java -version
openjdk version "1.8.0 comes with internal - the debug".Copy the code

There should also be a compile_commands. Json file at the project root that is not empty.

4. Import CLion and debug it

See above for steps

OpenJDK 11

1. Download the OpenJDK11 source code

# First need to install git tools (if not available)
sudo apt-get install git
# Clone project code, which may take a long time
git clone [email protected]:AdoptOpenJDK/openjdk-jdk11u.git
Copy the code

2. Install the tool chain and its dependencies

# Need to download and install JDK10 as BootJDKMethods see aboveInstall the compiler and build tools
sudo apt-get install gcc g++ gdb make autoconf
Download and install dependency packages
sudo apt-get install libfreetype6-dev libcups2-dev
sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev
sudo apt-get install libasound2-dev libffi-dev
sudo apt-get install libfontconfig1-dev
Copy the code

3. Configure and build

# configurationsh ./configure --with-debug-level=slowdebug --with-native-debug-symbols=internal --with-target-bits=64 - with - the boot - JDK = / home/jiajiawang/software/JDK/JDK - 10.0.2Copy the code

If this is not successful, it is likely that some dependencies are missing and you can install them as prompted by the script.

Configure Parameter description:

parameter meaning
–with-debug-level Debug information level. The available values arerelease.fastdebug.slowdebug
–with-native-debug-symbols Specify how to builddebug symbol, the optional values arenone.internal.external.zipped, is set tointernalYou can debug it better
–with-target-bits The value can be 32-bit or 64-bit, depending on the operating system
–with-boot-jdk bootjdklocation
–with-freetype-include

–with-freetype-lib
The specifiedfreetypeIt depends on location. If the prompt is not foundfreetype, the two parameters need to be configured

See OpenJDK 11 Build readme-configure for more information and parameters

# Generate the Compilation Database
make compile-commands
# building
make all
Copy the code

For details about the make target, see OpenJDK 11 Build readme-make

When you’re done, you should be able to find the compiled JDK in./build/linux-x86_64-normal-server-slowdebug/ JDK and verify that it was successful

To:cd build/linux-x86_64-normal-server-slowdebug/jdk/bin/
~: ./java -version
openjdk version "11.0.8 - internal"The 2020-07-14...Copy the code

There will also be a non-empty compile_commands. Json file in /build/linux-x86_64-normal-server-slowdebug/.

4. Import CLion and debug it

The general steps are the same as described above. Note that you need to change the root directory of your project to the root directory of your source code (in this case openJDk-11u) after selecting the compile_commands. Json file in /build/linux-x86_64-normal-server-slowdebug/ to import your project Directory). Click on the Tools menu | Compilation Database | Change Project Root, select the source Root directory (u) its 11, wait to index.

MacOS 10.15 environment

OpenJDK 8

The steps for building OpenJDK on MacOS 10.15.5 are similar to those for Linux. However, due to the older version of OpenJDK 8, some of the dependencies cannot be found in MacOS 10.15.5, which leads to various problems during the configuration build process. This article provides a relatively simple and convenient method.

1. Download the OpenJDK8 source code

We chose to download the source code from the Github repository of AdoptOpenJDK

git clone [email protected]:AdoptOpenJDK/openjdk-jdk8u.git
Copy the code

2. Install the tool chain and its dependencies

  1. You need to download and install it firstjdk7As abootjdkThe method is shown at the beginning of the article.
  2. The installationHomeBrew.HomebrewIs aMacOSSoftware package management system on the system.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    Copy the code
  3. The installationXcode. You can directlyApp StoreSearch install, also available inDeveloper.apple.com/download/mo…Download the offline installation package. You can usexcodebuildCommand to check whether the installation is successful. If the version number is displayed, the installation is correct.
    xcodebuild -version
    Copy the code

    This may be reported if the installation is offlinexcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instanceWrong. That’s becausexcodebuildCan’t find the new installationXcode, simply execute the following command.

    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
    Copy the code
  4. Installing the Compilation Tool
    Install build tools
    brew install make
    Copy the code
  5. Dependencies required for installation
    # installed freetype
    brew install freetype
    Copy the code

3. Configure and build

3.1 Modifying Code

If you don’t modify the code, you get all kinds of errors when you execute configure. There are also many ways to fix the error by modifying the source file for each error. Here is a more convenient way. GitHub’s stooke/jdk8u-xcode10 project provides patch files that modify openJDk8 code. After modifying the code, you can configure normally.

git clone [email protected]:stooke/jdk8u-xcode10.git
Copy the code

The project itself provides scripts for downloading source code, downloading dependencies, modifying code, configuring it, compiling it, testing it, and so on, but we will only use the modified code. The README in the original project may be out of date, but by looking at the build8.sh file in the source code to get an idea of the execution logic, I have extracted the modified OpenJDK8 code from it and simplified it as follows:

Create a new shell script patch.sh with the following content:

#! /bin/bash
# JDK8 source directory
JDK_DIR=`pwd`
# download jdk8U-xcode10 project directory
PATCH_DIR="$(dirname $JDK_DIR)/jdk8u-xcode10"
PATCH_DIR="$PATCH_DIR/jdk8u-patch"

applypatch() {
	cd "$JDK_DIR/The $1"
	echo "applying The $1 $2"
	patch -p1 <$2
}

patchjdkbuild() {
	echo "patch jdk"
	# JDK-8019470: Changes needed to compile JDK 8 on MacOS with clang compiler
	applypatch . "$PATCH_DIR/jdk8u-8019470.patch"

	# JDK-8152545: Use preprocessor instead of compiling a program to generate native nio constants
	# (fixes genSocketOptionRegistry build error on 10.8)
	applypatch jdk "$PATCH_DIR/jdk8u-jdk-8152545.patch"

	# fix WARNINGS_ARE_ERRORS handling
	applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8241285.patch"

	# fix some help messages and Xcode version checks
	applypatch . "$PATCH_DIR/jdk8u-buildfix1.patch"
	# use correct C++ standard library
	#applypatch . "$PATCH_DIR/jdk8u-libcxxfix.patch"
	# misc clang-specific cleanup
	applypatch . "$PATCH_DIR/jdk8u-buildfix2.patch"

	# misc clang-specific cleanup; doesn't apply cleanly on top of 8019470 
	# (use -g1 for fastdebug builds)
	#applypatch . "$PATCH_DIR/jdk8u-buildfix2a.patch"

	# fix for clang crash if base has non-virtual destructor
	applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-8244878.patch"
	
	applypatch hotspot "$PATCH_DIR/jdk8u-hotspot-mac.patch"

	# Libosxapp. Dylib Fails to build on Mac OS 10.9 with clang
	applypatch jdk     "$PATCH_DIR/jdk8u-jdk-8043646.patch"

	applypatch jdk     "$PATCH_DIR/jdk8u-jdk-minversion.patch"
}
patchjdkbuild
Copy the code

Then execute this script:

bash patsh.sh
Copy the code

3.2 configuration

sh ./configure MAKE=/usr/bin/make --with-toolchain-type=clang --with-debug-level=slowdebug --disable-zip-debug-info - with - target - bits = 64 - with - the boot - JDK = / Users/jiajiawang/Software/JDK/jdk1.7.0 _80. JDK/Contents/Home / --with-freetype-include=/usr/local/ Cellar/freetype / 2.10.2 / include/freetype2 - with freetype - lib = / usr /local/ Cellar/freetype / 2.10.2 / lib /Copy the code

MAKE=/usr/bin/make is optional. If Bear is used to generate the Compilation Database, this parameter may not be used.

Configure some parameters are described as follows:

parameter meaning
–with-toolchain-type The value can be: Type of the tool chaingcc.clangCan be used--helpTo view all the optional values
–with-debug-level Debug information level. The available values arerelease.fastdebug.slowdebug
–disable-zip-debug-info Disables compression of debugging information. Set to true for better debugging
–with-target-bits The value can be 32-bit or 64-bit, depending on the operating system
–with-boot-jdk bootjdklocation
–with-freetype-include

–with-freetype-lib
The specifiedfreetypeDepending on location, in executionconfigureIf you can’t find itfreetypeThe two parameters need to be specified

See OpenJDK 8 Build Readme-configure for more descriptions of the parameters and more parameters

3.3 build

You can still use Bear or Compiledb to generate the Compilation Database, but there are some problems with bear, so compiledB is recommended.

Using compiledb
Make sure you have Python and PIP installedMethods Please search by yourself# 2. Install compiledb
pip install compiledb
# 3. Build and generate the Compilation Database using compiledb
compiledb make all COMPILER_WARNINGS_FATAL=false
You can use the LOG=debug option to output more detailed information
# compiledb make all LOG=debug COMPILER_WARNINGS_FATAL=false
Copy the code

Possible problems with using compiledB are that all items in the generated compile_Commands. Json file have directory entries that are the root of the project, resulting in a header file not being found, an error in importing CLion, and invalid code definitions and jumps. The reason for this is that on MacOS, compiledB may use gmake and can’t catch gmake switching paths, so paths are all root. The solution is to specify the use of make instead of gmake by specifying the make =/usr/bin/make parameter specified in Configure in the previous section.

The use of the bear

We used compiledb to generate the Compilation Database. We can also use bear to generate the Compilation Database:

# 1. SIP needs to be turned off first, otherwise the generated Compilation Database may be emptyTo disable SIP, search by yourself# 2. Install Bear
brew install bear
# 3. Build and use bear tool to generate the Compilation Database
bear make all COMPILER_WARNINGS_FATAL=false
You can use the LOG=debug option to output more detailed information
# compiledb make all LOG=debug COMPILER_WARNINGS_FATAL=false
Copy the code

If met with error/Applications/Xcode execute the command. The app/Contents/Developer/Toolchains/XcodeDefault xctoolchain/usr/bin /.. H :107:15: fatal error: ‘stdio.h’ file not found you can run the following command: /include/c++/v1/stdio.h:107:15: fatal error: ‘stdio.h’ file not found

sudo mount -uw /
sudo cp -R /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /usr
Copy the code

For more information about make target, see OpenJDK 8 Build readme-make

If no errors are reported, you should be able to find the compiled JDK in./build/macosx-x86_64-normal-server-slowdebug/ JDK and verify that it was successful

To:cd build/macosx-x86_64-normal-server-slowdebug/jdk/bin/
~: ./java -version
openjdk version "1.8.0 comes with internal - the debug".Copy the code

There should also be a compile_commands. Json file at the project root that is not empty.

4. Import CLion and debug it

When creating Custom Build Targets, add COMPILER_WARNINGS_FATAL=false to the make parameter in the External Tool for Build

OpenJDK 11

1. Download the OpenJDK11 source code

git clone [email protected]:AdoptOpenJDK/openjdk-jdk11u.git
Copy the code

2. Install the tool chain and its dependencies

  1. You need to download and install it firstjdk10As abootjdkThe method is shown at the beginning of the article.
  2. The installationHomeBrew.HomebrewIs aMacOSSoftware package management system on the system.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    Copy the code
  3. The installationXcode. You can directlyApp StoresearchXcodeInstallation is also available inDeveloper.apple.com/download/mo…Download the offline installation package. You can usexcodebuildCommand to check whether the installation is successful. If the version number is displayed, the installation is correct.
    xcodebuild -version
    Copy the code

    This may be reported if the installation is offlinexcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instanceWrong. That’s becausexcodebuildCan’t find the new installationXcode, simply execute the following command.

    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
    Copy the code
  4. Installing the Compilation Tool
    brew install autoconf
    brew install make
    Copy the code
  5. Dependencies required for installation
    # installed freetype
    brew install freetype
    Copy the code

3. Configure and compile

# configurationsh ./configure --with-debug-level=slowdebug --with-native-debug-symbols=internal --with-target-bits=64 - with - the boot - JDK = / Users/jiajiawang/Software/JDK/JDK - 10.0.2 + 13 / Contents/HomeCopy the code

Configure Parameter description:

parameter meaning
–with-debug-level Debug information level. The available values arerelease.fastdebug.slowdebug
–with-native-debug-symbols Specify how to builddebug symbol, the optional values arenone.internal.external.zipped, is set tointernalYou can debug it better
–with-target-bits The value can be 32-bit or 64-bit, depending on the operating system
–with-boot-jdk bootjdklocation
–with-freetype-include

–with-freetype-lib
The specifiedfreetypeDepending on location, in executionconfigureIf you can’t find itfreetypeThe two parameters need to be specified

See OpenJDK 11 Build readme-configure for more information and parameters

# Generate the Compilation Database
make compile-commands
# building
make all
Copy the code

When you’re done, you should have the file compile_commands. Json in /build/linux-x86_64-normal-server-slowdebug/.

For details about the make target, see OpenJDK 11 Build readme-make

When you’re done, you should be able to find the compiled JDK in./build/macosx-x86_64-normal-server-slowdebug/ JDK and verify that it’s successful

To:cd build/macosx-x86_64-normal-server-slowdebug/jdk/bin/
~: ./java -version
openjdk version "11.0.8 - internal"The 2020-07-14...Copy the code

You will also have the compile_commands. Json file in./build/macosx-x86_64-normal-server-slowdebug/ and it will not be empty.

4. Import CLion and debug it

The general steps are the same as described above. Note that you need to change the root of your project to the root of your source code (in this case openJDK-11) after importing the project from the compile_commands U directory). Click on the Tools menu | Compilation Database | Change Project Root, set the Root directory of the Project to source the Root directory (u) its 11, wait to index.

reference

  1. OpenJDK
  2. OpenJDK 8 Build README
  3. OpenJDK 11 Build README
  4. rizsotto/Bear: Bear is a tool that generates a compilation database for clang tooling
  5. nickdiego/compiledb: Tool for generating Clang’s JSON Compilation Database files for make-based build systems.
  6. Managing Makefile Projects
  7. Dealing with Makefile Projects in CLion: Status Update
  8. Tips & Tricks: Develop OpenJDK in CLion with Pleasure
  9. Debugging OpenJDK – DZone DevOps
  10. Compilation Database — Sarcasm notebook
  11. More Software Downloads – Apple Developer
  12. stooke/jdk8u-xcode10: How to compile JDK 8u with Xcode 9, 10 or 11 on macOS.