美文网首页
编译可调试的 OpenJDK8

编译可调试的 OpenJDK8

作者: 萧哈哈 | 来源:发表于2020-09-06 18:00 被阅读0次

    以 Manjaro 20.1 为例

    系统环境

    ➜  ~ uname -r
    5.4.57-1-MANJARO
    
    ➜  ~ make -version
    GNU Make 4.3
    
    ➜  ~ gcc -v
    ...
    gcc version 10.2.0 (GCC) 
    
    ➜  ~ g++ -v
    ...
    gcc version 10.2.0 (GCC) 
    

    安装必要的编译、调试软件

    • CLion C and C++ IDE
    • compiledb Tool for generating Clang's JSON Compilation Database file for GNU make-based build systems
    • Building the JDK 编译需要的安装包参考
    • mercurial sudo pacman -S mercurial
    • OracleJDK7 作为编译OpenJDK8 的 bootSDK

    获取源码

    需要挂梯子

    # 根据自己的实际情况配置
    export ALL_PROXY=socks5://127.0.0.1:1080
    # 这里最好用jdk8u, 不容易出问题
    hg clone http://hg.openjdk.java.net/jdk8u/jdk8u/
    
    # 进入目录
    cd jdk8u
    # 执行脚本,拉取所有代码
    bash ./get_source.sh
    

    配置源码

    # 移除环境变量配置
    unset JAVA_HOME
    # 生成debug版本的 openjdk8
    bash ./configure --enable-debug --enable-debug-symbols --disable-zip-debug-info --with-boot-jdk=/home/zero/Documents/Java/jdk1.7.0_80
    

    编译源码

    # 源码里将所有的warn处理为error。 这里必须配置WARNINGS_ARE_ERRORS=""
    # compiledb 是为了生成 compile_commands.json
    compiledb make WARNINGS_ARE_ERRORS="" images 
    

    CLion 导入项目

    File -> Open 选择 compile_commands.json -> 选择 open as project

    CLion 运行、调试设置

    详见 custom-build-targets

    GDB 配置

    vim ~/.gdbinit

    handle SIGSEGV nostop noprint pass
    handle SIGBUS nostop noprint pass
    handle SIGFPE nostop noprint pass
    handle SIGPIPE nostop noprint pass
    handle SIGILL nostop noprint pass
    

    参考资料

    相关文章

      网友评论

          本文标题:编译可调试的 OpenJDK8

          本文链接:https://www.haomeiwen.com/subject/lrnqektx.html