With the following, I can not build the project (compiles fine, but linking fails), but navigation seems to work fine mostly. Updated to work with OpenJDK 21 source.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
cmake_minimum_required(VERSION 3.22)
project(clion-jdk)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_CXX_FLAGS "-fpermissive -Wno-format-zero-length -Wconversion")

set(build_path "./build")

MACRO(expand_glob result pattern)
file(GLOB elements RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${pattern})

SET(dir_list "")
FOREACH(e ${elements})
IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${e})
# message(${e})
LIST(APPEND dir_list ${e})
ENDIF()
ENDFOREACH()
SET(${result} ${dir_list})
ENDMACRO()

MACRO(include_glob pattern)
expand_glob(dir_list "${pattern}")
include_directories(${dir_list})
ENDMACRO()

# include curdir and curdir/* (only one level deep)
function(include_under curdir)
include_directories(${curdir})

expand_glob(dir_list ${curdir}/*)
include_directories(${dir_list})
endfunction()

include_directories(${build_path}/linux-x64-debug/jdk/include/)
include_directories(${build_path}/linux-x64-debug/hotspot/variant-server/gensrc/)

include_directories(${build_path}/linux-x64-debug/support/modules_include/java.base)
include_directories(${build_path}/linux-x64-debug/support/modules_include/java.base/linux/)

include_under(${build_path}/linux-x64-debug/support/headers/)

include_directories(src/hotspot/share/)
include_directories(src/hotspot/share/include)
include_directories(src/hotspot/share/precompiled/)

include_directories(src/hotspot/cpu/x86/)
#include_directories(src/hotspot/os/bsd/)
include_directories(src/hotspot/os/linux/)
include_directories(src/hotspot/os/posix/)
include_directories(src/hotspot/os/posix/include)
include_directories(src/hotspot/os_cpu/linux_x86/)

include_glob(src/*/share/native/*)
include_glob(src/*/unix/native/*)
include_glob(src/*/linux/native/*)

include_glob(src/*/share/native/*/*)
include_glob(src/*/unix/native/*/*)

add_definitions(-D_XOPEN_SOURCE)
add_definitions(-D_GNU_SOURCE)
#add_definitions(-D_ALLBSD_SOURCE)
#add_definitions(-D_DARWIN_C_SOURCE)
#add_definitions(-DCHECK_UNHANDLED_OOPS)
add_definitions(-DLINUX)
add_definitions(-DSUPPORTS_CLOCK_MONOTONIC)

add_definitions(-DASSERT)
# add_definitions(-D_NMT_NOINLINE_)
add_definitions(-DDONT_USE_PRECOMPILED_HEADER)
add_definitions(-DAMD64)
add_definitions(-DHOTSPOT_LIB_ARCH="amd64")
add_definitions(-DARCHPROPNAME="amd64")
add_definitions(-DTARGET_ARCH_x86)
add_definitions(-DINCLUDE_SUFFIX_OS=_linux)
add_definitions(-DINCLUDE_SUFFIX_CPU=_x86)
add_definitions(-DINCLUDE_SUFFIX_COMPILER=_gcc)
add_definitions(-DTARGET_COMPILER_gcc)

add_definitions(-DCOMPILER1)
add_definitions(-DCOMPILER2)
add_definitions(-DINCLUDE_AOT)

add_definitions(-DVERSION_MAJOR=0)
add_definitions(-DVERSION_MINOR=0)
add_definitions(-DVERSION_SECURITY=0)
add_definitions(-DVERSION_PATCH=0)
add_definitions(-DVERSION_FEATURE=0)
add_definitions(-DVERSION_INTERIM=0)
add_definitions(-DVERSION_UPDATE=0)

add_definitions(-DVERSION_BUILD=0)
add_definitions(-DVERSION_STRING="0-internal+0-adhoc.openjdk.vm")
add_definitions(-DHOTSPOT_VERSION_STRING="0-internal+0-adhoc.openjdk.vm")

add_definitions(-DDEBUG_LEVEL="fastdebug")
add_definitions(-DHOTSPOT_VM_DISTRO="OpenJDK")
add_definitions(-DHOTSPOT_BUILD_USER="openjdk")

file(GLOB_RECURSE SOURCE_FILES
# only hotspot
src/hotspot/*.c src/hotspot/*.cpp
src/hotspot/*.h src/hotspot/*.hpp
# src/*.java
${build_path}/linux-x64-debug/hotspot/variant-server/support/adlc/*.cpp
)

# g1gc
# list(FILTER SOURCE_FILES EXCLUDE REGEX ".*/gc/g1.*")
# shenandoah
#list(FILTER SOURCE_FILES EXCLUDE REGEX ".*/gc/shenandoah.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*java.desktop.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*jdk.jdi.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*share/shark.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*hsdis.*")

# cpu
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*aarch64.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*arm.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*ppc.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*riscv.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*s390.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*x86_32.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*zero.*")

# os
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*aix.*")
#list(FILTER SOURCE_FILES EXCLUDE REGEX ".*linux.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*bsd.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*macosx.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*solaris.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*windows.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*libadt/dict.*")

#message(${SOURCE_FILES})

add_executable(a.out ${SOURCE_FILES})