diff mbox

RFC: Building a minimal libgfortran for nvptx

Message ID 5458E403.4010408@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt Nov. 4, 2014, 2:34 p.m. UTC
The ptx port by its nature is lacking features that are expected on 
"normal" machines, such as alloca and indirect jumps. We have a subset 
of the C library which contains functions that can be implemented on the 
target (excluding things like file I/O other than printf which is a ptx 
builtin).

It would be good to be able to also build as much of libgfortran as 
possible, and the following patch is what I've been using so far. It 
recognizes the target at configure time and restricts the list of 
compiled files, as well as providing a LIBGFOR_MINIMAL define for #ifdef 
tests. There's also a new file minimal.c which contains alternative 
implementations of some functionality (using printf to write error 
messages rather than fprintf and such). Constructors are currently 
unimplemented on ptx and therefore the init function is commented out.

Comments on the approach, do the Fortran maintainers have a preference 
how this should look? The whole thing is good enough to substantially 
reduce the number of failures when trying to run the Fortran testsuites 
on nvptx (although many remain).


Bernd

Comments

Steve Kargl Nov. 4, 2014, 3:41 p.m. UTC | #1
On Tue, Nov 04, 2014 at 03:34:43PM +0100, Bernd Schmidt wrote:
> The ptx port by its nature is lacking features that are expected on 
> "normal" machines, such as alloca and indirect jumps. We have a subset 
> of the C library which contains functions that can be implemented on the 
> target (excluding things like file I/O other than printf which is a ptx 
> builtin).
> 
> It would be good to be able to also build as much of libgfortran as 
> possible, and the following patch is what I've been using so far. It 
> recognizes the target at configure time and restricts the list of 
> compiled files, as well as providing a LIBGFOR_MINIMAL define for #ifdef 
> tests. There's also a new file minimal.c which contains alternative 
> implementations of some functionality (using printf to write error 
> messages rather than fprintf and such). Constructors are currently 
> unimplemented on ptx and therefore the init function is commented out.
> 
> Comments on the approach, do the Fortran maintainers have a preference 
> how this should look? The whole thing is good enough to substantially 
> reduce the number of failures when trying to run the Fortran testsuites 
> on nvptx (although many remain).
> 

It is unclear to me from reading the diff whether this patch 
cause gfortran on ptx to knowingly violate the fortran standard.
If the answer is "yes, this patch causes gfortran on ptx to
violate the standard", then the patch is IMHO unacceptable.
Bernd Schmidt Nov. 4, 2014, 3:54 p.m. UTC | #2
On 11/04/2014 04:41 PM, Steve Kargl wrote:
> It is unclear to me from reading the diff whether this patch
> cause gfortran on ptx to knowingly violate the fortran standard.
> If the answer is "yes, this patch causes gfortran on ptx to
> violate the standard", then the patch is IMHO unacceptable.

I don't have the Fortran standard, but I assume that missing pieces in 
the library would be a violation. However, the alternative is no Fortran 
(library) support at all, which doesn't seem like an improvement. The 
target simply does not allow full language support, even for something 
like C.

Note that the intention is not to support Fortran (or any other 
language) directly targetting ptx code. The only way it's supposed to be 
used is as an accelerator for OpenACC offloading.


Bernd
FX Coudert Nov. 4, 2014, 3:59 p.m. UTC | #3
> Comments on the approach, do the Fortran maintainers have a preference how this should look? The whole thing is good enough to substantially reduce the number of failures when trying to run the Fortran testsuites on nvptx (although many remain).

I’m afraid I don’t really see the point. Maybe I’ll say it differently that Steve has: what would be the state of Fortran on such platform, and would it have users? It looks that, at the very least, your target wouldn’t be able to do any I/O.

Unless we have a good reason to think there will be users, because the state of support will be good, I don’t see that we should add to the library maintainance burden by special-casing targets.

Also: if other targets come along that have this need, how does your strategy scale up?

Thanks,
FX
Bernd Schmidt Nov. 4, 2014, 4:06 p.m. UTC | #4
On 11/04/2014 04:59 PM, FX wrote:
>> Comments on the approach, do the Fortran maintainers have a
>> preference how this should look? The whole thing is good enough to
>> substantially reduce the number of failures when trying to run the
>> Fortran testsuites on nvptx (although many remain).
>
> I’m afraid I don’t really see the point. Maybe I’ll say it
> differently that Steve has: what would be the state of Fortran on
> such platform, and would it have users? It looks that, at the very
> least, your target wouldn’t be able to do any I/O.

It would be used through OpenACC - and that I do believe that does have 
Fortran users, with other compilers. We can make Fortran OpenACC work 
for simple testcases without any runtime library, but IMO it would be 
better to go as far as possible in supporting whatever can be made to 
work. I/O is the major piece that is missing, but you'd expect that to 
be done on the host rather than on the accelerator.


Bernd
Jakub Jelinek Nov. 4, 2014, 4:11 p.m. UTC | #5
On Tue, Nov 04, 2014 at 07:41:42AM -0800, Steve Kargl wrote:
> On Tue, Nov 04, 2014 at 03:34:43PM +0100, Bernd Schmidt wrote:
> > The ptx port by its nature is lacking features that are expected on 
> > "normal" machines, such as alloca and indirect jumps. We have a subset 
> > of the C library which contains functions that can be implemented on the 
> > target (excluding things like file I/O other than printf which is a ptx 
> > builtin).
> > 
> > It would be good to be able to also build as much of libgfortran as 
> > possible, and the following patch is what I've been using so far. It 
> > recognizes the target at configure time and restricts the list of 
> > compiled files, as well as providing a LIBGFOR_MINIMAL define for #ifdef 
> > tests. There's also a new file minimal.c which contains alternative 
> > implementations of some functionality (using printf to write error 
> > messages rather than fprintf and such). Constructors are currently 
> > unimplemented on ptx and therefore the init function is commented out.
> > 
> > Comments on the approach, do the Fortran maintainers have a preference 
> > how this should look? The whole thing is good enough to substantially 
> > reduce the number of failures when trying to run the Fortran testsuites 
> > on nvptx (although many remain).
> > 
> 
> It is unclear to me from reading the diff whether this patch 
> cause gfortran on ptx to knowingly violate the fortran standard.
> If the answer is "yes, this patch causes gfortran on ptx to
> violate the standard", then the patch is IMHO unacceptable.

