Commit 86db887a by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR other/31400 (enable static linking of support libraries through -static-libXY)

	PR other/31400

	* gcc.c (process_command): Recognize the new -static-libgfortran
	option.

	* lang.opt (static-libgfortran): New option.
	* gfortranspec.c (ADD_ARG_LIBGFORTRAN): New macro.
	(Option): Add OPTION_static and OPTION_static_libgfortran.
	(lookup_option): Handle the new -static-libgfortran option.
	(lang_specific_driver): Check whether -static is passed.
	Handle the new -static-libgfortran option.
	* options.c (gfc_handle_option): If -static-libgfortran is
	passed and isn't supported on this configuration, error out.

From-SVN: r126068
parent 99920b6f
2007-06-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR other/31400
* gcc.c (process_command): Recognize the new -static-libgfortran
option.
2007-06-27 Rask Ingemann Lambertsen <rask@sygehus.dk> 2007-06-27 Rask Ingemann Lambertsen <rask@sygehus.dk>
PR target/32418 PR target/32418
......
2007-06-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR other/31400
* lang.opt (static-libgfortran): New option.
* gfortranspec.c (ADD_ARG_LIBGFORTRAN): New macro.
(Option): Add OPTION_static and OPTION_static_libgfortran.
(lookup_option): Handle the new -static-libgfortran option.
(lang_specific_driver): Check whether -static is passed.
Handle the new -static-libgfortran option.
* options.c (gfc_handle_option): If -static-libgfortran is
passed and isn't supported on this configuration, error out.
2007-06-27 Daniel Franke <franke.daniel@gmail.com> 2007-06-27 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32467 PR fortran/32467
......
...@@ -66,6 +66,20 @@ Boston, MA 02110-1301, USA. */ ...@@ -66,6 +66,20 @@ Boston, MA 02110-1301, USA. */
#define FORTRAN_LIBRARY "-lgfortran" #define FORTRAN_LIBRARY "-lgfortran"
#endif #endif
#ifdef HAVE_LD_STATIC_DYNAMIC
#define ADD_ARG_LIBGFORTRAN(arg) \
{ \
if (static_lib && !static_linking) \
append_arg ("-Wl,-Bstatic"); \
append_arg (arg); \
if (static_lib && !static_linking) \
append_arg ("-Wl,-Bdynamic"); \
}
#else
#define ADD_ARG_LIBGFORTRAN(arg) append_arg (arg);
#endif
/* Options this driver needs to recognize, not just know how to /* Options this driver needs to recognize, not just know how to
skip over. */ skip over. */
typedef enum typedef enum
...@@ -82,6 +96,8 @@ typedef enum ...@@ -82,6 +96,8 @@ typedef enum
-nodefaultlibs. */ -nodefaultlibs. */
OPTION_o, /* Aka --output. */ OPTION_o, /* Aka --output. */
OPTION_S, /* Aka --assemble. */ OPTION_S, /* Aka --assemble. */
OPTION_static, /* -static. */
OPTION_static_libgfortran, /* -static-libgfortran. */
OPTION_syntax_only, /* -fsyntax-only. */ OPTION_syntax_only, /* -fsyntax-only. */
OPTION_v, /* Aka --verbose. */ OPTION_v, /* Aka --verbose. */
OPTION_version, /* --version. */ OPTION_version, /* --version. */
...@@ -170,6 +186,8 @@ lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text) ...@@ -170,6 +186,8 @@ lookup_option (Option *xopt, int *xskip, const char **xarg, const char *text)
opt = OPTION_nostdlib; opt = OPTION_nostdlib;
else if (!strcmp (text, "-fsyntax-only")) else if (!strcmp (text, "-fsyntax-only"))
opt = OPTION_syntax_only; opt = OPTION_syntax_only;
else if (!strcmp (text, "-static-libgfortran"))
opt = OPTION_static_libgfortran;
else if (!strcmp (text, "-dumpversion")) else if (!strcmp (text, "-dumpversion"))
opt = OPTION_version; opt = OPTION_version;
else if (!strcmp (text, "-fversion")) /* Really --version!! */ else if (!strcmp (text, "-fversion")) /* Really --version!! */
...@@ -265,6 +283,12 @@ lang_specific_driver (int *in_argc, const char *const **in_argv, ...@@ -265,6 +283,12 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
/* By default, we throw on the math library if we have one. */ /* By default, we throw on the math library if we have one. */
int need_math = (MATH_LIBRARY[0] != '\0'); int need_math = (MATH_LIBRARY[0] != '\0');
/* Whether we should link a static libgfortran. */
int static_lib = 0;
/* Whether we need to link statically. */
int static_linking = 0;
/* The number of input and output files in the incoming arg list. */ /* The number of input and output files in the incoming arg list. */
int n_infiles = 0; int n_infiles = 0;
int n_outfiles = 0; int n_outfiles = 0;
...@@ -323,6 +347,13 @@ lang_specific_driver (int *in_argc, const char *const **in_argv, ...@@ -323,6 +347,13 @@ lang_specific_driver (int *in_argc, const char *const **in_argv,
library = 0; library = 0;
break; break;
case OPTION_static_libgfortran:
static_lib = 1;
break;
case OPTION_static:
static_linking = 1;
case OPTION_l: case OPTION_l:
++n_infiles; ++n_infiles;
break; break;
...@@ -468,11 +499,16 @@ For more information about these matters, see the file named COPYING\n\n")); ...@@ -468,11 +499,16 @@ For more information about these matters, see the file named COPYING\n\n"));
append_arg (FORTRAN_INIT); append_arg (FORTRAN_INIT);
use_init = 1; use_init = 1;
} }
append_arg (FORTRAN_LIBRARY);
ADD_ARG_LIBGFORTRAN (FORTRAN_LIBRARY);
} }
} }
else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0) else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
saw_library = 1; /* -l<library>. */ {
saw_library = 1; /* -l<library>. */
ADD_ARG_LIBGFORTRAN (argv[i]);
continue;
}
else else
{ /* Other library, or filename. */ { /* Other library, or filename. */
if (saw_library == 1 && need_math) if (saw_library == 1 && need_math)
...@@ -498,7 +534,9 @@ For more information about these matters, see the file named COPYING\n\n")); ...@@ -498,7 +534,9 @@ For more information about these matters, see the file named COPYING\n\n"));
append_arg (FORTRAN_INIT); append_arg (FORTRAN_INIT);
use_init = 1; use_init = 1;
} }
append_arg (library); ADD_ARG_LIBGFORTRAN (library);
/* Fall through. */
case 1: case 1:
if (need_math) if (need_math)
append_arg (MATH_LIBRARY); append_arg (MATH_LIBRARY);
......
...@@ -253,6 +253,10 @@ funderscoring ...@@ -253,6 +253,10 @@ funderscoring
Fortran Fortran
Append underscores to externally visible names Append underscores to externally visible names
static-libgfortran
Fortran
Statically link the GNU Fortran helper library (libgfortran)
std=f2003 std=f2003
Fortran Fortran
Conform to the ISO Fortran 2003 standard Conform to the ISO Fortran 2003 standard
......
...@@ -551,6 +551,13 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -551,6 +551,13 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_option.flag_second_underscore = value; gfc_option.flag_second_underscore = value;
break; break;
case OPT_static_libgfortran:
#ifndef HAVE_LD_STATIC_DYNAMIC
gfc_fatal_error ("-static-libgfortran is not supported in this "
"configuration");
#endif
break;
case OPT_fimplicit_none: case OPT_fimplicit_none:
gfc_option.flag_implicit_none = value; gfc_option.flag_implicit_none = value;
break; break;
......
...@@ -4214,11 +4214,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ...@@ -4214,11 +4214,13 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
switches[n_switches].live_cond = SWITCH_OK; switches[n_switches].live_cond = SWITCH_OK;
switches[n_switches].validated = 0; switches[n_switches].validated = 0;
switches[n_switches].ordering = 0; switches[n_switches].ordering = 0;
/* These are always valid, since gcc.c itself understands them. */ /* These are always valid, since gcc.c itself understands the
first four and gfortranspec.c understands -static-libgfortran. */
if (!strcmp (p, "save-temps") if (!strcmp (p, "save-temps")
|| !strcmp (p, "static-libgcc") || !strcmp (p, "static-libgcc")
|| !strcmp (p, "shared-libgcc") || !strcmp (p, "shared-libgcc")
|| !strcmp (p, "pipe")) || !strcmp (p, "pipe")
|| !strcmp (p, "static-libgfortran"))
switches[n_switches].validated = 1; switches[n_switches].validated = 1;
else else
{ {
......
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