cygwin jdk11u

cygwin jdk11u

 

安装 Cygwin64

下载地址 https://cygwin.com/setup-x86_64.exe

Cygwin 国内源    中科大镜像源 http://mirrors.ustc.edu.cn/cygwin/

选择安装的包:(automatically added) 表示根据依赖自动添加的包

Install _autorebase 001007-1
Install alternatives 1.3.30c-10
Install autoconf 13-1 (automatically added)
Install autoconf2.1 2.13-12 (automatically added)
Install autoconf2.5 2.69-3
Install automake1.15 1.15.1-1
Install base-cygwin 3.8-1
Install base-files 4.2-4
Install bash 4.4.12-3
Install binutils 2.29-1
Install binutils-debuginfo 2.29-1
Install bsdcat 3.3.2-1
Install bsdcpio 3.3.2-1
Install bsdiff 4.3-5
Install bsdtar 3.3.2-1
Install busybox 1.23.2-1
Install busybox-debuginfo 1.23.2-1
Install bzip2 1.0.6-3
Install ca-certificates 2.22-1
Install coreutils 8.26-2
Install cpio 2.11-3
Install cygutils 1.4.16-2
Install cygwin 2.11.2-1
Install cygwin-debuginfo 2.11.2-1 (automatically added)
Install dash 0.5.9.1-1
Install diffutils 3.5-2
Install editrights 1.03-1
Install file 5.32-1
Install findutils 4.6.0-1
Install gawk 4.2.1-1
Install getent 2.18.90-4
Install grep 3.0-2
Install groff 1.22.3-1
Install guile2.0 2.0.14-3
Install gzip 1.8-1
Install hostname 3.13-1
Install info 6.5-2
Install ipc-utils 1.0-2
Install less 530-1
Install libarchive13 3.3.2-1 (automatically added)
Install libargp 20110921-3
Install libattr1 2.4.48-2
Install libblkid1 2.25.2-2
Install libbz2_1 1.0.6-3
Install libcrypt0 2.1-1 (automatically added)
Install libdb5.3 5.3.28-2 (automatically added)
Install libffi6 3.2.1-2
Install libgc1 7.6.10-1 (automatically added)
Install libgcc1 7.4.0-1
Install libgdbm4 1.12-1
Install libgmp10 6.1.2-1
Install libgnutls30 3.5.18-1 (automatically added)
Install libguile2.0_22 2.0.14-3 (automatically added)
Install libhogweed4 3.4-1 (automatically added)
Install libiconv 1.14-3
Install libiconv2 1.14-3
Install libidn2_0 2.0.4-1 (automatically added)
Install libintl8 0.19.8.1-2
Install libltdl7 2.4.6-6 (automatically added)
Install liblz4_1 1.7.5-1 (automatically added)
Install liblzma5 5.2.3-1
Install libmpfr6 4.0.1-4p11
Install libncursesw10 6.0-12.20171125
Install libnettle6 3.4-1 (automatically added)
Install libopenssl100 1.0.2p-1
Install libp11-kit0 0.23.10-1
Install libpcre1 8.40-3
Install libpipeline1 1.4.0-1
Install libpopt-common 1.16-2
Install libpopt0 1.16-2
Install libprocps-ng6 3.3.12-2 (automatically added)
Install libpsl5 0.18.0-1 (automatically added)
Install libreadline7 7.0.3-3
Install libsigsegv2 2.10-2
Install libsmartcols1 2.25.2-2
Install libssp0 6.4.0-4 (automatically added)
Install libstdc++6 7.4.0-1
Install libtasn1_6 4.13-1
Install libunistring2 0.9.10-1 (automatically added)
Install libuuid1 2.25.2-2
Install libxml2 2.9.4-2 (automatically added)
Install login 1.12-1
Install m4 1.4.18-1
Install make 4.2.1-2
Install man-db 2.7.6.1-1
Install mintty 2.9.5-0
Install nano 2.9.7-1
Install ncurses 6.0-12.20171125
Install openssl 1.0.2p-1
Install p11-kit 0.23.10-1
Install p11-kit-trust 0.23.10-1
Install perl 5.26.3-1 (automatically added)
Install perl-Carp 1.38-2 (automatically added)
Install perl_autorebase 5.26.3-1 (automatically added)
Install perl_base 5.26.3-1 (automatically added)
Install procps-ng 3.3.12-2
Install psmisc 22.20-1
Install publicsuffix-list-dafsa 20180523-1 (automatically added)
Install rebase 4.4.4-1
Install run 1.3.4-2
Install sed 4.4-1
Install tar 1.29-1
Install terminfo 6.0-12.20171125
Install texinfo 6.5-2 (automatically added)
Install tzcode 2018e-1
Install tzdata 2018e-1
Install unzip 6.0-17
Install util-linux 2.25.2-2
Install vim-minimal 8.0.1567-1
Install wget 1.19.1-2
Install which 2.20-2
Install xz 5.2.3-1
Install zip 3.0-12
Install zlib0 1.2.11-1

 

 

添加环境变量到系统Path变量中

推荐使用 rapidee 进行环境变量修改  软件下载地址  https://www.rapidee.com/en/download

命令行追加环境变量  set path=%path:%C:\cygwin64\bin
命令行查看环境变量  echo %path%

 

Cygwin64的模拟终端:

快捷方式目标:  C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

起始位置:  C:\cygwin64

图标:  C:\cygwin64\Cygwin-Terminal.ico

 

 

Copying skeleton files.
These files are for the users to personalise their cygwin experience.

They will never be overwritten nor automatically updated.

'./.bashrc' -> '/home/lsgx//.bashrc'
'./.bash_profile' -> '/home/lsgx//.bash_profile'
'./.inputrc' -> '/home/lsgx//.inputrc'
'./.profile' -> '/home/lsgx//.profile'

lsgx@DESKTOP-M1LAIA2 ~
$ cygcheck -c cygwin
Cygwin Package Information
Package              Version        Status
cygwin               2.11.2-1       OK

lsgx@DESKTOP-M1LAIA2 ~
$

 

安装 Mercurial ( hg )

下载地址 https://bitbucket.org/tortoisehg/files/downloads/

下载地址 https://www.mercurial-scm.org/downloads

 

获取 openjdk 源码

Mercurial(Hg) 克隆源码库,这样获取的源码包含提交log和tag,更新也比较方便,推荐这样操作。

命令  hg clone --verbose http://hg.openjdk.java.net/jdk-updates/jdk11u "D:\jdk11u"

 

直接下载打包的 openjdk 源码,不包含提交log和tag,更新一般需要重新下载包。

下载地址 http://hg.openjdk.java.net/jdk-updates/jdk11u/file/

 

编译 openjdk 11

-------------------------------------- make images

编译参考文档 D:/jdk11-1ddf9a99e4ad/doc/building.html

测试参考文档 D:/jdk11-1ddf9a99e4ad/doc/testing.html

注意 visual studio 必须使用英文版,不能安装其他语言包,否则在编译配置时无法识别到c++编译器。

# 设置可执行权限
$ chmod 07555 ./configure

# 配置编译参数
$ ./configure --with-target-bits=64 --with-boot-jdk=/cygdrive/d/jdk-11.0.1 --with-toolchain-version=2017 --enable-debug --with-jvm-variants=server --disable-warnings-as-errors
# 编译镜像
$ make images 

 

 

 

----------------------------- make all 

openjdk-jdk-11-0-1-12-build 目录结构:

$ tree  -L 2
.
├── build.sh
├── launch.vs.json
├── src
│   ├── ADDITIONAL_LICENSE_INFO
│   ├── ASSEMBLY_EXCEPTION
│   ├── LICENSE
│   ├── Makefile
│   ├── README
│   ├── bin
│   ├── build
│   ├── configure
│   ├── doc
│   ├── make
│   ├── src
│   └── test
├── startCygwin.bat
└── third
    ├── cygwin64
    ├── freetype-2.9.1
    └── openjdk-11.0.1_windows-x64_bin

11 directories, 9 files

 

startCygwin.bat

:: 1. 采用C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere获得vcvars64.bat路径
:: 2. 运行vcvars64.bat,以设置VS2017路径
:: 3.运行mintty.exe以启动cygwin
:: 作者:wangjian, 2018-11-28
:: 启动后请cd

@echo off
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\Installer;%PATH%
setlocal enabledelayedexpansion

for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
  set InstallDir=%%i
)

if exist "%InstallDir%\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" (
  set /p Version=<"%InstallDir%\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"

  rem Trim
  set Version=!Version: =!
)

if not "%Version%"=="" (
  rem Example hardcodes x64 as the host and target architecture, but you could parse it from arguments
  set VCvars64="%InstallDir%\VC\Auxiliary\Build\vcvars64.bat"
)
call %VCvars64%

set HOME=%CD%
.\third\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

 

build.sh

#!/usr/bin/env bash

#--------------------------------------------
# 作者:wangjian, 2018-11-28
# 配置并编译 openjdk
#--------------------------------------------