The point is, if the target can implement just a subset of the Fortran (or
C or C++) standards, then ideally if you use anything that is not supported
would just cause always host fallback, the code will still work, but will
not be offloaded.  So even supporting a subset of the standard is
worthwhile, usually one will just offload the most performance critical
parts of his code.

	Jakub
FX Coudert Nov. 4, 2014, 4:15 p.m. UTC | #6
> The point is, if the target can implement just a subset of the Fortran (or
> C or C++) standards, then ideally if you use anything that is not supported
> would just cause always host fallback, the code will still work, but will
> not be offloaded.  So even supporting a subset of the standard is
> worthwhile, usually one will just offload the most performance critical
> parts of his code.

Do we have the architecture for that in place in GCC in general, and in the Fortran front-end in particular? I’d be interested to see how it works…

FX
Jakub Jelinek Nov. 4, 2014, 4:19 p.m. UTC | #7
On Tue, Nov 04, 2014 at 05:15:52PM +0100, FX wrote:
> > The point is, if the target can implement just a subset of the Fortran (or
> > C or C++) standards, then ideally if you use anything that is not supported
> > would just cause always host fallback, the code will still work, but will
> > not be offloaded.  So even supporting a subset of the standard is
> > worthwhile, usually one will just offload the most performance critical
> > parts of his code.
> 
> Do we have the architecture for that in place in GCC in general, and in
> the Fortran front-end in particular?  I’d be interested to see how it
> works…

See https://gcc.gnu.org/wiki/Offloading and kyukhin/gomp4-offload and
branches/gomp-4_0-branch branches.  Both are in the process of being merged
into trunk these days.

	Jakub
Steve Kargl Nov. 4, 2014, 5:08 p.m. UTC | #8
On Tue, Nov 04, 2014 at 04:54:54PM +0100, Bernd Schmidt wrote:
> On 11/04/2014 04:41 PM, Steve Kargl wrote:
> > It is unclear to me from reading the diff whether this patch
> > cause gfortran on ptx to knowingly violate the fortran standard.
> > If the answer is "yes, this patch causes gfortran on ptx to
> > violate the standard", then the patch is IMHO unacceptable.
> 
> I don't have the Fortran standard, but I assume that missing pieces in 
> the library would be a violation. However, the alternative is no Fortran 
> (library) support at all, which doesn't seem like an improvement. The 
> target simply does not allow full language support, even for something 
> like C.
> 
> Note that the intention is not to support Fortran (or any other 
> language) directly targetting ptx code. The only way it's supposed to be 
> used is as an accelerator for OpenACC offloading.
> 

I see.  I get nervous when a patch appears that throws away
a part of the runtime library.  There are typically unintended
consequences, which then becomes a support issue.
FX Coudert Nov. 4, 2014, 5:11 p.m. UTC | #9
> See https://gcc.gnu.org/wiki/Offloading and kyukhin/gomp4-offload and
> branches/gomp-4_0-branch branches.  Both are in the process of being merged
> into trunk these days.

Thanks for the link, I’ll look into it.
I suppose then it makes sense to provide partial libgfortran support, assuming someone is volunteering to make offloading work nicely for Fortran code and maintain it.

FX
Jeff Law Nov. 4, 2014, 5:20 p.m. UTC | #10
On 11/04/14 09:11, Jakub Jelinek wrote:
> On Tue, Nov 04, 2014 at 07:41:42AM -0800, Steve Kargl wrote:
>> On Tue, Nov 04, 2014 at 03:34:43PM +0100, Bernd Schmidt wrote:
>>> The ptx port by its nature is lacking features that are expected on
>>> "normal" machines, such as alloca and indirect jumps. We have a subset
>>> of the C library which contains functions that can be implemented on the
>>> target (excluding things like file I/O other than printf which is a ptx
>>> builtin).
>>>
>>> It would be good to be able to also build as much of libgfortran as
>>> possible, and the following patch is what I've been using so far. It
>>> recognizes the target at configure time and restricts the list of
>>> compiled files, as well as providing a LIBGFOR_MINIMAL define for #ifdef
>>> tests. There's also a new file minimal.c which contains alternative
>>> implementations of some functionality (using printf to write error
>>> messages rather than fprintf and such). Constructors are currently
>>> unimplemented on ptx and therefore the init function is commented out.
>>>
>>> Comments on the approach, do the Fortran maintainers have a preference
>>> how this should look? The whole thing is good enough to substantially
>>> reduce the number of failures when trying to run the Fortran testsuites
>>> on nvptx (although many remain).
>>>
>>
>> It is unclear to me from reading the diff whether this patch
>> cause gfortran on ptx to knowingly violate the fortran standard.
>> If the answer is "yes, this patch causes gfortran on ptx to
>> violate the standard", then the patch is IMHO unacceptable.
>
> The point is, if the target can implement just a subset of the Fortran (or
> C or C++) standards, then ideally if you use anything that is not supported
> would just cause always host fallback, the code will still work, but will
> not be offloaded.  So even supporting a subset of the standard is
> worthwhile, usually one will just offload the most performance critical
> parts of his code.
Also note there's a reasonable chance that the GPUs will continue to 
evolve and will be able to support more of the standard language 
features.  Not sure if they'll ever do the IO side of Fortran, but they 
could always surprise us.

