JDK-8299580 : RISC-V: fail to build with GCC 12 due to stringop-overflow warning
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: riscv
  • Submitted: 2023-01-04
  • Updated: 2023-10-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
$ /usr/bin/g++-12 -v
Using built-in specs.
COLLECT_GCC=g++-12
COLLECT_LTO_WRAPPER=/usr/lib/gcc/riscv64-linux-gnu/12/lto-wrapper
Target: riscv64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=riscv64-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-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64gc --with-abi=lp64d --enable-checking=release --build=riscv64-linux-gnu --host=riscv64-linux-gnu --target=riscv64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)

OpenJDK linux-riscv64 release build warnings/errors with GCC 12:

In file included from /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:612,
                 from /home/fyang/openjdk-jdk/src/hotspot/share/gc/shared/suspendibleThreadSet.hpp:29,
                 from /home/fyang/openjdk-jdk/src/hotspot/share/gc/z/zPageAllocator.cpp:26:
In member function 'D Atomic::PlatformAdd<byte_size>::add_and_fetch(volatile D*, I, atomic_memory_order) const [with D = long unsigned int; I = long unsigned int; long unsigned int byte_size = 8]',
    inlined from 'static D Atomic::AddImpl<D, I, typename std::enable_if<(((IsIntegral<I>::value && IsIntegral<T>::value) && (sizeof (I) <= sizeof (D))) && (IsSigned<I>::value == IsSigned<T>::value)), void>::type>::add_and_fetch(volatile D*, I, atomic_memory_order) [with D = long unsigned int; I = long unsigned int]' at /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:686:50,
    inlined from 'static D Atomic::add(volatile D*, I, atomic_memory_order) [with D = long unsigned int; I = long unsigned int]' at /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:667:38,
    inlined from 'size_t ZPageAllocator::uncommit(uint64_t*)' at /home/fyang/openjdk-jdk/src/hotspot/share/gc/z/zPageAllocator.cpp:789:16:
/home/fyang/openjdk-jdk/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp:40:31: error: 'long unsigned int __atomic_add_fetch_8(volatile void*, long unsigned int, int)' writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   40 |     D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
      |             ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[3]: *** [lib/CompileJvm.gmk:147: /home/fyang/openjdk-jdk/build/linux-riscv64-server-release/hotspot/variant-server/libjvm/objs/zPageAllocator.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [make/Main.gmk:252: hotspot-server-libs] Error 2

ERROR: Build failed for target 'images' in configuration 'linux-riscv64-server-release' (exit code 2)

=== Output from failing command(s) repeated here ===
* For target hotspot_variant-server_libjvm_objs_zPageAllocator.o:
In file included from /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:612,
                 from /home/fyang/openjdk-jdk/src/hotspot/share/gc/shared/suspendibleThreadSet.hpp:29,
                 from /home/fyang/openjdk-jdk/src/hotspot/share/gc/z/zPageAllocator.cpp:26:
In member function 'D Atomic::PlatformAdd<byte_size>::add_and_fetch(volatile D*, I, atomic_memory_order) const [with D = long unsigned int; I = long unsigned int; long unsigned int byte_size = 8]',
    inlined from 'static D Atomic::AddImpl<D, I, typename std::enable_if<(((IsIntegral<I>::value && IsIntegral<T>::value) && (sizeof (I) <= sizeof (D))) && (IsSigned<I>::value == IsSigned<T>::value)), void>::type>::add_and_fetch(volatile D*, I, atomic_memory_order) [with D = long unsigned int; I = long unsigned int]' at /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:686:50,
    inlined from 'static D Atomic::add(volatile D*, I, atomic_memory_order) [with D = long unsigned int; I = long unsigned int]' at /home/fyang/openjdk-jdk/src/hotspot/share/runtime/atomic.hpp:667:38,
    inlined from 'size_t ZPageAllocator::uncommit(uint64_t*)' at /home/fyang/openjdk-jdk/src/hotspot/share/gc/z/zPageAllocator.cpp:789:16:
/home/fyang/openjdk-jdk/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp:40:31: error: 'long unsigned int __atomic_add_fetch_8(volatile void*, long unsigned int, int)' writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   40 |     D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE);
      |             ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

* All command lines available in /home/fyang/openjdk-jdk/build/linux-riscv64-server-release/make-support/failure-logs.
=== End of repeated output ===

No indication of failed target found.
HELP: Try searching the build log for '] Error'.
HELP: Run 'make doctor' to diagnose build problems.

make[1]: *** [/home/fyang/openjdk-jdk/make/Init.gmk:320: main] Error 2
make: *** [/home/fyang/openjdk-jdk/make/Init.gmk:186: images] Error 2
Comments
Same issue still reproducible with latest jdk mainline (commit: 16c3d53b1bb60b1c1570731041f564bf13b45098)
11-06-2023

Is this still an issue after the sequence JDK-8302262, JDK-8302798, JDK-8302189, JDK-8302799, JDK-8303805? If not, then resolve as not an issue, similarly to JDK-8294031.
10-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11858 Date: 2023-01-05 04:18:50 +0000
06-01-2023