From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11898 invoked by alias); 14 Mar 2006 15:17:02 -0000 Received: (qmail 11876 invoked by uid 48); 14 Mar 2006 15:16:59 -0000 Date: Tue, 14 Mar 2006 15:17:00 -0000 Subject: [Bug fortran/26682] New: gfortran fails with -fwhole-program optimization X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jjcogliati-r1 at yahoo dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-03/txt/msg01503.txt.bz2 List-Id: The following simple.f90 program: PROGRAM hello_world PRINT *,"Hello, World!" END PROGRAM hello_world does not compile with the following arguments: gfortran -fwhole-program -O2 -o simple simple.f90 ~/gcc_install/lib/gcc/i686-pc-linux-gnu/4.1.0/../../../libgfortranbegin.a(fmain.o)(.text+0x23): In function `main': ../../../gcc-4.1.0/libgfortran/fmain.c:18: undefined reference to `MAIN__' collect2: ld returned 1 exit status The program compiles fine with just -O2 or -fwhole-program and prints out the expected Hello, World! I think the problem roughly is that -fwhole-program combined with -O2 is optimizing out the main function since it is not getting called internally. I was unable to find in the documentation any method of forcing external visiblity in a fortran 90 program. There was also no mention of gfortran not having -fwhole-program working in http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Optimize-Options.html -- Summary: gfortran fails with -fwhole-program optimization Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jjcogliati-r1 at yahoo dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26682