jeff
Steve Kargl Nov. 4, 2014, 5:38 p.m. UTC | #11
On Tue, Nov 04, 2014 at 10:20:53AM -0700, Jeff Law wrote:
> On 11/04/14 09:11, Jakub Jelinek wrote:
> > On Tue, Nov 04, 2014 at 07:41:42AM -0800, Steve Kargl wrote:
> >> On Tue, Nov 04, 2014 at 03:34:43PM +0100, Bernd Schmidt wrote:
> >>> The ptx port by its nature is lacking features that are expected on
> >>> "normal" machines, such as alloca and indirect jumps. We have a subset
> >>> of the C library which contains functions that can be implemented on the
> >>> target (excluding things like file I/O other than printf which is a ptx
> >>> builtin).
> >>>
> >>> It would be good to be able to also build as much of libgfortran as
> >>> possible, and the following patch is what I've been using so far. It
> >>> recognizes the target at configure time and restricts the list of
> >>> compiled files, as well as providing a LIBGFOR_MINIMAL define for #ifdef
> >>> tests. There's also a new file minimal.c which contains alternative
> >>> implementations of some functionality (using printf to write error
> >>> messages rather than fprintf and such). Constructors are currently
> >>> unimplemented on ptx and therefore the init function is commented out.
> >>>
> >>> Comments on the approach, do the Fortran maintainers have a preference
> >>> how this should look? The whole thing is good enough to substantially
> >>> reduce the number of failures when trying to run the Fortran testsuites
> >>> on nvptx (although many remain).
> >>>
> >>
> >> It is unclear to me from reading the diff whether this patch
> >> cause gfortran on ptx to knowingly violate the fortran standard.
> >> If the answer is "yes, this patch causes gfortran on ptx to
> >> violate the standard", then the patch is IMHO unacceptable.
> >
> > The point is, if the target can implement just a subset of the Fortran (or
> > C or C++) standards, then ideally if you use anything that is not supported
> > would just cause always host fallback, the code will still work, but will
> > not be offloaded.  So even supporting a subset of the standard is
> > worthwhile, usually one will just offload the most performance critical
> > parts of his code.
> Also note there's a reasonable chance that the GPUs will continue to 
> evolve and will be able to support more of the standard language 
> features.  Not sure if they'll ever do the IO side of Fortran, but they 
> could always surprise us.
> 

Thanks for the explanation.  Certainly mapping Fortran's array syntax
and many of the intrinsic subprograms to an accelerator may provide a
nice speed improvement.  It wasn't clear to me from Bernd original message
that the patch was intended for OpenACC offloading.  I was assuming
that ptx was a new cpu architecture, which had limited capabilites.
Jeff Law Nov. 4, 2014, 6:19 p.m. UTC | #12
On 11/04/14 08:54, Bernd Schmidt wrote:
> Note that the intention is not to support Fortran (or any other
> language) directly targetting ptx code. The only way it's supposed to be
> used is as an accelerator for OpenACC offloading.
Right.  To reiterate for everyone, offloading is the goal of the nvptx 
port.  Normal C, C++, Fortran code really isn't interesting, though the 
direction the hardware is going should allow more and more C, C++ & 
Fortran code to be used as-is on the GPU.

Bernd has done a fair amount of work to allow normal-ish C, C++ & 
Fortran code to run, that's really been to allow running GCC's testsuite 
to shake out the first level bugs in the ptx support.

Jeff
N.M. Maclaren Nov. 4, 2014, 6:44 p.m. UTC | #13
On Nov 4 2014, Jeff Law wrote:
>On 11/04/14 09:11, Jakub Jelinek wrote:
>>
>> The point is, if the target can implement just a subset of the Fortran 
>> (or C or C++) standards, then ideally if you use anything that is not 
>> supported would just cause always host fallback, the code will still 
>> work, but will not be offloaded. So even supporting a subset of the 
>> standard is worthwhile, usually one will just offload the most 
>> performance critical parts of his code.

