ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3994字,纯文字阅读大概需要6分钟。
内容图文
![ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation](/upload/InfoBanner/zyjiaocheng/929/02df8fc66e344b1c806ffa514d042bcf.jpg)
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.2环境下openjdk12源码编译相关问题Werror=stringop-truncation全部内容,希望文章能够帮你解决ubuntu20.04.2环境下openjdk12源码编译相关问题Werror=stringop-truncation所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。