ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation

2021-02-11 20:02:30  阅读:646  来源: 互联网

标签:ubuntu20.04 src hx enable -- stringop 源码 OpenJDK12 home


ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation

按照《深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)》的编译openjdk步骤指示,出现了一些问题,导致无法完成编译。

环境

Ubuntu 20.04.2 LTS

其余组件安装命令

sudo apt-get install build-essential

在这里插入图片描述

bootstrap jdk:
sudo apt-get install openjdk-11-jdk

编译前准备

configure命令
bash configure --enable-debug --with-jvm-variants=server
编译命令:
make images

报错信息

=== Output from failing command(s) repeated here ===
* For target hotspot_variant-server_libjvm_objs_arguments.o:
In file included from /usr/include/string.h:495,
                 from /home/hx/OpenJDK12/src/hotspot/share/utilities/globalDefinitions_gcc.hpp:35,
                 from /home/hx/OpenJDK12/src/hotspot/share/utilities/globalDefinitions.hpp:32,
                 from /home/hx/OpenJDK12/src/hotspot/share/utilities/align.hpp:28,
                 from /home/hx/OpenJDK12/src/hotspot/share/runtime/globals.hpp:29,
                 from /home/hx/OpenJDK12/src/hotspot/share/memory/allocation.hpp:28,
                 from /home/hx/OpenJDK12/src/hotspot/share/classfile/classLoaderData.hpp:28,
                 from /home/hx/OpenJDK12/src/hotspot/share/precompiled/precompiled.hpp:34:
In function ‘char* strncpy(char*, const char*, size_t)’,
    inlined from ‘static jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs*, bool*, JVMFlag::Flags)’ at /home/hx/OpenJDK12/src/hotspot/share/runtime/arguments.cpp:2472:29:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:34: error: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
   ... (rest of output omitted)

* All command lines available in /home/hx/OpenJDK12/build/linux-x86_64-server-fastdebug/make-support/failure-logs.
=== End of repeated output ===

error: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ output truncated before terminating nul copying as many bytes from a string as its length
直接百度,根据 https://segmentfault.com/a/1190000022669252的做法

引发错误的原因是这段[-Werror=stringop-truncation],GCC在8.0之后的版本加入了
stringop truncation的验证警告,这里是因为出现了警告导致编译不通过,那就禁止
掉警告再进行编译。

查看GCC版本,

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

果然如此

解决方案

configure命令增加参数–disable-warnings-as-errors,即变更为
bash configure --disable-warnings-as-errors --enable-debug --with-jvm-variants=server
然后进行make images,顺利完成编译。

P.S:按照书中的方法下载的openjdk12的zip格式的源码文件,大小不对且无法解压。
可用下载地址如下:
https://download.java.net/openjdk/jdk12/ri/openjdk-12+32_src.zip

标签:ubuntu20.04,src,hx,enable,--,stringop,源码,OpenJDK12,home
来源: https://blog.csdn.net/huaxia2002/article/details/113791634

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有