As I see it, this isn't a free-standing compilation environment, but a
component of one for heterogeneous architectures.  There are similar
issues for some embedded systems, in several languages.  That doesn't
fit well with the current build model, unfortunately :-(

>Also note there's a reasonable chance that the GPUs will continue to 
>evolve and will be able to support more of the standard language 
>features.  Not sure if they'll ever do the IO side of Fortran, but they 
>could always surprise us.

I am almost certain that the current situation is going to change
significantly, probably by 2020, but there is as yet no indication of
how.  And it wouldn't be entirely reasonable to say nothing should be
done for this sort of use until the situation becomes clear.


Regards,
Nick Maclaren.
Tobias Burnus Nov. 13, 2014, 10:04 p.m. UTC | #14
Hi all,

since everyone seems to agree that it makes in principle sense to have a 
reduce libgfortran (even though a full one is nicer, if the system 
permits), let's look at the patch itself ;-)

Bernd Schmidt wrote:
> The ptx port by its nature is lacking features that are expected on 
> "normal" machines, such as alloca and indirect jumps. We have a subset 
> of the C library which contains functions that can be implemented on 
> the target (excluding things like file I/O other than printf which is 
> a ptx builtin).
>
> It would be good to be able to also build as much of libgfortran as 
> possible, and the following patch is what I've been using so far. It 
> recognizes the target at configure time and restricts the list of 
> compiled files, as well as providing a LIBGFOR_MINIMAL define for 
> #ifdef tests. There's also a new file minimal.c which contains 
> alternative implementations of some functionality (using printf to 
> write error messages rather than fprintf and such). Constructors are 
> currently unimplemented on ptx and therefore the init function is 
> commented out.

Does printf work? I thought I/O is not supported? Or does it just accept 
it for linking and drop it? I think Janne's patch has already dealt with 
the issue of stack allocation.

What I dislike a bit about the feature is that it is not clear what 
features will be supported for LIBGFOR_MINIMAL. Maybe configure.ac would 
be a good place to describe which features are included there (e.g. no 
I/O but "printf" etc.) and which aren't. That will make it easier to see 
what has to be modifed if one will add another differently bare system 
later on.

+#if 0
+/* Initialize the runtime library.  */

#if 0'ed code shouldn't be in the patch.


+@LIBGFOR_MINIMAL_FALSE@gfor_helper_src = intrinsics/associated.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/abort.c intrinsics/access.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/args.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/bit_intrinsics.c \
...
+@LIBGFOR_MINIMAL_TRUE@gfor_helper_src = intrinsics/associated.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/abort.c intrinsics/args.c \
...

Can't one write this differently, avoiding having most lines repeated 
and only a few missing from the second set? I am not an automake expert, 
but can't one simply split this into different make variables - one set 
which is in both and one which is not in minimal?

Otherwise, the RFC looks good to me.

Tobias

Tobias
diff mbox

Patch

Index: libgfortran/Makefile.am
===================================================================
--- libgfortran/Makefile.am.orig
+++ libgfortran/Makefile.am
@@ -77,6 +77,14 @@  AM_CFLAGS += $(SECTION_FLAGS)
 AM_CFLAGS += $(IEEE_FLAGS)
 AM_FCFLAGS += $(IEEE_FLAGS)
 
+if LIBGFOR_MINIMAL
+AM_CFLAGS += -DLIBGFOR_MINIMAL
+endif
+
+if LIBGFOR_MINIMAL
+gfor_io_src= \
+io/size_from_kind.c
+else
 gfor_io_src= \
 io/close.c \
 io/file_pos.c \
@@ -94,6 +102,7 @@  io/unit.c \
 io/unix.c \
 io/write.c \
 io/fbuf.c
+endif
 
 gfor_io_headers= \
 io/io.h \
@@ -101,6 +110,41 @@  io/fbuf.h \
 io/format.h \
 io/unix.h
 
+if LIBGFOR_MINIMAL
+gfor_helper_src= \
+intrinsics/associated.c \
+intrinsics/abort.c \
+intrinsics/args.c \
+intrinsics/bit_intrinsics.c \
+intrinsics/cshift0.c \
+intrinsics/eoshift0.c \
+intrinsics/eoshift2.c \
+intrinsics/erfc_scaled.c \
+intrinsics/extends_type_of.c \
+intrinsics/fnum.c \
+intrinsics/ierrno.c \
+intrinsics/ishftc.c \
+intrinsics/iso_c_generated_procs.c \
+intrinsics/iso_c_binding.c \
+intrinsics/malloc.c \
+intrinsics/mvbits.c \
+intrinsics/move_alloc.c \
+intrinsics/pack_generic.c \
+intrinsics/selected_char_kind.c \
+intrinsics/size.c \
+intrinsics/spread_generic.c \
+intrinsics/string_intrinsics.c \
+intrinsics/rand.c \
+intrinsics/random.c \
+intrinsics/reshape_generic.c \
+intrinsics/reshape_packed.c \
+intrinsics/selected_int_kind.f90 \
+intrinsics/selected_real_kind.f90 \
+intrinsics/transpose_generic.c \
+intrinsics/unpack_generic.c \
+runtime/in_pack_generic.c \
+runtime/in_unpack_generic.c
+else
 gfor_helper_src= \
 intrinsics/associated.c \
 intrinsics/abort.c \
@@ -165,6 +209,7 @@  intrinsics/unlink.c \
 intrinsics/unpack_generic.c \
 runtime/in_pack_generic.c \
 runtime/in_unpack_generic.c
+endif
 
 if IEEE_SUPPORT
 
@@ -181,6 +226,15 @@  gfor_ieee_src=
 
 endif
 
+if LIBGFOR_MINIMAL
+gfor_src= \
+runtime/bounds.c \
+runtime/compile_options.c \
+runtime/memory.c \
+runtime/minimal.c \
+runtime/string.c \
+runtime/select.c
+else
 gfor_src= \
 runtime/backtrace.c \
 runtime/bounds.c \
@@ -195,6 +249,7 @@  runtime/pause.c \
 runtime/stop.c \
 runtime/string.c \
 runtime/select.c
+endif
 
 i_all_c= \
 $(srcdir)/generated/all_l1.c \
Index: libgfortran/Makefile.in
===================================================================
--- libgfortran/Makefile.in.orig
+++ libgfortran/Makefile.in
@@ -54,10 +54,11 @@  POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@IEEE_SUPPORT_TRUE@am__append_1 = ieee/ieee_helper.c
+@LIBGFOR_MINIMAL_TRUE@am__append_1 = -DLIBGFOR_MINIMAL
+@IEEE_SUPPORT_TRUE@am__append_2 = ieee/ieee_helper.c
 
 # dummy sources for libtool
-@onestep_TRUE@am__append_2 = libgfortran_c.c libgfortran_f.f90
+@onestep_TRUE@am__append_3 = libgfortran_c.c libgfortran_f.f90
 subdir = .
 DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
@@ -121,9 +122,13 @@  libcaf_single_la_LIBADD =
 am_libcaf_single_la_OBJECTS = single.lo
 libcaf_single_la_OBJECTS = $(am_libcaf_single_la_OBJECTS)
 libgfortran_la_LIBADD =
-am__objects_1 = backtrace.lo bounds.lo compile_options.lo \
-	convert_char.lo environ.lo error.lo fpu.lo main.lo memory.lo \
-	pause.lo stop.lo string.lo select.lo
+@LIBGFOR_MINIMAL_FALSE@am__objects_1 = backtrace.lo bounds.lo \
+@LIBGFOR_MINIMAL_FALSE@	compile_options.lo convert_char.lo \
+@LIBGFOR_MINIMAL_FALSE@	environ.lo error.lo fpu.lo main.lo \
+@LIBGFOR_MINIMAL_FALSE@	memory.lo pause.lo stop.lo string.lo \
+@LIBGFOR_MINIMAL_FALSE@	select.lo
+@LIBGFOR_MINIMAL_TRUE@am__objects_1 = bounds.lo compile_options.lo \
+@LIBGFOR_MINIMAL_TRUE@	memory.lo minimal.lo string.lo select.lo
 am__objects_2 = all_l1.lo all_l2.lo all_l4.lo all_l8.lo all_l16.lo
 am__objects_3 = any_l1.lo any_l2.lo any_l4.lo any_l8.lo any_l16.lo
 am__objects_4 = count_1_l.lo count_2_l.lo count_4_l.lo count_8_l.lo \
@@ -260,26 +265,54 @@  am__objects_40 = $(am__objects_2) $(am__
 	$(am__objects_32) $(am__objects_33) $(am__objects_34) \
 	$(am__objects_35) $(am__objects_36) $(am__objects_37) \
 	$(am__objects_38) $(am__objects_39)
-am__objects_41 = close.lo file_pos.lo format.lo inquire.lo \
-	intrinsics.lo list_read.lo lock.lo open.lo read.lo \
-	size_from_kind.lo transfer.lo transfer128.lo unit.lo unix.lo \
-	write.lo fbuf.lo
+@LIBGFOR_MINIMAL_FALSE@am__objects_41 = close.lo file_pos.lo format.lo \
+@LIBGFOR_MINIMAL_FALSE@	inquire.lo intrinsics.lo list_read.lo \
+@LIBGFOR_MINIMAL_FALSE@	lock.lo open.lo read.lo \
+@LIBGFOR_MINIMAL_FALSE@	size_from_kind.lo transfer.lo \
+@LIBGFOR_MINIMAL_FALSE@	transfer128.lo unit.lo unix.lo write.lo \
+@LIBGFOR_MINIMAL_FALSE@	fbuf.lo
+@LIBGFOR_MINIMAL_TRUE@am__objects_41 = size_from_kind.lo
 @IEEE_SUPPORT_TRUE@am__objects_42 = ieee_helper.lo
-am__objects_43 = associated.lo abort.lo access.lo args.lo \
-	bit_intrinsics.lo c99_functions.lo chdir.lo chmod.lo clock.lo \
-	cpu_time.lo cshift0.lo ctime.lo date_and_time.lo dtime.lo \
-	env.lo eoshift0.lo eoshift2.lo erfc_scaled.lo etime.lo \
-	execute_command_line.lo exit.lo extends_type_of.lo fnum.lo \
-	gerror.lo getcwd.lo getlog.lo getXid.lo hostnm.lo ierrno.lo \
-	ishftc.lo iso_c_generated_procs.lo iso_c_binding.lo kill.lo \
-	link.lo malloc.lo mvbits.lo move_alloc.lo pack_generic.lo \
-	perror.lo selected_char_kind.lo signal.lo size.lo sleep.lo \
-	spread_generic.lo string_intrinsics.lo system.lo rand.lo \
-	random.lo rename.lo reshape_generic.lo reshape_packed.lo \
-	selected_int_kind.lo selected_real_kind.lo stat.lo symlnk.lo \
-	system_clock.lo time.lo transpose_generic.lo umask.lo \
-	unlink.lo unpack_generic.lo in_pack_generic.lo \
-	in_unpack_generic.lo $(am__objects_42)
+@LIBGFOR_MINIMAL_FALSE@am__objects_43 = associated.lo abort.lo \
+@LIBGFOR_MINIMAL_FALSE@	access.lo args.lo bit_intrinsics.lo \
+@LIBGFOR_MINIMAL_FALSE@	c99_functions.lo chdir.lo chmod.lo \
+@LIBGFOR_MINIMAL_FALSE@	clock.lo cpu_time.lo cshift0.lo \
+@LIBGFOR_MINIMAL_FALSE@	ctime.lo date_and_time.lo dtime.lo \
+@LIBGFOR_MINIMAL_FALSE@	env.lo eoshift0.lo eoshift2.lo \
+@LIBGFOR_MINIMAL_FALSE@	erfc_scaled.lo etime.lo \
+@LIBGFOR_MINIMAL_FALSE@	execute_command_line.lo exit.lo \
+@LIBGFOR_MINIMAL_FALSE@	extends_type_of.lo fnum.lo gerror.lo \
+@LIBGFOR_MINIMAL_FALSE@	getcwd.lo getlog.lo getXid.lo hostnm.lo \
+@LIBGFOR_MINIMAL_FALSE@	ierrno.lo ishftc.lo \
+@LIBGFOR_MINIMAL_FALSE@	iso_c_generated_procs.lo \
+@LIBGFOR_MINIMAL_FALSE@	iso_c_binding.lo kill.lo link.lo \
+@LIBGFOR_MINIMAL_FALSE@	malloc.lo mvbits.lo move_alloc.lo \
+@LIBGFOR_MINIMAL_FALSE@	pack_generic.lo perror.lo \
+@LIBGFOR_MINIMAL_FALSE@	selected_char_kind.lo signal.lo size.lo \
+@LIBGFOR_MINIMAL_FALSE@	sleep.lo spread_generic.lo \
+@LIBGFOR_MINIMAL_FALSE@	string_intrinsics.lo system.lo rand.lo \
+@LIBGFOR_MINIMAL_FALSE@	random.lo rename.lo reshape_generic.lo \
+@LIBGFOR_MINIMAL_FALSE@	reshape_packed.lo selected_int_kind.lo \
+@LIBGFOR_MINIMAL_FALSE@	selected_real_kind.lo stat.lo symlnk.lo \
+@LIBGFOR_MINIMAL_FALSE@	system_clock.lo time.lo \
+@LIBGFOR_MINIMAL_FALSE@	transpose_generic.lo umask.lo unlink.lo \
+@LIBGFOR_MINIMAL_FALSE@	unpack_generic.lo in_pack_generic.lo \
+@LIBGFOR_MINIMAL_FALSE@	in_unpack_generic.lo $(am__objects_42)
+@LIBGFOR_MINIMAL_TRUE@am__objects_43 = associated.lo abort.lo args.lo \
+@LIBGFOR_MINIMAL_TRUE@	bit_intrinsics.lo cshift0.lo eoshift0.lo \
+@LIBGFOR_MINIMAL_TRUE@	eoshift2.lo erfc_scaled.lo \
+@LIBGFOR_MINIMAL_TRUE@	extends_type_of.lo fnum.lo ierrno.lo \
+@LIBGFOR_MINIMAL_TRUE@	ishftc.lo iso_c_generated_procs.lo \
+@LIBGFOR_MINIMAL_TRUE@	iso_c_binding.lo malloc.lo mvbits.lo \
+@LIBGFOR_MINIMAL_TRUE@	move_alloc.lo pack_generic.lo \
+@LIBGFOR_MINIMAL_TRUE@	selected_char_kind.lo size.lo \
+@LIBGFOR_MINIMAL_TRUE@	spread_generic.lo string_intrinsics.lo \
+@LIBGFOR_MINIMAL_TRUE@	rand.lo random.lo reshape_generic.lo \
+@LIBGFOR_MINIMAL_TRUE@	reshape_packed.lo selected_int_kind.lo \
+@LIBGFOR_MINIMAL_TRUE@	selected_real_kind.lo \
+@LIBGFOR_MINIMAL_TRUE@	transpose_generic.lo unpack_generic.lo \
+@LIBGFOR_MINIMAL_TRUE@	in_pack_generic.lo in_unpack_generic.lo \
+@LIBGFOR_MINIMAL_TRUE@	$(am__objects_42)
 @IEEE_SUPPORT_TRUE@am__objects_44 = ieee_arithmetic.lo \
 @IEEE_SUPPORT_TRUE@	ieee_exceptions.lo ieee_features.lo
 am__objects_45 =
@@ -376,7 +409,7 @@  AMTAR = @AMTAR@
 
 # Some targets require additional compiler options for IEEE compatibility.
 AM_CFLAGS = @AM_CFLAGS@ -fcx-fortran-rules $(SECTION_FLAGS) \
-	$(IEEE_FLAGS)
+	$(IEEE_FLAGS) $(am__append_1)
 AM_FCFLAGS = @AM_FCFLAGS@ $(IEEE_FLAGS)
 AR = @AR@
 AS = @AS@
@@ -554,23 +587,26 @@  AM_CPPFLAGS = -iquote$(srcdir)/io -I$(sr
 	      -I$(srcdir)/$(MULTISRCTOP)../libgcc \
 	      -I$(MULTIBUILDTOP)../libgcc
 
-gfor_io_src = \
-io/close.c \
-io/file_pos.c \
-io/format.c \
-io/inquire.c \
-io/intrinsics.c \
-io/list_read.c \
-io/lock.c \
-io/open.c \
-io/read.c \
-io/size_from_kind.c \
-io/transfer.c \
-io/transfer128.c \
-io/unit.c \
-io/unix.c \
-io/write.c \
-io/fbuf.c
+@LIBGFOR_MINIMAL_FALSE@gfor_io_src = \
+@LIBGFOR_MINIMAL_FALSE@io/close.c \
+@LIBGFOR_MINIMAL_FALSE@io/file_pos.c \
+@LIBGFOR_MINIMAL_FALSE@io/format.c \
+@LIBGFOR_MINIMAL_FALSE@io/inquire.c \
+@LIBGFOR_MINIMAL_FALSE@io/intrinsics.c \
+@LIBGFOR_MINIMAL_FALSE@io/list_read.c \
+@LIBGFOR_MINIMAL_FALSE@io/lock.c \
+@LIBGFOR_MINIMAL_FALSE@io/open.c \
+@LIBGFOR_MINIMAL_FALSE@io/read.c \
+@LIBGFOR_MINIMAL_FALSE@io/size_from_kind.c \
+@LIBGFOR_MINIMAL_FALSE@io/transfer.c \
+@LIBGFOR_MINIMAL_FALSE@io/transfer128.c \
+@LIBGFOR_MINIMAL_FALSE@io/unit.c \
+@LIBGFOR_MINIMAL_FALSE@io/unix.c \
+@LIBGFOR_MINIMAL_FALSE@io/write.c \
+@LIBGFOR_MINIMAL_FALSE@io/fbuf.c
+
+@LIBGFOR_MINIMAL_TRUE@gfor_io_src = \
+@LIBGFOR_MINIMAL_TRUE@io/size_from_kind.c
 
 gfor_io_headers = \
 io/io.h \
@@ -578,54 +614,112 @@  io/fbuf.h \
 io/format.h \
 io/unix.h
 
-gfor_helper_src = intrinsics/associated.c intrinsics/abort.c \
-	intrinsics/access.c intrinsics/args.c \
-	intrinsics/bit_intrinsics.c intrinsics/c99_functions.c \
-	intrinsics/chdir.c intrinsics/chmod.c intrinsics/clock.c \
-	intrinsics/cpu_time.c intrinsics/cshift0.c intrinsics/ctime.c \
-	intrinsics/date_and_time.c intrinsics/dtime.c intrinsics/env.c \
-	intrinsics/eoshift0.c intrinsics/eoshift2.c \
-	intrinsics/erfc_scaled.c intrinsics/etime.c \
-	intrinsics/execute_command_line.c intrinsics/exit.c \
-	intrinsics/extends_type_of.c intrinsics/fnum.c \
-	intrinsics/gerror.c intrinsics/getcwd.c intrinsics/getlog.c \
-	intrinsics/getXid.c intrinsics/hostnm.c intrinsics/ierrno.c \
-	intrinsics/ishftc.c intrinsics/iso_c_generated_procs.c \
-	intrinsics/iso_c_binding.c intrinsics/kill.c intrinsics/link.c \
-	intrinsics/malloc.c intrinsics/mvbits.c \
-	intrinsics/move_alloc.c intrinsics/pack_generic.c \
-	intrinsics/perror.c intrinsics/selected_char_kind.c \
-	intrinsics/signal.c intrinsics/size.c intrinsics/sleep.c \
-	intrinsics/spread_generic.c intrinsics/string_intrinsics.c \
-	intrinsics/system.c intrinsics/rand.c intrinsics/random.c \
-	intrinsics/rename.c intrinsics/reshape_generic.c \
-	intrinsics/reshape_packed.c intrinsics/selected_int_kind.f90 \
-	intrinsics/selected_real_kind.f90 intrinsics/stat.c \
-	intrinsics/symlnk.c intrinsics/system_clock.c \
-	intrinsics/time.c intrinsics/transpose_generic.c \
-	intrinsics/umask.c intrinsics/unlink.c \
-	intrinsics/unpack_generic.c runtime/in_pack_generic.c \
-	runtime/in_unpack_generic.c $(am__append_1)
+@LIBGFOR_MINIMAL_FALSE@gfor_helper_src = intrinsics/associated.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/abort.c intrinsics/access.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/args.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/bit_intrinsics.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/c99_functions.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/chdir.c intrinsics/chmod.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/clock.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/cpu_time.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/cshift0.c intrinsics/ctime.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/date_and_time.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/dtime.c intrinsics/env.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/eoshift0.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/eoshift2.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/erfc_scaled.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/etime.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/execute_command_line.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/exit.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/extends_type_of.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/fnum.c intrinsics/gerror.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/getcwd.c intrinsics/getlog.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/getXid.c intrinsics/hostnm.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/ierrno.c intrinsics/ishftc.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/iso_c_generated_procs.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/iso_c_binding.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/kill.c intrinsics/link.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/malloc.c intrinsics/mvbits.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/move_alloc.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/pack_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/perror.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/selected_char_kind.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/signal.c intrinsics/size.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/sleep.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/spread_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/string_intrinsics.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/system.c intrinsics/rand.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/random.c intrinsics/rename.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/reshape_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/reshape_packed.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/selected_int_kind.f90 \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/selected_real_kind.f90 \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/stat.c intrinsics/symlnk.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/system_clock.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/time.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/transpose_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/umask.c intrinsics/unlink.c \
+@LIBGFOR_MINIMAL_FALSE@	intrinsics/unpack_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	runtime/in_pack_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	runtime/in_unpack_generic.c \
+@LIBGFOR_MINIMAL_FALSE@	$(am__append_2)
+@LIBGFOR_MINIMAL_TRUE@gfor_helper_src = intrinsics/associated.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/abort.c intrinsics/args.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/bit_intrinsics.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/cshift0.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/eoshift0.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/eoshift2.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/erfc_scaled.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/extends_type_of.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/fnum.c intrinsics/ierrno.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/ishftc.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/iso_c_generated_procs.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/iso_c_binding.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/malloc.c intrinsics/mvbits.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/move_alloc.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/pack_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/selected_char_kind.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/size.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/spread_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/string_intrinsics.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/rand.c intrinsics/random.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/reshape_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/reshape_packed.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/selected_int_kind.f90 \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/selected_real_kind.f90 \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/transpose_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	intrinsics/unpack_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	runtime/in_pack_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	runtime/in_unpack_generic.c \
+@LIBGFOR_MINIMAL_TRUE@	$(am__append_2)
 @IEEE_SUPPORT_FALSE@gfor_ieee_src = 
 @IEEE_SUPPORT_TRUE@gfor_ieee_src = \
 @IEEE_SUPPORT_TRUE@ieee/ieee_arithmetic.F90 \
 @IEEE_SUPPORT_TRUE@ieee/ieee_exceptions.F90 \
 @IEEE_SUPPORT_TRUE@ieee/ieee_features.F90
 
-gfor_src = \
-runtime/backtrace.c \
-runtime/bounds.c \
-runtime/compile_options.c \
-runtime/convert_char.c \
-runtime/environ.c \
-runtime/error.c \
-runtime/fpu.c \
-runtime/main.c \
-runtime/memory.c \
-runtime/pause.c \
-runtime/stop.c \
-runtime/string.c \
-runtime/select.c
+@LIBGFOR_MINIMAL_FALSE@gfor_src = \
+@LIBGFOR_MINIMAL_FALSE@runtime/backtrace.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/bounds.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/compile_options.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/convert_char.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/environ.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/error.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/fpu.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/main.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/memory.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/pause.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/stop.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/string.c \
+@LIBGFOR_MINIMAL_FALSE@runtime/select.c
+
+@LIBGFOR_MINIMAL_TRUE@gfor_src = \
+@LIBGFOR_MINIMAL_TRUE@runtime/bounds.c \
+@LIBGFOR_MINIMAL_TRUE@runtime/compile_options.c \
+@LIBGFOR_MINIMAL_TRUE@runtime/memory.c \
+@LIBGFOR_MINIMAL_TRUE@runtime/minimal.c \
+@LIBGFOR_MINIMAL_TRUE@runtime/string.c \
+@LIBGFOR_MINIMAL_TRUE@runtime/select.c
 
 i_all_c = \
 $(srcdir)/generated/all_l1.c \
@@ -1255,7 +1349,7 @@  intrinsics/f2c_specifics.F90
 
 BUILT_SOURCES = $(gfor_built_src) $(gfor_built_specific_src) \
 	$(gfor_built_specific2_src) $(gfor_misc_specifics) \
-	$(am__append_2)
+	$(am__append_3)
 prereq_SRC = $(gfor_src) $(gfor_built_src) $(gfor_io_src) \
     $(gfor_helper_src) $(gfor_ieee_src) $(gfor_io_headers) $(gfor_specific_src)
 
@@ -1669,6 +1763,7 @@  distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maxval_r4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maxval_r8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minloc0_16_i1.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minloc0_16_i16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minloc0_16_i2.Plo@am__quote@
@@ -2463,6 +2558,13 @@  select.lo: runtime/select.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o select.lo `test -f 'runtime/select.c' || echo '$(srcdir)/'`runtime/select.c
 
+minimal.lo: runtime/minimal.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT minimal.lo -MD -MP -MF $(DEPDIR)/minimal.Tpo -c -o minimal.lo `test -f 'runtime/minimal.c' || echo '$(srcdir)/'`runtime/minimal.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/minimal.Tpo $(DEPDIR)/minimal.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='runtime/minimal.c' object='minimal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o minimal.lo `test -f 'runtime/minimal.c' || echo '$(srcdir)/'`runtime/minimal.c
+
 all_l1.lo: $(srcdir)/generated/all_l1.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT all_l1.lo -MD -MP -MF $(DEPDIR)/all_l1.Tpo -c -o all_l1.lo `test -f '$(srcdir)/generated/all_l1.c' || echo '$(srcdir)/'`$(srcdir)/generated/all_l1.c
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/all_l1.Tpo $(DEPDIR)/all_l1.Plo
Index: libgfortran/caf/single.c
===================================================================
--- libgfortran/caf/single.c.orig
+++ libgfortran/caf/single.c
@@ -48,13 +48,14 @@  caf_static_t *caf_static_list = NULL;
 static void
 caf_runtime_error (const char *message, ...)
 {
+#ifndef LIBGFOR_MINIMAL
   va_list ap;
   fprintf (stderr, "Fortran runtime error: ");
   va_start (ap, message);
   vfprintf (stderr, message, ap);
   va_end (ap);
   fprintf (stderr, "\n");
-
+#endif
   /* FIXME: Shutdown the Fortran RTL to flush the buffer.  PR 43849.  */
   exit (EXIT_FAILURE);
 }
Index: libgfortran/configure
===================================================================
--- libgfortran/configure.orig
+++ libgfortran/configure
@@ -641,6 +641,8 @@  RANLIB
 AR
 AS
 SECTION_FLAGS
+LIBGFOR_MINIMAL_FALSE
+LIBGFOR_MINIMAL_TRUE
 LIBGFOR_USE_SYMVER_SUN_FALSE
 LIBGFOR_USE_SYMVER_SUN_TRUE
 LIBGFOR_USE_SYMVER_GNU_FALSE
@@ -5890,6 +5892,15 @@  else
 fi
 
 
+ if test "x${target_cpu}" = xnvptx; then
+  LIBGFOR_MINIMAL_TRUE=
+  LIBGFOR_MINIMAL_FALSE='#'
+else
+  LIBGFOR_MINIMAL_TRUE='#'
+  LIBGFOR_MINIMAL_FALSE=
+fi
+
+
 # Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
 # similarly to how libstdc++ does it
 ac_test_CFLAGS="${CFLAGS+set}"
@@ -12350,7 +12361,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12353 "configure"
+#line 12364 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12456,7 +12467,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12459 "configure"
+#line 12470 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -26799,6 +26810,10 @@  if test -z "${LIBGFOR_USE_SYMVER_SUN_TRU
   as_fn_error "conditional \"LIBGFOR_USE_SYMVER_SUN\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LIBGFOR_MINIMAL_TRUE}" && test -z "${LIBGFOR_MINIMAL_FALSE}"; then
+  as_fn_error "conditional \"LIBGFOR_MINIMAL\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${LIBGFOR_BUILD_QUAD_TRUE}" && test -z "${LIBGFOR_BUILD_QUAD_FALSE}"; then
   as_fn_error "conditional \"LIBGFOR_BUILD_QUAD\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
Index: libgfortran/configure.ac
===================================================================
--- libgfortran/configure.ac.orig
+++ libgfortran/configure.ac
@@ -189,6 +189,8 @@  AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test
 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_GNU, [test "x$gfortran_use_symver" = xgnu])
 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_SUN, [test "x$gfortran_use_symver" = xsun])
 
+AM_CONDITIONAL(LIBGFOR_MINIMAL, [test "x${target_cpu}" = xnvptx])
+
 # Figure out whether the compiler supports "-ffunction-sections -fdata-sections",
 # similarly to how libstdc++ does it
 ac_test_CFLAGS="${CFLAGS+set}"
Index: libgfortran/runtime/compile_options.c
===================================================================
--- libgfortran/runtime/compile_options.c.orig
+++ libgfortran/runtime/compile_options.c
@@ -29,7 +29,7 @@  see the files COPYING3 and COPYING.RUNTI
 /* Useful compile-time options will be stored in here.  */
 compile_options_t compile_options;
 
-
+#ifndef LIBGFOR_MINIMAL
 volatile sig_atomic_t fatal_error_in_progress = 0;
 
 
@@ -146,6 +146,7 @@  maybe_find_addr2line (void)
   if (options.backtrace == -1)
     find_addr2line ();
 }
