Commit 092231a8 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/39178 (Generate main() rather than using a main in libgfortran/fmain.c)

fortran/
2009-05-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/39178
        * gfortranspec.c (lang_specific_driver): Stop linking
        libgfortranbegin.
        * trans-decl.c (gfc_build_builtin_function_decls): Stop
        making MAIN__ publicly visible.
        (gfc_build_builtin_function_decls): Add
        gfor_fndecl_set_args.
        (create_main_function) New function.
        (gfc_generate_function_code): Use it.

libgfortran/
2009-05-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/39178
        * runtime/main.c (store_exe_path): Make static
        and multiple-times callable.
        (set_args): Call store_exe_path.
        * libgfortran.h: Remove store_exe_path prototype.
        * fmain.c (main): Remove store_exe_path call.

From-SVN: r147883
parent 9a0bab0b
2009-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/39178
* gfortranspec.c (lang_specific_driver): Stop linking
libgfortranbegin.
* trans-decl.c (gfc_build_builtin_function_decls): Stop
making MAIN__ publicly visible.
(gfc_build_builtin_function_decls): Add
gfor_fndecl_set_args.
(create_main_function) New function.
(gfc_generate_function_code): Use it.
2009-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/40246
* match.c (gfc_match_nullify): NULLify freed pointer.
......
......@@ -58,10 +58,6 @@ along with GCC; see the file COPYING3. If not see
#define MATH_LIBRARY "-lm"
#endif
#ifndef FORTRAN_INIT
#define FORTRAN_INIT "-lgfortranbegin"
#endif
#ifndef FORTRAN_LIBRARY
#define FORTRAN_LIBRARY "-lgfortran"
#endif
......@@ -278,10 +274,6 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
2 => last two args were -l<library> -lm. */
int saw_library = 0;
/* 0 => initial/reset state
1 => FORTRAN_INIT linked in */
int use_init = 0;
/* By default, we throw on the math library if we have one. */
int need_math = (MATH_LIBRARY[0] != '\0');
......@@ -505,12 +497,6 @@ For more information about these matters, see the file named COPYING\n\n"));
saw_library = 2; /* -l<library> -lm. */
else
{
if (0 == use_init)
{
append_arg (FORTRAN_INIT);
use_init = 1;
}
ADD_ARG_LIBGFORTRAN (FORTRAN_LIBRARY);
}
}
......@@ -540,11 +526,6 @@ For more information about these matters, see the file named COPYING\n\n"));
switch (saw_library)
{
case 0:
if (0 == use_init)
{
append_arg (FORTRAN_INIT);
use_init = 1;
}
ADD_ARG_LIBGFORTRAN (library);
/* Fall through. */
......
2009-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/39178
* runtime/main.c (store_exe_path): Make static
and multiple-times callable.
(set_args): Call store_exe_path.
* libgfortran.h: Remove store_exe_path prototype.
* fmain.c (main): Remove store_exe_path call.
2009-05-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/37754
......
......@@ -9,12 +9,8 @@ void MAIN__ (void);
int
main (int argc, char *argv[])
{
/* Store the path of the executable file. */
store_exe_path (argv[0]);
/* Set up the runtime environment. */
set_args (argc, argv);
PREFIX(set_args) (argc, argv);
/* Call the Fortran main program. Internally this is a function
called MAIN__ */
......
......@@ -610,9 +610,6 @@ export_proto(set_args);
extern void get_args (int *, char ***);
internal_proto(get_args);
extern void store_exe_path (const char *);
export_proto(store_exe_path);
extern char * full_exe_path (void);
internal_proto(full_exe_path);
......
......@@ -69,31 +69,12 @@ determine_endianness (void)
static int argc_save;
static char **argv_save;
/* Set the saved values of the command line arguments. */
void
set_args (int argc, char **argv)
{
argc_save = argc;
argv_save = argv;
}
/* Retrieve the saved values of the command line arguments. */
void
get_args (int *argc, char ***argv)
{
*argc = argc_save;
*argv = argv_save;
}
static const char *exe_path;
static int please_free_exe_path_when_done;
/* Save the path under which the program was called, for use in the
backtrace routines. */
void
static void
store_exe_path (const char * argv0)
{
#ifndef PATH_MAX
......@@ -106,6 +87,10 @@ store_exe_path (const char * argv0)
char buf[PATH_MAX], *cwd, *path;
/* This can only happen if store_exe_path is called multiple times. */
if (please_free_exe_path_when_done)
free ((char *) exe_path);
/* On the simulator argv is not set. */
if (argv0 == NULL || argv0[0] == '/')
{
......@@ -128,6 +113,7 @@ store_exe_path (const char * argv0)
please_free_exe_path_when_done = 1;
}
/* Return the full path of the executable. */
char *
full_exe_path (void)
......@@ -135,6 +121,28 @@ 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;
store_exe_path (argv[0]);
}
/* Retrieve the saved values of the command line arguments. */
void
get_args (int *argc, char ***argv)
{
*argc = argc_save;
*argv = argv_save;
}
/* Initialize the runtime library. */
static void __attribute__((constructor))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment