1 /* gm2spec.cc specific flags and argument handling within GNU Modula-2.
3 Copyright (C) 2007-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius@glam.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
30 #include "opt-suggestions.h"
37 #include "m2/gm2config.h"
42 #ifdef HAVE_SYS_NDIR_H
53 /* This bit is set if the arguments is a M2 source file. */
54 #define M2SOURCE (1<<1)
55 /* This bit is set if we saw a `-xfoo' language specification. */
56 #define LANGSPEC (1<<2)
57 /* This bit is set if they did `-lm' or `-lmath'. */
58 #define MATHLIB (1<<3)
59 /* This bit is set if they did `-lc'. */
60 #define WITHLIBC (1<<4)
61 /* Skip this option. */
62 #define SKIPOPT (1<<5)
65 #define MATH_LIBRARY "m"
67 #ifndef MATH_LIBRARY_PROFILE
68 #define MATH_LIBRARY_PROFILE MATH_LIBRARY
72 #define LIBSTDCXX "stdc++"
74 #ifndef LIBSTDCXX_PROFILE
75 #define LIBSTDCXX_PROFILE LIBSTDCXX
77 #ifndef LIBSTDCXX_STATIC
78 #define LIBSTDCXX_STATIC NULL
84 #ifndef LIBCXX_PROFILE
85 #define LIBCXX_PROFILE LIBCXX
88 #define LIBCXX_STATIC NULL
92 #define LIBCXXABI "c++abi"
94 #ifndef LIBCXXABI_PROFILE
95 #define LIBCXXABI_PROFILE LIBCXXABI
97 #ifndef LIBCXXABI_STATIC
98 #define LIBCXXABI_STATIC NULL
101 /* The values used here must match those of the stdlib_kind enumeration
109 #define DEFAULT_DIALECT "pim"
113 typedef enum { iso
, pim
, min
, logitech
, pimcoroutine
, maxlib
} libs
;
115 /* These are the library names which are installed as part of gm2 and reflect
116 -flibs=name. The -flibs= option provides the user with a short cut to add
117 libraries without having to know the include and link path. */
119 static const char *library_name
[maxlib
]
120 = { "m2iso", "m2pim", "m2min", "m2log", "m2cor" };
122 /* They match the installed archive name for example libm2iso.a,
123 libm2pim.a, libm2min.a, libm2log.a and libm2cor.a. They also match a
124 subdirectory name where the definition modules are kept. The driver
125 checks the argument to -flibs= for an entry in library_name or
126 alternatively the existance of the subdirectory (to allow for third
127 party libraries to coexist). */
129 static const char *library_abbrev
[maxlib
]
130 = { "iso", "pim", "min", "log", "cor" };
132 /* Users may specifiy -flibs=pim,iso etc which are mapped onto
133 -flibs=m2pim,m2iso respectively. This provides a match between
134 the dialect of Modula-2 and the library set. */
136 static bool seen_scaffold_static
= false;
137 static bool seen_scaffold_dynamic
= false;
138 static bool seen_scaffold_main
= false;
139 static bool scaffold_static
= false;
140 static bool scaffold_dynamic
= true; // Default uses -fscaffold-dynamic.
141 static bool scaffold_main
= false;
142 static bool seen_gen_module_list
= false;
143 static bool seen_uselist
= false;
144 static bool uselist
= false;
145 static bool gen_module_list
= true; // Default uses -fgen-module-list=-.
146 static const char *gen_module_filename
= "-";
147 /* The original argument list and related info is copied here. */
148 static unsigned int gm2_xargc
;
149 static const struct cl_decoded_option
*gm2_x_decoded_options
;
150 static void append_arg (const struct cl_decoded_option
*);
152 /* The new argument list will be built here. */
153 static unsigned int gm2_newargc
;
154 static struct cl_decoded_option
*gm2_new_decoded_options
;
155 static const char *libraries
= NULL
; /* Abbreviated libraries. */
156 static const char *m2_path_name
= "";
158 typedef struct named_path_s
{
159 std::vector
<const char*>path
;
163 static std::vector
<named_path
>Ipaths
;
167 push_back_Ipath (const char *arg
)
172 np
.path
.push_back (arg
);
173 np
.name
= m2_path_name
;
174 Ipaths
.push_back (np
);
178 if (strcmp (Ipaths
.back ().name
,
180 Ipaths
.back ().path
.push_back (arg
);
184 np
.path
.push_back (arg
);
185 np
.name
= m2_path_name
;
186 Ipaths
.push_back (np
);
191 /* Return whether strings S1 and S2 are both NULL or both the same
195 strings_same (const char *s1
, const char *s2
)
197 return s1
== s2
|| (s1
!= NULL
&& s2
!= NULL
&& strcmp (s1
, s2
) == 0);
201 options_same (const struct cl_decoded_option
*opt1
,
202 const struct cl_decoded_option
*opt2
)
204 return (opt1
->opt_index
== opt2
->opt_index
205 && strings_same (opt1
->arg
, opt2
->arg
)
206 && strings_same (opt1
->orig_option_with_args_text
,
207 opt2
->orig_option_with_args_text
)
208 && strings_same (opt1
->canonical_option
[0],
209 opt2
->canonical_option
[0])
210 && strings_same (opt1
->canonical_option
[1],
211 opt2
->canonical_option
[1])
212 && strings_same (opt1
->canonical_option
[2],
213 opt2
->canonical_option
[2])
214 && strings_same (opt1
->canonical_option
[3],
215 opt2
->canonical_option
[3])
216 && (opt1
->canonical_option_num_elements
217 == opt2
->canonical_option_num_elements
)
218 && opt1
->value
== opt2
->value
219 && opt1
->errors
== opt2
->errors
);
222 /* Append another argument to the list being built. */
225 append_arg (const struct cl_decoded_option
*arg
)
227 static unsigned int newargsize
;
229 if (gm2_new_decoded_options
== gm2_x_decoded_options
230 && gm2_newargc
< gm2_xargc
231 && options_same (arg
, &gm2_x_decoded_options
[gm2_newargc
]))
234 return; /* Nothing new here. */
237 if (gm2_new_decoded_options
== gm2_x_decoded_options
)
238 { /* Make new arglist. */
241 newargsize
= (gm2_xargc
<< 2) + 20; /* This should handle all. */
242 gm2_new_decoded_options
= XNEWVEC (struct cl_decoded_option
, newargsize
);
244 /* Copy what has been done so far. */
245 for (i
= 0; i
< gm2_newargc
; ++i
)
246 gm2_new_decoded_options
[i
] = gm2_x_decoded_options
[i
];
249 if (gm2_newargc
== newargsize
)
250 fatal_error (input_location
, "overflowed output argument list for %qs",
251 arg
->orig_option_with_args_text
);
253 gm2_new_decoded_options
[gm2_newargc
++] = *arg
;
256 /* Append an option described by OPT_INDEX, ARG and VALUE to the list
260 append_option (size_t opt_index
, const char *arg
, int value
)
262 struct cl_decoded_option decoded
;
264 generate_option (opt_index
, arg
, value
, CL_DRIVER
, &decoded
);
265 append_arg (&decoded
);
268 /* safe_strdup safely duplicates a string. */
271 safe_strdup (const char *s
)
278 /* add_default_libs adds the -l option which is derived from the
282 add_default_libs (const char *libraries
)
284 const char *l
= libraries
;
287 unsigned int libcount
= 0;
289 while ((l
!= NULL
) && (l
[0] != (char)0))
294 libname
= xstrdup (l
);
296 append_option (OPT_l
, safe_strdup (libname
), 1);
302 libname
= xstrndup (l
, e
- l
);
304 append_option (OPT_l
, safe_strdup (libname
), 1);
312 /* add_word returns a new string which has the contents of lib
313 appended to list. If list is NULL then lib is duplicated and
314 returned otherwise the list is appended by "," and the contents of
318 add_word (const char *list
, const char *lib
)
322 return xstrdup (lib
);
323 copy
= (char *) xmalloc (strlen (list
) + strlen (lib
) + 1 + 1);
330 /* convert_abbreviation checks abbreviation against known library
331 abbreviations. If an abbreviation is found it converts the element
332 to the full library name, otherwise the user supplied name is added
333 to the full_libraries list. A new string is returned. */
336 convert_abbreviation (const char *full_libraries
, const char *abbreviation
)
338 for (int i
= 0; i
< maxlib
; i
++)
339 if (strcmp (abbreviation
, library_abbrev
[i
]) == 0)
340 return add_word (full_libraries
, library_name
[i
]);
341 /* Perhaps the user typed in the whole lib name rather than an abbrev. */
342 for (int i
= 0; i
< maxlib
; i
++)
343 if (strcmp (abbreviation
, library_name
[i
]) == 0)
344 return add_word (full_libraries
, abbreviation
);
345 /* Not found, probably a user typo. */
346 error ("%qs is not a valid Modula-2 system library name or abbreviation",
348 return full_libraries
;
351 /* convert_abbreviations checks each element in the library list to
352 see if an a known library abbreviation was used. If found it
353 converts the element to the full library name, otherwise the
354 element is copied into the list. A new string is returned. */
357 convert_abbreviations (const char *libraries
)
359 const char *start
= libraries
;
361 const char *full_libraries
= NULL
;
365 end
= index (start
, ',');
368 full_libraries
= convert_abbreviation (full_libraries
, start
);
373 full_libraries
= convert_abbreviation (full_libraries
,
374 xstrndup (start
, end
- start
));
378 while ((start
!= NULL
) && (start
[0] != (char)0));
379 return full_libraries
;
382 /* add_m2_I_path appends -fm2-pathname and -fm2-pathnameI options to
383 the command line which are contructed in the saved Ipaths. */
388 for (auto np
: Ipaths
)
390 if (strcmp (np
.name
, "") == 0)
391 append_option (OPT_fm2_pathname_
, safe_strdup ("-"), 1);
393 append_option (OPT_fm2_pathname_
, safe_strdup (np
.name
), 1);
394 for (auto *s
: np
.path
)
395 append_option (OPT_fm2_pathnameI
, safe_strdup (s
), 1);
402 lang_specific_driver (struct cl_decoded_option
**in_decoded_options
,
403 unsigned int *in_decoded_options_count
,
404 int *in_added_libraries
)
406 unsigned int argc
= *in_decoded_options_count
;
407 struct cl_decoded_option
*decoded_options
= *in_decoded_options
;
410 /* True if we saw a `-xfoo' language specification on the command
411 line. This function will add a -xmodula-2 if the user has not
412 already placed one onto the command line. */
413 bool seen_x_flag
= false;
414 const char *language
= NULL
;
416 /* If nonzero, the user gave us the `-p' or `-pg' flag. */
417 int saw_profile_flag
= 0;
419 /* What action to take for the c++ runtime library:
420 -1 means we should not link it in.
421 0 means we should link it if it is needed.
422 1 means it is needed and should be linked in.
423 2 means it is needed but should be linked statically. */
426 /* Which c++ runtime library to link. */
427 stdcxxlib_kind which_library
= USE_LIBSTDCXX
;
429 const char *dialect
= DEFAULT_DIALECT
;
431 /* An array used to flag each argument that needs a bit set for
432 LANGSPEC, MATHLIB, or WITHLIBC. */
435 /* Have we seen -fmod=? */
436 char *module_extension
= NULL
;
438 /* Should the driver perform a link? */
441 /* Should the driver link the shared gm2 libs? */
442 bool shared_libgm2
= true;
444 /* "-lm" or "-lmath" if it appears on the command line. */
445 const struct cl_decoded_option
*saw_math
= NULL
;
447 /* "-lc" if it appears on the command line. */
448 const struct cl_decoded_option
*saw_libc
= NULL
;
450 /* By default, we throw on the math library if we have one. */
451 int need_math
= (MATH_LIBRARY
[0] != '\0');
453 /* 1 if we should add -lpthread to the command-line.
454 FIXME: the default should be a configuration choice. */
455 int need_pthread
= 1;
457 /* True if we saw -static. */
460 /* True if we should add -shared-libgcc to the command-line. */
461 int shared_libgcc
= 1;
463 /* Have we seen the -v flag? */
464 bool verbose
= false;
466 /* Have we seen the -fm2-pathname flag? */
467 bool seen_pathname
= false;
469 /* The number of libraries added in. */
472 /* True if we should add -fplugin=m2rte to the command-line. */
473 bool need_plugin
= false;
475 /* True if we should set up include paths and library paths. */
476 bool allow_libraries
= true;
478 #ifdef M2C_LONGREAL_PPC64LE
479 /* Should we add -mabi=ieeelongdouble by default? */
480 #ifdef M2C_LONGREAL_FLOAT128
481 bool need_default_mabi
= true;
483 bool need_default_mabi
= false;
487 #if defined(DEBUG_ARG)
488 printf ("argc = %d\n", argc
);
489 fprintf (stderr
, "Incoming:");
490 for (i
= 0; i
< argc
; i
++)
491 fprintf (stderr
, " %s", decoded_options
[i
].orig_option_with_args_text
);
492 fprintf (stderr
, "\n");
495 // add_spec_function ("m2I", add_m2_I_path);
497 gm2_x_decoded_options
= decoded_options
;
499 gm2_new_decoded_options
= decoded_options
;
500 added_libraries
= *in_added_libraries
;
501 args
= XCNEWVEC (int, argc
);
503 /* First pass through arglist.
505 If -nostdlib or a "turn-off-linking" option is anywhere in the
506 command line, don't do any library-option processing (except
509 for (i
= 1; i
< argc
; i
++)
511 const char *arg
= decoded_options
[i
].arg
;
513 #if defined(DEBUG_ARG)
514 printf ("1st pass: %s\n",
515 decoded_options
[i
].orig_option_with_args_text
);
517 switch (decoded_options
[i
].opt_index
)
535 libraries
= xstrdup (arg
);
536 allow_libraries
= decoded_options
[i
].value
;
537 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
540 module_extension
= xstrdup (arg
);
541 #if defined(DEBUG_ARG)
542 printf ("seen -fmod=%s\n", module_extension
);
546 need_pthread
= decoded_options
[i
].value
;
547 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
550 need_plugin
= decoded_options
[i
].value
;
551 #ifndef ENABLE_PLUGIN
553 error ("plugin support is disabled; configure with "
554 "%<--enable-plugin%>");
556 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
558 case OPT_fscaffold_dynamic
:
559 seen_scaffold_dynamic
= true;
560 scaffold_dynamic
= decoded_options
[i
].value
;
561 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
563 case OPT_fscaffold_static
:
564 seen_scaffold_static
= true;
565 scaffold_static
= decoded_options
[i
].value
;
566 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
568 case OPT_fscaffold_main
:
569 seen_scaffold_main
= true;
570 scaffold_main
= decoded_options
[i
].value
;
571 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
573 case OPT_fgen_module_list_
:
574 seen_gen_module_list
= true;
575 gen_module_list
= decoded_options
[i
].value
;
577 gen_module_filename
= decoded_options
[i
].arg
;
581 uselist
= decoded_options
[i
].value
;
583 case OPT_fm2_pathname_
:
584 seen_pathname
= true;
585 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
586 m2_path_name
= decoded_options
[i
].arg
;
589 args
[i
] |= SKIPOPT
; /* We will add the option if it is needed. */
590 push_back_Ipath (decoded_options
[i
].arg
);
592 #if defined(OPT_mabi_ibmlongdouble)
593 case OPT_mabi_ibmlongdouble
:
594 need_default_mabi
= false; /* User has specified a -mabi. */
597 #if defined(OPT_mabi_ieeelongdouble)
598 case OPT_mabi_ieeelongdouble
:
599 need_default_mabi
= true; /* User has specified a -mabi. */
604 case OPT_nodefaultlibs
:
609 if (strcmp (arg
, MATH_LIBRARY
) == 0)
614 else if (strcmp (arg
, "c") == 0)
617 /* Unrecognized libraries (e.g. -lfoo) may require libstdc++. */
618 library
= (library
== 0) ? 1 : library
;
637 /* Arguments that go directly to the linker might be .o files,
638 or something, and so might cause libstdc++ to be needed. */
649 case OPT_fsyntax_only
:
650 /* Don't specify libraries if we won't link, since that would
656 /* PCH makes no sense here, we do not catch -output-pch on purpose,
657 that should flag an error. */
659 case OPT_fpch_preprocess
:
660 case OPT_Winvalid_pch
:
668 case OPT_static_libgcc
:
672 case OPT_static_libstdc__
:
673 library
= library
>= 0 ? 2 : library
;
674 #ifdef HAVE_LD_STATIC_DYNAMIC
675 /* Remove -static-libstdc++ from the command only if target supports
676 LD_STATIC_DYNAMIC. When not supported, it is left in so that a
677 back-end target can use outfile substitution. */
682 case OPT_static_libgm2
:
683 shared_libgm2
= false;
684 #ifdef HAVE_LD_STATIC_DYNAMIC
685 /* Remove -static-libgm2 from the command only if target supports
686 LD_STATIC_DYNAMIC. When not supported, it is left in so that a
687 back-end target can use outfile substitution. */
693 which_library
= (stdcxxlib_kind
) decoded_options
[i
].value
;
696 case OPT_SPECIAL_input_file
:
698 const char *source_file
= decoded_options
[i
].orig_option_with_args_text
;
699 #if defined(DEBUG_ARG)
700 printf ("seen OPT_SPECIAL_input_file: %s\n", source_file
);
702 if (source_file
!= NULL
)
704 /* Record that this is a Modula-2 source file. */
705 const char *suffix
= strrchr (source_file
, '.');
706 #if defined(DEBUG_ARG)
707 printf ("ext = %s\n", suffix
);
710 && ((strcmp (suffix
, ".mod") == 0)
711 || ((module_extension
!= NULL
)
712 && (strcmp (suffix
, module_extension
) == 0))))
714 #if defined(DEBUG_ARG)
715 printf ("modula-2 source file detected: %s\n", source_file
);
727 if (language
!= NULL
&& (strcmp (language
, "modula-2") != 0))
731 /* Not seen -fm2-pathname therefore make current working directory
732 the first place to look for modules. */
733 push_back_Ipath (".");
735 /* Override the default when the user specifies it. */
736 if (seen_scaffold_static
&& scaffold_static
&& !seen_scaffold_dynamic
)
737 scaffold_dynamic
= false;
739 /* If both options have been seen and both are true, that means the user
740 tried to set both. */
741 if (seen_scaffold_dynamic
&& scaffold_dynamic
742 && seen_scaffold_static
&& scaffold_static
)
743 error ("%qs and %qs cannot both be enabled",
744 "-fscaffold-dynamic", "-fscaffold-static");
746 if (uselist
&& gen_module_list
)
748 if (! seen_gen_module_list
)
749 gen_module_list
= false;
750 if (uselist
&& gen_module_list
)
751 error ("%qs and %qs cannot both be enabled",
752 "-fgen-module-list=", "-fuse-list=");
756 /* There's no point adding -shared-libgcc if we don't have a shared
758 #ifndef ENABLE_SHARED_LIBGCC
762 /* Second pass through arglist, transforming arguments as appropriate. */
764 append_arg (&decoded_options
[0]); /* Start with command name, of course. */
765 for (i
= 1; i
< argc
; ++i
)
767 #if defined(DEBUG_ARG)
768 printf ("2nd pass: %s",
769 decoded_options
[i
].orig_option_with_args_text
);
770 if ((args
[i
] & SKIPOPT
) != 0)
772 if ((args
[i
] & M2SOURCE
) != 0)
773 printf (" m2 source");
776 if ((args
[i
] & SKIPOPT
) == 0)
778 if ((args
[i
] & M2SOURCE
) == 0)
780 append_arg (&decoded_options
[i
]);
781 /* Make sure -lstdc++ is before the math library, since libstdc++
782 itself uses those math routines. */
783 if (!saw_math
&& (args
[i
] & MATHLIB
) && library
> 0)
784 saw_math
= &decoded_options
[i
];
786 if (!saw_libc
&& (args
[i
] & WITHLIBC
) && library
> 0)
787 saw_libc
= &decoded_options
[i
];
791 if ((! seen_x_flag
) && module_extension
)
793 #if defined(DEBUG_ARG)
794 printf (" adding: -x modula-2 ");
796 append_option (OPT_x
, "modula-2", 1);
798 append_arg (&decoded_options
[i
]);
799 #if defined(DEBUG_ARG)
800 printf (" adding: %s\n",
801 decoded_options
[i
].orig_option_with_args_text
);
803 if ((! seen_x_flag
) && module_extension
)
805 #if defined(DEBUG_ARG)
806 printf (" adding: -x none ");
808 append_option (OPT_x
, "none", 1);
812 #if defined(DEBUG_ARG)
814 printf ("skipping: %s\n",
815 decoded_options
[i
].orig_option_with_args_text
);
820 /* We now add in extra arguments to facilitate a successful link.
821 Note that the libraries are added to the end of the link here
822 and also placed earlier into the link by lang-specs.h. Possibly
823 this is needed because the m2pim,m2iso libraries are cross linked
824 (--fixme-- combine all the m2 libraries into a single archive).
826 We also add default scaffold linking options. */
828 /* If we have not seen either uselist or gen_module_list and we need
829 to link or compile a module list then we turn on -fgen_module_list=-
831 if (!seen_uselist
&& !seen_gen_module_list
832 && (linking
|| scaffold_main
))
833 append_option (OPT_fgen_module_list_
, "-", 1);
835 /* We checked that they were not both enabled above, if there was a set
836 value (even iff that is 'off'), pass that to the FE. */
837 if (seen_scaffold_dynamic
|| scaffold_dynamic
)
838 append_option (OPT_fscaffold_dynamic
, NULL
, scaffold_dynamic
);
839 if (seen_scaffold_static
)
840 append_option (OPT_fscaffold_static
, NULL
, scaffold_static
);
842 /* If the user has set fscaffold-main specifically, use that. Otherwise, if
843 we are linking then set it so that we generate the relevant code for the
845 if (seen_scaffold_main
)
846 append_option (OPT_fscaffold_main
, NULL
, scaffold_main
);
848 append_option (OPT_fscaffold_main
, NULL
, true);
852 /* If the libraries have not been specified by the user, select the
853 appropriate libraries for the active dialect. */
854 if (libraries
== NULL
)
856 if (strcmp (dialect
, "iso") == 0)
857 libraries
= xstrdup ("m2iso,m2cor,m2pim,m2log");
859 /* Default to pim libraries otherwise. */
860 libraries
= xstrdup ("m2cor,m2log,m2pim,m2iso");
862 libraries
= convert_abbreviations (libraries
);
863 append_option (OPT_flibs_
, xstrdup (libraries
), 1);
866 append_option (OPT_flibs_
, xstrdup ("-"), 0); /* no system libs. */
869 append_option (OPT_fplugin_
, "m2rte", 1);
871 #ifdef M2C_LONGREAL_PPC64LE
872 if (need_default_mabi
)
873 append_option (OPT_mabi_ieeelongdouble
, NULL
, 1);
880 #ifdef HAVE_LD_STATIC_DYNAMIC
882 append_option (OPT_Wl_
, LD_STATIC_OPTION
, 1);
884 added_libraries
+= add_default_libs (libraries
);
885 #ifdef HAVE_LD_STATIC_DYNAMIC
887 append_option (OPT_Wl_
, LD_DYNAMIC_OPTION
, 1);
891 /* Add `-lstdc++' if we haven't already done so. */
892 #ifdef HAVE_LD_STATIC_DYNAMIC
893 if (library
> 1 && !static_link
)
894 append_option (OPT_Wl_
, LD_STATIC_OPTION
, 1);
896 if (which_library
== USE_LIBCXX
)
898 append_option (OPT_l
, saw_profile_flag
? LIBCXX_PROFILE
: LIBCXX
, 1);
900 if (LIBCXXABI
!= NULL
)
902 append_option (OPT_l
, saw_profile_flag
? LIBCXXABI_PROFILE
909 append_option (OPT_l
, saw_profile_flag
? LIBSTDCXX_PROFILE
913 /* Add target-dependent static library, if necessary. */
914 if ((static_link
|| library
> 1) && LIBSTDCXX_STATIC
!= NULL
)
916 append_option (OPT_l
, LIBSTDCXX_STATIC
, 1);
919 #ifdef HAVE_LD_STATIC_DYNAMIC
920 if (library
> 1 && !static_link
)
921 append_option (OPT_Wl_
, LD_DYNAMIC_OPTION
, 1);
926 append_option (OPT_l
, saw_profile_flag
? MATH_LIBRARY_PROFILE
:
932 append_option (OPT_l
, "pthread", 1);
935 if (shared_libgcc
&& !static_link
)
936 append_option (OPT_shared_libgcc
, NULL
, 1);
938 if (verbose
&& gm2_new_decoded_options
!= gm2_x_decoded_options
)
940 fprintf (stderr
, _("Driving:"));
941 for (i
= 0; i
< gm2_newargc
; i
++)
942 fprintf (stderr
, " %s",
943 gm2_new_decoded_options
[i
].orig_option_with_args_text
);
944 fprintf (stderr
, "\n");
945 fprintf (stderr
, "new argc = %d, added_libraries = %d\n",
946 gm2_newargc
, added_libraries
);
949 *in_decoded_options_count
= gm2_newargc
;
950 *in_decoded_options
= gm2_new_decoded_options
;
951 *in_added_libraries
= added_libraries
;
955 /* Called before linking. Returns 0 on success and -1 on failure. */
957 lang_specific_pre_link (void) /* Not used for M2. */
962 /* Number of extra output files that lang_specific_pre_link may generate. */
963 int lang_specific_extra_outfiles
= 0;