This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/22298] New: libgfortran init() constructor isn't called if executable is statically linked
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jul 2005 21:18:19 -0000
- Subject: [Bug libfortran/22298] New: libgfortran init() constructor isn't called if executable is statically linked
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
$ cat a_fortran.f90
subroutine f
print *, '##'
end
$ gfortran -c a_fortran.f90
$ cat a.c
extern void f_(void);
int main (void)
{
f_ ();
}
$ ./irun/bin/gcc -c a.c
$ gfortran -static a.o a_fortran.o && ./a.out
Fortran runtime error: End of record
$ gfortran a.o a_fortran.o && ./a.out
##
This happens because the init() constructor (libgfortran/runtime/main.c) is not
called when a.out is executed, if it was linked statically.
According to Andrew, one way to make sure that init() is called is to reference
it in an object file we're sure will be used. I'm thinking of runtime/error.c.
--
Summary: libgfortran init() constructor isn't called if
executable is statically linked
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22298