dragonwell-project / dragonwell11

Alibaba Dragonwell11 JDK
https://www.aliyun.com/product/dragonwell
GNU General Public License v2.0
552 stars 111 forks source link

[riscv64]gcc13编译报错java_md_common.c:124:43: error: '%s' directive output may be truncated writing up to 4095 bytes into a region of size between 2 and 4097 [-Werror=format-truncation=] #822

Closed sendaoYan closed 2 months ago

sendaoYan commented 2 months ago

Description A clear and concise description of what the bug is.

Steps to Reproduce Steps to reproduce the behavior:

/usr/bin/gcc -MMD -MF /home/yansendao/git/dragonwell11/build/linux-riscv64-normal-server-release/support/native/java.base/libjli/java_md_common.d.tmp -fpch-preprocess -I/home/yansendao/git/dragonwell11/build/linux-riscv64-normal-server-release/support/modules_include/java.base -I/home/yansendao/git/dragonwell11/build/linux-riscv64-normal-server-release/support/modules_include/java.base/linux -I/home/yansendao/git/dragonwell11/src/java.base/share/native/libjava -I/home/yansendao/git/dragonwell11/src/java.base/unix/native/libjava -I/home/yansendao/git/dragonwell11/src/hotspot/share/include -I/home/yansendao/git/dragonwell11/src/hotspot/os/posix/include -pipe -fstack-protector -DLIBC=gnu -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DLINUX -DNDEBUG -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-stringop-overflow -Wno-stringop-truncation -Wformat=2 -fmacro-prefix-map=/home/yansendao/git/dragonwell11/= -fno-strict-aliasing -D_LITTLE_ENDIAN -DARCH='"riscv64"' -Driscv64 -D_LP64=1 -fno-omit-frame-pointer -fno-delete-null-pointer-checks -fno-lifetime-dse -fPIC -fvisibility=hidden -DUSE_GENERIC_ERGO -I/home/yansendao/git/dragonwell11/src/java.base/unix/native/libjli -I/home/yansendao/git/dragonwell11/src/java.base/share/native/libjli -I/home/yansendao/git/dragonwell11/build/linux-riscv64-normal-server-release/support/headers/java.base -g -Wno-unused-function -Wno-implicit-fallthrough -Werror -O3 -c -o /home/yansendao/git/dragonwell11/build/linux-riscv64-normal-server-release/support/native/java.base/libjli/java_md_common.o /home/yansendao/git/dragonwell11/src/java.base/unix/native/libjli/java_md_common.c

Expected behavior riscv-port-jdk11u的编译命令:

/usr/bin/ccache /usr/bin/gcc -MMD -MF /home/yansendao/git/riscv-port-jdk11u/build/linux-riscv64-normal-server-release/support/native/java.base/libjli/java_md_common.d.tmp -fpch-preprocess -I/home/yansendao/git/riscv-port-jdk11u/build/linux-riscv64-normal-server-release/support/modules_include/java.base -I/home/yansendao/git/riscv-port-jdk11u/build/linux-riscv64-normal-server-release/support/modules_include/java.base/linux -I/home/yansendao/git/riscv-port-jdk11u/src/java.base/share/native/libjava -I/home/yansendao/git/riscv-port-jdk11u/src/java.base/unix/native/libjava -I/home/yansendao/git/riscv-port-jdk11u/src/hotspot/share/include -I/home/yansendao/git/riscv-port-jdk11u/src/hotspot/os/posix/include -pipe -fstack-protector -DLIBC=gnu -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DLINUX -DNDEBUG -fmacro-prefix-map=/home/yansendao/git/riscv-port-jdk11u/= -fno-strict-aliasing -D_LITTLE_ENDIAN '-DARCH="riscv64"' -Driscv64 -D_LP64=1 -fno-omit-frame-pointer -fno-delete-null-pointer-checks -fno-lifetime-dse -fPIC -fvisibility=hidden -DUSE_GENERIC_ERGO -I/home/yansendao/git/riscv-port-jdk11u/src/java.base/unix/native/libjli -I/home/yansendao/git/riscv-port-jdk11u/src/java.base/share/native/libjli -I/home/yansendao/git/riscv-port-jdk11u/build/linux-riscv64-normal-server-release/support/headers/java.base -g -Wno-unused-function -Wno-implicit-fallthrough -Werror -O3 -c -o /home/yansendao/git/riscv-port-jdk11u/build/linux-riscv64-normal-server-release/support/native/java.base/libjli/java_md_common.o /home/yansendao/git/riscv-port-jdk11u/src/java.base/unix/native/libjli/java_md_common.c

少了如下几个编译选项: -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-stringop-overflow -Wno-stringop-truncation -Wformat=2

Execution environment

$ uname -a ; cat /etc/os-release ; free -h ; lscpu | head -n 25 ; java -version ; java -Xinternalversion ; gcc -v
Linux fedora-riscv 6.1.31 #1 SMP Thu Jun 15 01:30:00 CST 2023 riscv64 GNU/Linux
NAME="Fedora Linux"
VERSION="38 (Workstation Edition)"
ID=fedora
VERSION_ID=38
VERSION_CODENAME=""
PLATFORM_ID="platform:f38"
PRETTY_NAME="Fedora Linux 38 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:38"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f38/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=38
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=38
SUPPORT_END=2024-05-14
VARIANT="Workstation Edition"
VARIANT_ID=workstation
               total        used        free      shared  buff/cache   available
Mem:           125Gi       1.4Gi        99Gi        15Mi        25Gi       123Gi
Swap:          8.0Gi          0B       8.0Gi
Architecture:        riscv64
Byte Order:          Little Endian
CPU(s):              64
On-line CPU(s) list: 0-63
NUMA node(s):        4
NUMA node0 CPU(s):   0-7,16-23
NUMA node1 CPU(s):   8-15,24-31
NUMA node2 CPU(s):   32-39,48-55
NUMA node3 CPU(s):   40-47,56-63
openjdk version "11.0.23.19" 2024-04-16
OpenJDK Runtime Environment (Alibaba Dragonwell Extended Edition)-11.0.22.19+7-ga (build 11.0.23.19+7)
OpenJDK 64-Bit Server VM (Alibaba Dragonwell Extended Edition)-11.0.22.19+7-ga (build 11.0.23.19+7, mixed mode)
OpenJDK 64-Bit Server VM (11.0.23.19+7) for linux-riscv64 JRE (11.0.23.19+7), built on Apr 26 2024 03:22:06 by "" with gcc 9.2.0
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-redhat-linux/13/lto-wrapper
Target: riscv64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20230728/obj-riscv64-redhat-linux/isl-install --enable-gnu-indirect-function --with-arch=rv64gc --with-abi=lp64d --with-multilib-list=lp64d --build=riscv64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20230728 (Red Hat 13.2.1-1) (GCC) 

make-linux-riscv64-gcc13.log make-riscv-port-jdk11u.log

sendaoYan commented 2 months ago

有2个PR应该都可以解决这个问题 https://github.com/openjdk/jdk/pull/8646 https://github.com/openjdk/jdk11u-dev/pull/2606

sendaoYan commented 2 months ago

https://github.com/openjdk/jdk11u-dev/pull/2606 对应的patch无法干净地backport到dragonwell11,需要手动backport。手动backport之后可以正常编译

JDK-8210988-dragonwell11.patch