参考文章:https://blog.csdn.net/wqlinloveruby/article/details/80409031
下载地址:http://www.cygwin.com/setup-x86_64.exe,请下载64位版本
1.打开安装文件,点击下一步
2.选择第一项,点击下一步
3.点击下一步到如下界面
添加国内镜像,我用的163的地址为:http://mirrors.163.com/cygwin/,点击下一步进行安装
4.下载依赖包
将左上角view下拉框变为如图所示
安装以下依赖包,根据category中的名称进行下载(这么下载可能下载的比较多,主要是package包依赖很难找)
配置cygwin到windos的环境变量中
为照顾没有使用过vs的同学,介绍一下编译的具体过程,第一次打开vs2010的话,选择使用VC++,找到你解压freetype的路径 D:\MyWorkSpace\freetype-2.9.1\builds\windows\vc2010
打开后,右键项目,选择属性,如图
修改目录扩展名以及配置类型如图所示
然后点击右上角配置管理器,改为下图所示
然后在编译一次生成DLL
然后生成文件在D:\MyWorkSpace\freetype-2.9.1\objs
然后咱们在D:\MyWorkSpace\freetype-2.9.1目录下创建lib文件夹,并将编译好的freetype.dll和freetype.lib复制到该目录。
然后还需要设置一下freetype的环境变量,FREETYPE_CFLAGS=D:\MyWorkSpace\freetype-2.9.1\include FREETYPE_LIBS=D:\MyWorkSpace\freetype-2.9.1\lib,可以尝试直接设置在path中。如图:
打开cygwin,切换到解压的openjdk_8的文件夹根目录,如:
./configure -with-freetype=/cygdrive/d/MyWorkSpace/freetype-2.9.1/ -enable-debug -with-target-bits=64 with_toolsdir="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build" --disable-ccache
报错如下:
1.
Your cygwin is too old. You are running 2.10.0(0.325/5/3), but at least cygwin 1.7 is required.
如果cygwin安装的是2.X的版本则在编译的过程中会报cygwin的版本太老,这是检测脚本的一个bug,该脚本在common/autoconf目录下使用文本编辑器打开generated-configure.sh搜索Your cygwin is too old,关注7220行原来是1.7这里我根据自己的cygwin版本改成不是1.7以下的判断。
最简单的修改方案就是把打直接写死当前cygwin的版本我的是2.10.0
2.
Cannot locate a valid Visual Studio or Windows SDK installation on disk
卸载机器上的Microsoft Visual C++ 2010 redistributable packages (both x86 as well as x64) 组件
然后从以下地址下载重新安装
x64:
http://www.microsoft.com/en-us/download/details.aspx?id=14632
x86:
http://www.microsoft.com/en-us/download/details.aspx?id=5555
然后安装Microsoft SDK 7.1下载地址
https://www.microsoft.com/en-us/download/details.aspx?id=8442
打开/common/autoconf/generated-configure.sh文件,搜索“Cannot locate a valid Visual Studio”进行定位,发现可以通过传入–with-tools-dir参数指定vcvars32.bat的路径,从而定位到头文件、库文件等的路径。针对VS2017,该批处理位于以下路径:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build
修改generated-configure.sh文件中如图位置
修改为如下所示:
# First-hand choice is to locate and run the vsvars bat file.
if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then
VCVARSFILE="VC/Auxiliary/Build/vcvars32xp.bat"
else
VCVARSFILE="VC/Auxiliary/Build/vcvars64.bat"
fi
VS_ENV_CMD=""
VS_ENV_ARGS=""
if test "x$with_toolsdir" != x; then
if test "x$VS_ENV_CMD" = x; then
VS100BASE="$with_toolsdir/../../.."
METHOD="--with-tools-dir"
3 .报错信息如下
/usr/bin/sort: cannot read: localdevenvtmp.export1: No such file or directory
no
configure: Could not succesfully extract the envionment variables needed for the VS setup.
报错出处来源于以下代码
if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
_vs10varsall=`cygpath -a -m -s "$VS_ENV_CMD"`
_dosvs10varsall=`cygpath -a -w -s $_vs10varsall`
_dosbash=`cygpath -a -w -s \`which bash\`.*`
else
_dosvs10varsall=`cmd //c echo $VS_ENV_CMD`
_dosbash=`cmd //c echo \`which bash\``
fi
# generate the set of exported vars before/after the vs10 setup
echo '-----------------$ECHO'
$ECHO "@echo off" > localdevenvtmp.bat
$ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export0" >> localdevenvtmp.bat
$ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
$ECHO "$_dosbash -c \"export -p\" > localdevenvtmp.export1" >> localdevenvtmp.bat
# Now execute the newly created bat file.
# The | cat is to stop SetEnv.Cmd to mess with system colors on msys
cmd /c localdevenvtmp.bat | cat
# apply the diff (less some non-vs10 vars named by "!")
$SORT localdevenvtmp.export0 | $GREP -v "!" > localdevenvtmp.export0.sort
$SORT localdevenvtmp.export1 | $GREP -v "!" > localdevenvtmp.export1.sort
$COMM -1 -3 localdevenvtmp.export0.sort localdevenvtmp.export1.sort > localdevenv.sh
找到文件
$ cd /cygdrive/d/MyWorkSpace/openjdk/build/windows-x86_64-normal-server-fastdebug
$ vi localdevenvtmp.bat
@echo off
C:\cygwin64\bin\bash.exe -c "export -p" > localdevenvtmp.export0
call C:\progra~2\mib055~1\2017\commun~1\vc\auxili~1\build\vcvars64.bat
C:\cygwin64\bin\bash.exe -c "export -p > localdevenvtmp.export1"
原因为call之后切换了环境变量创建的localdevenvtmp.export1不在指定位置
# generate the set of exported vars before/after the vs10 setup
$ECHO "@echo off" > localdevenvtmp.bat
$ECHO "$_dosbash -c \"export -p\" > D:/MyWorkSpace/openjdk/build/windows-x86_64-normal-server-fastdebug/localdevenvtmp.export0" >> localdevenvtmp.bat
$ECHO "call $_dosvs10varsall $VS_ENV_ARGS" >> localdevenvtmp.bat
$ECHO "$_dosbash -c \"export -p\" > D:/MyWorkSpace/openjdk/build/windows-x86_64-normal-server-fastdebug/localdevenvtmp.export1" >> localdevenvtmp.bat
4 继续报错
configure: error: Target CPU mismatch. We are building for x86_64 but CL is for ""; expected "x64".
错误段代码
# First line typically looks something like:
# Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
COMPILER_VERSION_TEST=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'`
COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*Version \([1-9][0-9.]*\) .*/\1/p"`
COMPILER_VENDOR="Microsoft CL.EXE"
COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"`
if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
if test "x$COMPILER_CPU_TEST" != "x80x86"; then
as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." "$LINENO" 5
fi
elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
if test "x$COMPILER_CPU_TEST" != "xx64"; then
as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." "$LINENO" 5
fi
fi
注释以下代码,一共有两处都要注释
if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
if test "x$COMPILER_CPU_TEST" != "x80x86"; then
as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"80x86\"." "$LINENO" 5
fi
elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
if test "x$COMPILER_CPU_TEST" != "xx64"; then
as_fn_error $? "Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for \"$COMPILER_CPU_TEST\"; expected \"x64\"." "$LINENO" 5
fi
fi
make images
if [ "x$FORCE_MSC_VER" != "x" ]; then
echo "MSC_VER=$FORCE_MSC_VER"
else
MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1`
MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2`
MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3`
if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then
# This said 1400 but it was really more like VS2003 (VC7) in terms of options
MSC_VER=1399
else
MSC_VER=`"$EXPR" $MSC_VER_MAJOR \* 100 + $MSC_VER_MINOR`
fi
echo "MSC_VER=$MSC_VER"
echo "MSC_VER_RAW=$MSC_VER_RAW"
fi
修改为
if [ "x$FORCE_MSC_VER" != "x" ]; then
echo "MSC_VER=$FORCE_MSC_VER"
else
MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1`
MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2`
MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3`
if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then
# This said 1400 but it was really more like VS2003 (VC7) in terms of options
MSC_VER=1399
else
MSC_VER=1700
fi
echo "MSC_VER=$MSC_VER"
echo "MSC_VER_RAW=$MSC_VER_RAW"
fi
进入目录执行编译指令,此步是在CMD指令下执行,不是在cygwin
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build
c:
vcvars64.bat
cd D:\MyWorkSpace\openjdk\hotspot\make\windows
d:
set HOTSPOTMKSHOME=C:\cygwin64\bin
set MSC_VER=1700
create.bat D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\images\j2sdk-image
这是由于c++版本问题需要进行源码修改,先将HostSpot项目导入VS2017中,利用VS2017快速修改其源码,使其通过编译。然而执行create.bat时马上就报错了:
在window中将如下参数加入环境变量
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64
成功结果如图所示
get_msc_ver.sh: line 65:编译完成前还出现了这个错误
if [ "x$FORCE_MSC_VER" != "x" ]; then
echo "MSC_VER=$FORCE_MSC_VER"
else
MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1`
MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2`
MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3`
MSC_VER_MAJOR
if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then
# This said 1400 but it was really more like VS2003 (VC7) in terms of options
MSC_VER=1399
else
MSC_VER=1700
fi
echo "MSC_VER=$MSC_VER"
echo "MSC_VER_RAW=$MSC_VER_RAW"
fi
修改为
if [ "x$FORCE_MSC_VER" != "x" ]; then
echo "MSC_VER=$FORCE_MSC_VER"
else
MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1`
MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2`
MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3`
MSC_VER=1700
echo "MSC_VER=$MSC_VER"
echo "MSC_VER_RAW=$MSC_VER_RAW"
fi
error C2084: function 'int vsnprintf(char *const ,const ::size_t,const char *const ,va_list)' already has a body
这个问题是JVM中定义了自己的vsnprintf函数,和C库的vsnprintf函数撞衫了。将JVM自定义的vsnprintf函数重命名为jvmvsnprintf即可:
然后是一大堆的E2474错误,值得注意的是,使用旧版本的编译器不会有问题,因为这是启用C++11特性所带来的坑。其实就是这些宏本身就是字符串,其与两侧的分号应该有空格间隔。解决方案就是补加空格。
用一段代码举例
out->print_cr(" Total per region rem sets sizes = "SIZE_FORMAT"K."
" Max = "SIZE_FORMAT"K.",
round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz()));
修改为
out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT "K."
" Max = " SIZE_FORMAT "K.",
round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz()));
有一大堆要改,估计得有几千处,慢慢改吧~~~~
C2065 “timezone”: 未声明的标识符 jvm D:\MyWorkSpace\openjdk\hotspot\src\share\vm\runtime\os.cpp
将以下代码修改为
#if defined(_ALLBSD_SOURCE)
const time_t zone = (time_t) time_struct.tm_gmtoff;
#else
const time_t zone = timezone;
#endif
#if defined(_ALLBSD_SOURCE)
const time_t zone = (time_t) time_struct.tm_gmtoff;
#else
#if _MSC_VER < 1900
const time_t zone = timezone;
#else
const time_t zone = 0;
_get_timezone((long *)&zone);
#endif
#endif
make images
先找出负责link版本的那个make文件:D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\sanity.make,将对cl和link版本进行判断的脚本注释掉。
!include local.make
all: checkCL checkLink
checkCL:
@ if "$(MSC_VER)" NEQ "1310" if "$(MSC_VER)" NEQ "1399" if "$(MSC_VER)" NEQ "1400" if "$(MSC_VER)" NEQ "1500" if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" \
echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) ($(RAW_MSC_VER)). Use FORCE_MSC_VER to override automatic detection.
checkLink:
@ if "$(LD_VER)" NEQ "710" if "$(LD_VER)" NEQ "800" if "$(LD_VER)" NEQ "900" if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" \
echo *** WARNING *** unrecognized link.exe version $(LD_VER) ($(RAW_LD_VER)). Use FORCE_LD_VER to override automatic detection.
修改为
!include local.make
#all: checkCL checkLink
#checkCL:
# @ if "$(MSC_VER)" NEQ "1310" if "$(MSC_VER)" NEQ "1399" if "$(MSC_VER)" NEQ "1400" if "$(MSC_VER)" NEQ "1500" if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" \
# echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) ($(RAW_MSC_VER)). Use FORCE_MSC_VER to override automatic detection.
#checkLink:
# @ if "$(LD_VER)" NEQ "710" if "$(LD_VER)" NEQ "800" if "$(LD_VER)" NEQ "900" if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" \
# echo *** WARNING *** unrecognized link.exe version $(LD_VER) ($(RAW_LD_VER)). Use FORCE_LD_VER to override automatic detection.
然后打开D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\下的compile.make,做如下修改:
# 第56行 去掉/WX
CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 /WX
修改为
CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3
# 第123行,去掉判定逻辑,强制指定表情且添加MSC_VER=1700
!if "x$(MSC_VER)" == "x"
COMPILER_NAME=$(DEFAULT_COMPILER_NAME)
!else
!if "$(MSC_VER)" == "1200"
COMPILER_NAME=VC6
!endif
!if "$(MSC_VER)" == "1300"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1310"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1399"
# Compiler might say 1400, but if it's 14.00.30701, it isn't really VS2005
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1400"
COMPILER_NAME=VS2005
!endif
!if "$(MSC_VER)" == "1500"
COMPILER_NAME=VS2008
!endif
!if "$(MSC_VER)" == "1600"
COMPILER_NAME=VS2010
!endif
!if "$(MSC_VER)" == "1700"
COMPILER_NAME=VS2012
!endif
!endif
修改为
MSC_VER=1700
!if "x$(MSC_VER)" == "x"
COMPILER_NAME=VS2012
!else
!if "$(MSC_VER)" == "1200"
COMPILER_NAME=VC6
!endif
!if "$(MSC_VER)" == "1300"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1310"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1399"
# Compiler might say 1400, but if it's 14.00.30701, it isn't really VS2005
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1400"
COMPILER_NAME=VS2005
!endif
!if "$(MSC_VER)" == "1500"
COMPILER_NAME=VS2008
!endif
!if "$(MSC_VER)" == "1600"
COMPILER_NAME=VS2010
!endif
!if "$(MSC_VER)" == "1700"
COMPILER_NAME=VS2012
!endif
!endif
arena.cpp(60): error C2956:报错
修改arena.hpp
class Chunk: public CHeapObj {
public:
void* operator new(size_t size, size_t length) throw();
void operator delete(void* p, size_t length);
Chunk(size_t length);
enum {
init_size = 1*1024, // Size of first chunk
size = 32*1024 // Default size of an Arena chunk (following the first)
};
Chunk* _next; // Next Chunk in list
size_t _len; // Size of this Chunk
void chop(); // Chop this chunk
void next_chop(); // Chop next chunk
// Boundaries of data area (possibly unused)
char* bottom() const { return ((char*) this) + sizeof(Chunk); }
char* top() const { return bottom() + _len; }
};
修改为
class Chunk: public CHeapObj {
enum class busx_size_t : size_t {};
public:
void* operator new(size_t size, size_t length) throw();
void operator delete(void* p, busx_size_t length);
Chunk(size_t length);
enum {
init_size = 1*1024, // Size of first chunk
size = 32*1024 // Default size of an Arena chunk (following the first)
};
Chunk* _next; // Next Chunk in list
size_t _len; // Size of this Chunk
void chop(); // Chop this chunk
void next_chop(); // Chop next chunk
// Boundaries of data area (possibly unused)
char* bottom() const { return ((char*) this) + sizeof(Chunk); }
char* top() const { return bottom() + _len; }
};
arena.cpp也按照此方法修改
问题原因https://msdn.microsoft.com/en-us/library/mt723604.aspx
报错fixpath.exe权限不足
/bin/sh: /cygdrive/d/MyWorkSpace/openjdk/build/windows-x86_64-normal-server-fastdebug/fixpath.exe: Permission denied
lib/CoreLibraries.gmk:37错误
在configure时加入参数 –disable-ccache
BuildJdk.gmk:70错误
这个问题貌似是动态CRT库和静态CRT库打架了,但JVM貌似全部都依赖的是动态库啊,不然也不会让传入msvcr100.dll路径了。上网查了半天,终于发现问题了:
We resolved the issue. Seems we had the following in one of our header files to work around in issue with one of the earlier versions of VS 2012.
说白了这是历史遗留问题,VS2012时代的历史遗留产物到了VS2017时代不好用了,也就是下面这两个家伙需要被干掉:
#define _STATIC_CPPLIB
#define _DISABLE_DEPRECATE_STATIC_CPPLIB
在文件夹中全局搜索“_STATIC_CPPLIB”字样,只要不是出现在PDB文件里,咱们统统将其干掉。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\config.status' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 15:04:22; 2017/12/19 星期二 15:04:24):”
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\config.status(662): S["CXXFLAGS_JDKEXE"]=" -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DE"\
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\config.status(667): S["CXXFLAGS_JDKLIB"]=" -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DE"\
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\config.status(673): S["CFLAGS_JDKEXE"]=" -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DE"\
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\config.status(678): S["CFLAGS_JDKLIB"]=" -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DE"\
找到 '_STATIC_CPPLIB' 8 次。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\spec.gmk' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 15:04:25; 2017/12/19 星期二 15:04:25):”
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\spec.gmk(327): CFLAGS_JDKLIB:= -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL -D_X86_ -Dx86 -D_LITTLE_ENDIAN -DWINDOWS -DDEBUG -DARCH='"i586"' -Di586 -DRELEASE='"$(RELEASE)"' -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include/windows -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/native/common -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/native/common
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\spec.gmk(328): CXXFLAGS_JDKLIB:= -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL -D_X86_ -Dx86 -D_LITTLE_ENDIAN -DWINDOWS -DDEBUG -DARCH='"i586"' -Di586 -DRELEASE='"$(RELEASE)"' -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include/windows -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/native/common -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/native/common
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\spec.gmk(331): CFLAGS_JDKEXE:= -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL -D_X86_ -Dx86 -D_LITTLE_ENDIAN -DWINDOWS -DDEBUG -DARCH='"i586"' -Di586 -DRELEASE='"$(RELEASE)"' -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include/windows -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/native/common -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/native/common
D:\MyWorkSpace\openjdk\build\windows-x86_64-normal-server-fastdebug\spec.gmk(332): CXXFLAGS_JDKEXE:= -nologo -Zi -MD -Zc:wchar_t- -W3 -wd4800 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL -D_X86_ -Dx86 -D_LITTLE_ENDIAN -DWINDOWS -DDEBUG -DARCH='"i586"' -Di586 -DRELEASE='"$(RELEASE)"' -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include -I/cygdrive/i/jvm/jdk8u-dev/build/windows-x86-normal-client-slowdebug/jdk/include/windows -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/javavm/export -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/share/native/common -I/cygdrive/i/jvm/jdk8u-dev/jdk/src/windows/native/common
找到 '_STATIC_CPPLIB' 8 次。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\common\autoconf\generated-configure.sh' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 13:06:27; 2017/12/19 星期二 15:03:25):”
D:\MyWorkSpace\openjdk\common\autoconf\generated-configure.sh(30017): -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
找到 '_STATIC_CPPLIB' 2 次。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\common\autoconf\toolchain.m4' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 13:06:27; 2017/12/17 星期日 11:07:41):”
D:\MyWorkSpace\openjdk\common\autoconf\toolchain.m4(1068): -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
找到 '_STATIC_CPPLIB' 2 次。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\adlc.make' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 13:07:40; 2017/12/17 星期日 11:08:56):”
D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\adlc.make(29): # $(MS_RUNTIME_OPTION) ( with /D_STATIC_CPPLIB)
找到 '_STATIC_CPPLIB' 1 次。
----------------------------------------
“在 'D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\compile.make' 中查找 '_STATIC_CPPLIB' (2017/12/19 星期二 13:07:40; 2017/12/19 星期二 20:34:01):”
D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\compile.make(160): # /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\compile.make(162): # Always add the _STATIC_CPPLIB flag
D:\MyWorkSpace\openjdk\hotspot\make\windows\makefiles\compile.make(163): STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
找到 '_STATIC_CPPLIB' 5 次。
解决报错:CreateJars.gmk中的错误
这个错误比较坑,在Google上搜索得到的结果又是换行符不同造成的血案。为此,需要修改两处class文件的换行标识。
用vi打开jdk\make目录下的CreateJars.gmk,定位到268行,相距不远处有两个
Exception in thread "main" java.lang.VerifyError: class jdk.nashorn.internal.objects.ScriptFunctionImpl overrides final method setPrototype.(Ljava/lang/Object;)V
修改:D:\MyWorkSpace\openjdk\nashorn\make\BuildNashorn.gmk 80行
$(FIXPATH) $(JAVA) \
-cp "$(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes" \
jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
修改为
$(FIXPATH) $(JAVA) \
-Xbootclasspath/p:"$(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes" \
jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)