RFR: 8341880: RISC-V: riscv_vector.h native build fails with gcc13 after JDK-8320500 [v2]

SendaoYan syan at openjdk.org
Fri Oct 11 06:48:15 UTC 2024


On Thu, 10 Oct 2024 10:04:32 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> SendaoYan has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - chech gcc and clang verison to determine #include <riscv_vector.h> or not
>>  - chech gcc and clang verison to determine #include <riscv_vector.h> or not
>
> make/modules/jdk.incubator.vector/Lib.gmk line 53:
> 
>> 51:       DISABLED_WARNINGS_gcc := unused-function sign-compare tautological-compare ignored-qualifiers, \
>> 52:       DISABLED_WARNINGS_clang := unused-function sign-compare tautological-compare ignored-qualifiers, \
>> 53:       CFLAGS := -march=rv64gcv, \
> 
> diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4
> index 992a0282c04..4b9efdaff1e 100644
> --- a/make/autoconf/flags-cflags.m4
> +++ b/make/autoconf/flags-cflags.m4
> @@ -912,6 +912,37 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
>          IF_FALSE: [$2FDLIBM_CFLAGS=""])
>    fi
>    AC_SUBST($2FDLIBM_CFLAGS)
> +
> +  # Check that the compiler support -march=rv64gcv and riscv_vector.h
> +  if test "x${OPENJDK_TARGET_CPU}" = "xriscv64"; then
> +    if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
> +      AC_LANG_PUSH(C)
> +      OLD_CFLAGS="$CFLAGS"
> +      CFLAGS="$CFLAGS -march=rv64gcv"
> +      AC_MSG_CHECKING([is rvv intrinsic supported])
> +      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <riscv_vector.h>],
> +          [
> +            const char *src = NULL;
> +            char *dst = NULL;
> +            size_t vl = __riscv_vsetvl_e8m8(16);
> +            vuint8m8_t vec_src = __riscv_vle8_v_u8m8(src, vl);
> +            __riscv_vse8_v_u8m8(dst, vec_src, vl);
> +            return dst[0];
> +          ])],
> +          [
> +            AC_MSG_RESULT([yes])
> +            $2RVV_INTRINSICS_CFLAGS="-march=rv64gcv"
> +          ],
> +          [
> +            AC_MSG_RESULT([no])
> +            $2RVV_INTRINSICS_CFLAGS=""
> +          ]
> +      )
> +      CFLAGS="$OLD_CFLAGS"
> +      AC_LANG_POP(C)
> +    fi
> +  fi
> +  AC_SUBST($2RVV_INTRINSICS_CFLAGS)
>  ])
>  
>  # FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
> diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template
> index 20b1d00aa89..a95f5cb5793 100644
> --- a/make/autoconf/spec.gmk.template
> +++ b/make/autoconf/spec.gmk.template
> @@ -827,6 +827,9 @@ OS_VERSION_MAJOR := @OS_VERSION_MAJOR@
>  OS_VERSION_MINOR := @OS_VERSION_MINOR@
>  OS_VERSION_MICRO := @OS_VERSION_MICRO@
>  
> +# Riscv: RVV intrinsics flags
> +RVV_INTRINSICS_CFLAGS := @RVV_INTRINSICS_CFLAGS@
> +
>  # Images directory definitions
>  JDK_IMAGE_SUBDIR := jdk
>  JRE_IMAGE_SUBDIR := jre
> diff --git a/make/modules/jdk.incubator.vector/Lib.gmk b/make/modules/jdk.incubator.vector/Lib.gmk
> index bf6ace6f97f..b099f41f6f5 100644
> --- a/make/modules/jdk.incubator.vector/Lib.gmk
> +++ b/make/modules/jdk.incubator.vector/Lib.gmk
> @@ -50,7 +50,7 @@ ifeq ($(call isTargetOs, li...

Check the gcc and clang version seems will be enough.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21442#discussion_r1796495838


More information about the build-dev mailing list