gcc/libgfortran/configure.host
Thomas Schwinge bac2d8a246 nvptx: Build libgfortran with '-mfake-ptx-alloca' [PR107635]
As of recent commit 8bf0ee8d62
"Fortran: Add transfer_between_remotes [PR107635]", we've got 'alloca' usage
in 'libgfortran/caf/single.c:_gfortran_caf_transfer_between_remotes', and
the libgfortran target library fails to build for legacy configurations where
PTX 'alloca' is not available:

    ../../../../source-gcc/libgfortran/caf/single.c: In function ‘_gfortran_caf_transfer_between_remotes’:
    ../../../../source-gcc/libgfortran/caf/single.c:675:23: sorry, unimplemented: dynamic stack allocation not supported
      675 |       transfer_desc = __builtin_alloca (desc_size);
          |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../../source-gcc/libgfortran/caf/single.c:680:20: sorry, unimplemented: dynamic stack allocation not supported
      680 |     transfer_ptr = __builtin_alloca (*opt_dst_charlen * src_size);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    make[6]: *** [Makefile:4675: caf/single.lo] Error 1

With '-mfake-ptx-alloca', libgfortran again succeeds to build, and compared
to before, we've got only a small number of regressions due to nvptx 'ld'
complaining about 'unresolved symbol __GCC_nvptx__PTX_alloca_not_supported':

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single (test for excess errors)
    [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to produce executable+}

    [-PASS:-]{+FAIL:+} gfortran.dg/coarray_43.f90   -O  (test for excess errors)

That's acceptable for such legacy PTX configurations.

	PR target/107635
	libgfortran/
	* config/t-nvptx: New.
	* configure.host [nvptx] (tmake_file): Add it.
2025-02-27 21:48:15 +01:00

102 lines
2 KiB
Text

# configure.host
#
# This shell script handles all host based configuration for libgfortran.
# It sets various shell variables based on the host triplet.
# You can modify this shell script without rerunning autoconf/aclocal/etc.
# This file is "sourced", not executed.
#
#
# It uses the following shell variables as set by config.guess:
# host The configuration host (full CPU-vendor-OS triplet)
# host_cpu The configuration host CPU
# host_os The configuration host OS
#
#
# It sets the following shell variables:
#
# fpu_host FPU-specific code file, defaults to fpu-generic.
# tmake_file A list of machine-description-specific
# makefile fragments.
# DEFAULTS
fpu_host='fpu-generic'
ieee_support='no'
if test "x${have_fp_enable}" = "xyes" && test "x${have_fp_trap}" = "xyes"; then
fpu_host='fpu-aix'
ieee_support='yes'
fi
if test "x${have_fpsetmask}" = "xyes"; then
fpu_host='fpu-sysv'
ieee_support='yes'
fi
if test "x${have_feenableexcept}" = "xyes"; then
fpu_host='fpu-glibc'
ieee_support='yes'
fi
case "${host_cpu}" in
# x86 asm should be used instead of glibc, since glibc doesn't support
# the x86 denormal exception.
i?86 | x86_64)
if test "x${have_soft_float}" = "xyes"; then
fpu_host='fpu-generic'
ieee_support='no'
else
fpu_host='fpu-387'
ieee_support='yes'
fi
;;
# use asm on aarch64-darwin
aarch64)
case "${host_os}" in
darwin*)
fpu_host='fpu-aarch64'
ieee_support='yes'
;;
esac
;;
powerpc*)
case "${host_os}" in
darwin*)
fpu_host='fpu-macppc'
ieee_support='yes'
;;
esac
esac
# Some targets require additional compiler options for NaN/Inf.
ieee_flags=
case "${host_cpu}" in
alpha*)
ieee_flags="-mieee" ;;
sh*)
ieee_flags="-mieee" ;;
esac
tmake_file=
# Other system configury
case "${target}" in
*-*-aix*)
# Create AIX-style "FAT" libraries.
tmake_file="t-aix"
;;
nvptx-*-none)
tmake_file="$tmake_file t-nvptx"
;;
*)
;;
esac