https://gcc.gnu.org/g:bac2d8a246892334e24dfa7d62be0cd0648c5606

commit r15-7736-gbac2d8a246892334e24dfa7d62be0cd0648c5606
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Tue Feb 25 22:31:25 2025 +0100

    nvptx: Build libgfortran with '-mfake-ptx-alloca' [PR107635]
    
    As of recent commit 8bf0ee8d62b8a08e808344d31354ab713157e15d
    "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.

Diff:
---
 libgfortran/config/t-nvptx | 2 ++
 libgfortran/configure.host | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/libgfortran/config/t-nvptx b/libgfortran/config/t-nvptx
new file mode 100644
index 000000000000..88bd6eee9826
--- /dev/null
+++ b/libgfortran/config/t-nvptx
@@ -0,0 +1,2 @@
+# Re 'alloca' usage in '../caf/single.c':
+AM_CFLAGS += -mfake-ptx-alloca
diff --git a/libgfortran/configure.host b/libgfortran/configure.host
index 291188d19c29..9abd40f511ae 100644
--- a/libgfortran/configure.host
+++ b/libgfortran/configure.host
@@ -91,6 +91,10 @@ case "${target}" in
        tmake_file="t-aix"
        ;;
 
+  nvptx-*-none)
+       tmake_file="$tmake_file t-nvptx"
+       ;;
+
   *)
        ;;

Reply via email to