#移动文件后,原软链接不能使用
#重新创建软链接
rm /usr/bin/autoconf
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autoconf

rm /usr/bin/autoheader
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autoheader

rm /usr/bin/autom4te
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autom4te

rm /usr/bin/autoreconf
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autoreconf

rm /usr/bin/autoscan
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autoscan

rm /usr/bin/autoupdate
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/autoupdate

rm /usr/bin/ifnames
ln -s /usr/share/autotools/ac-wrapper.sh /usr/bin/ifnames

rm /usr/bin/python
rm /usr/bin/python2
ln -s /usr/bin/python2.7.exe /usr/bin/python
ln -s /usr/bin/python2.7.exe /usr/bin/python2

rm /dev/fd
ln -s /proc/self/fd /dev/fd

rm /dev/stdin
ln -s /proc/self/fd/0 /dev/stdin

rm /dev/stdout
ln -s /proc/self/fd/1 /dev/stdout

rm /dev/stderr 
ln -s /proc/self/fd/2 /dev/stderr

configurestr='bash configure --with-freetype-include='$(pwd)'/third/freetype-2.9.1/src/include --with-freetype-lib='$(pwd)'/third/freetype-2.9.1/lib --with-boot-jdk='$(pwd)'/third/openjdk-11.0.1_windows-x64_bin --disable-warnings-as-errors --with-toolchain-version=2017 --with-target-bits=64'

cd src
echo $configurestr
${configurestr}
echo "make all"
make all

 

Cmd 执行以下命令,设置 vs2017 编译工具链环境,并启动 cygwin :

Microsoft Windows [版本 10.0.17134.407]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\LSGX>E:

E:\>cd Develop\openjdk-jdk-11-0-1-12-build

E:\Develop\openjdk-jdk-11-0-1-12-build>.\startCygwin.bat
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.6.6
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
E:\Develop\openjdk-jdk-11-0-1-12-build>

 

cygwin 执行以下命令,开始编译 openjdk --- 完整编译大概需要30分钟左右  :

LSGX@DESKTOP-OS0DFSI ~
$ cygcheck -c cygwin
Cygwin Package Information
Package              Version        Status
cygwin               2.11.2-1       OK

LSGX@DESKTOP-OS0DFSI ~
$ pwd
/cygdrive/e/Develop/openjdk-jdk-11-0-1-12-build

LSGX@DESKTOP-OS0DFSI ~
$ bash ./build.sh

 

 

调试 openjdk11

 

环境变量设置:

文档参考地址 https://docs.oracle.com/en/java/javase/11/
JAVA_HOME = "D:\openjdk-11.0.1"
CLASSPATH = ".;%JAVA_HOME%\lib"
Path = "%JAVA_HOME%\bin"

 

命令行工具测试:

javac -encoding utf-8 --source-path .;.\src --class-path .;.\src;D:\openjdk-11.0.1\lib -d .\src -Xlint:deprecation -g .\src\TestDemo.java

jar -cvf .\src\my.jar -C .\src com

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -Dfile.encoding=utf-8 -classpath .;.\src;D:\openjdk-11.0.1\lib com.lsgx.test.TestDemo

jdb -Dfile.encoding=utf-8 -sourcepath .;.\src -classpath .;.\src;D:\openjdk-11.0.1\lib com.lsgx.test.TestDemo

javap -classpath .;.\src;D:\openjdk-11.0.1\lib -c -sysinfo com.lsgx.test.TestDemo

 

java -XX:+PrintFlagsFinal -XX:+PrintCommandLineFlags -verbose:gc -Xlog:gc*=debug -version

 

用vs2017打开源码目录 对着根目录右击 ,选择Debug and Launch settings,选择default.

Test为进行调试的类,请大家自行准备。
找到入口文件,打上断点,便可进行调试了。

 

launch.vs.json

{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "native",
      "name": "openjdkLaunch",
      "project": "build/windows-x86_64-normal-server-release/jdk/bin/java.exe",
      "args": [
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+PrintAssembly",
        "-Dfile.encoding=utf-8",
        "-classpath .\src",
        "TestDemo"
      ]
    },
    {
      "type": "native",
      "name": "openjdkVersion",
      "project": "build/windows-x86_64-normal-server-release/jdk/bin/java.exe",
      "args": [
        "XX:+PrintFlagsFinal",
        "-XX:+PrintCommandLineFlags",
        "-verbose:gc",
        "Xlog:gc*=debug",
        "-version"
      ]
    }
  ]
}

 

=========== End

 

posted @ 2018-12-29 11:40  lsgxeva  阅读(426)  评论(0编辑  收藏  举报