+#endif
 
 /* Set the usual compile-time options.  */
 extern void set_options (int , int []);
@@ -176,6 +177,7 @@  set_options (int num, int options[])
   if (num >= 9)
     compile_options.fpe_summary = options[8];
 
+#ifndef LIBGFOR_MINIMAL
   /* If backtrace is required, we set signal handlers on the POSIX
      2001 signals with core action.  */
   if (compile_options.backtrace)
@@ -212,6 +214,7 @@  set_options (int num, int options[])
 
       maybe_find_addr2line ();
     }
+#endif
 }
 
 
Index: libgfortran/runtime/minimal.c
===================================================================
--- /dev/null
+++ libgfortran/runtime/minimal.c
@@ -0,0 +1,197 @@ 
+/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
+   Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* Stupid function to be sure the constructor is always linked in, even
+   in the case of static linking.  See PR libfortran/22298 for details.  */
+void
+stupid_function_name_for_static_linking (void)
+{
+  return;
+}
+
+options_t options;
+
+/* This will be 0 for little-endian
+   machines and 1 for big-endian machines.  */
+int big_endian = 0;
+
+
+/* Figure out endianness for this machine.  */
+
+static void
+determine_endianness (void)
+{
+  union
+  {
+    GFC_LOGICAL_8 l8;
+    GFC_LOGICAL_4 l4[2];
+  } u;
+
+  u.l8 = 1;
+  if (u.l4[0])
+    big_endian = 0;
+  else if (u.l4[1])
+    big_endian = 1;
+  else
+    runtime_error ("Unable to determine machine endianness");
+}
+
+
+static int argc_save;
+static char **argv_save;
+
+static const char *exe_path;
+
+/* recursion_check()-- It's possible for additional errors to occur
+ * during fatal error processing.  We detect this condition here and
+ * exit with code 4 immediately. */
+
+#define MAGIC 0x20DE8101
+
+static void
+recursion_check (void)
+{
+  static int magic = 0;
+
+  /* Don't even try to print something at this point */
+  if (magic == MAGIC)
+    sys_abort ();
+
+  magic = MAGIC;
+}
+
+#define STRERR_MAXSZ 256
+
+void
+os_error (const char *message)
+{
+  recursion_check ();
+  printf ("Operating system error: ");
+  printf ("%s\n", message);
+  exit (1);
+}
+iexport(os_error);
+
+void
+runtime_error (const char *message, ...)
+{
+  va_list ap;
+
+  recursion_check ();
+  printf ("Fortran runtime error: ");
+  va_start (ap, message);
+  vprintf (message, ap);
+  va_end (ap);
+  printf ("\n");
+  exit (2);
+}
+iexport(runtime_error);
+
+/* void runtime_error_at()-- These are errors associated with a
+ * run time error generated by the front end compiler.  */
+
+void
+runtime_error_at (const char *where, const char *message, ...)
+{
+  va_list ap;
+
+  recursion_check ();
+  printf ("Fortran runtime error: ");
+  va_start (ap, message);
+  vprintf (message, ap);
+  va_end (ap);
+  printf ("\n");
+  exit (2);
+}
+iexport(runtime_error_at);
+
+/* Return the full path of the executable.  */
+char *
+full_exe_path (void)
+{
+  return (char *) exe_path;
+}
+
+
+/* Set the saved values of the command line arguments.  */
+
+void
+set_args (int argc, char **argv)
+{
+  argc_save = argc;
+  argv_save = argv;
+  exe_path = argv[0];
+}
+iexport(set_args);
+
+
+/* Retrieve the saved values of the command line arguments.  */
+
+void
+get_args (int *argc, char ***argv)
+{
+  *argc = argc_save;
+  *argv = argv_save;
+}
+
+#if 0
+/* Initialize the runtime library.  */
+
+static void /* __attribute__((constructor)) */
+init (void)
+{
+  /* Figure out the machine endianness.  */
+  determine_endianness ();
+
+  /* Must be first */
+  init_variables ();
+
+  set_fpu ();
+  init_compile_options ();
+
+  random_seed_i4 (NULL, NULL, NULL);
+}
+
+#endif
+
+/* sys_abort()-- Terminate the program showing backtrace and dumping
+   core.  */
+
+void
+sys_abort (void)
+{
+  printf ("Abort called.\n");
+  abort();
+}