Fork me on GitHub

Mac Big Sur11.2.3 编译调试JDK8 问题总结

comparison between pointer and integer

解决方法

1
2
3
vim hotspot/src/share/vm/code/relocInfo.hpp
原:inline friend relocInfo prefix_relocInfo(int datalen = 0);
修改后:inline friend relocInfo prefix_relocInfo(int datalen);

fatal error: ‘JavaNativeFoundation/JavaNativeFoundation.h’ file not found

解决方法

1
2
3
4
5
6
vim hotspot/make/bsd/makefiles/saproc.make
替换路径
# SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
SALIBS = -g -framework Foundation -F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
# -I/System/Library/Frameworks/JavaVM.framework/Headers
-I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers

miss iostream

解决方法

1
2
3
下载文件
https://github.com/imkiwa/xcode-missing-libstdc-
执行install

JavaVM/jni.h’ file not found

解决方法

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
vim hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m
<JavaVM/jni.h> --> 替换为 <jni.h>

# loaded from '/System/Library/Frameworks/ApplicationServices.framework/Frameworks

解决方法
```bash
vim jdk/make/lib/PlatformLibraries.gmk
vim jdk/make/lib/Awt2dLibraries.gmk

包含JavaVM.framework 全部替换
替换
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

CFLAGS := $(CFLAGS_JDKLIB) \
-I$(JDK_TOPDIR)/src/macosx/native/apple/applescript \
-F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Frameworks \
-F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX := -framework Cocoa \
-framework Carbon \
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-framework JavaNativeFoundation \
$(LDFLAGS_JDKLIB_SUFFIX), \

clang: error: unknown argument: ‘-fpch-deps’

1
2
3
4
5
6
7
vim hotspot/make/bsd/makefiles/gcc.make
注释
ifeq ($(USE_CLANG),)
ifneq ($(CC_VER_MAJOR), 2)
DEPFLAGS += -fpch-deps
endif
endif

/jdk/src/share/native/sun/security/krb5/nativeccache.c:322:21: error: implicitly declaring library function ‘strncmp’ with type ‘int (const char , const char , unsigned long)’ [-Werror,-Wimplicit-function-declaration]

if (strncmp (serverName, "krbtgt", sizeof("krbtgt")-1) == 0 &&

解决方案

1
2
3
vim /jdk/src/share/native/sun/security/krb5/nativeccache.c
添加
#include <string.h>

/jdk/src/share/instrument/JarFacade.c:61:20: error: implicitly declaring library function ‘isspace’ with type ‘int (int)’

解决方案

1
2
添加文件
#include <ctype.h>.

implicit declaration of function ‘free’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]

解决方案

1
<stdlib.h>

fatal error: ‘X11/Intrinsic.h’ file not found

解决方案
安装Quartz
创建链接

1
2
3
sudo ln -s /opt/X11/include/X11 /usr/local/include/X11

sudo ln -s /opt/X11/include/X11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again

解决方案

1
2
3
4
5
vim hotspot/src/share/vm/runtime/perfMemory.cpp

注释
if (!StatSampler::is_active())
//PerfDataManager::destroy();

下面为编译jdk配置的参数,为避免其他错误,在窗口执行

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
# 设定语言选项,必须设置
export LANG=C
# Mac平台,C编译器不再是GCC,是clang
export CC=clang
# 跳过clang的一些严格的语法检查,不然会将N多的警告作为Error
export COMPILER_WARNINGS_FATAL=false
# 链接时使用的参数
export LFLAGS='-Xlinker -lstdc++'
# 是否使用clang
export USE_CLANG=true
# 使用64位数据模型
export LP64=1
# 告诉编译平台是64位,不然会按32位来编译
export ARCH_DATA_MODEL=64
# 允许自动下载依赖
export ALLOW_DOWNLOADS=true
# 并行编译的线程数,编译时间长,为了不影响其他工作,我选择为2
export HOTSPOT_BUILD_JOBS=2
export ALT_PARALLEL_COMPILE_JOBS=2
# 是否跳过与先前版本的比较
export SKIP_COMPARE_IMAGES=true
# 是否使用预编译头文件,加快编译速度
export USE_PRECOMPILED_HEADER=true
# 是否使用增量编译
export INCREMENTAL_BUILD=true
# 编译内容
export BUILD_LANGTOOLS=true
export BUILD_JAXP=true
export BUILD_JAXWS=true
export BUILD_CORBA=true
export BUILD_HOTSPOT=true
export BUILD_JDK=true
# 编译版本
export SKIP_DEBUG_BUILD=true
export SKIP_FASTDEBUG_BUILD=false
export DEBUG_NAME=debug
# 避开javaws和浏览器Java插件之类的部分的build
export BUILD_DEPLOY=false
export BUILD_INSTALL=false

显示 Gitment 评论