Hello Ian
Thank you for your reply.
Ian Lance Taylor wrote:
Jon <j...@jguk.org> writes:
Is there a way to get collect2 to save the temporary .c file it
generates to have a look at it? I believe it may be the __main()
function, with the -debug option it gives the attached
gplusplus_collect2_log.txt, looking at the [/tmp/ccyBAI9V.c] file
though it is empty, any ideas?
Using -debug will direct collect2 to save the temporary .c file when
it creates one. However, in ordinary use on GNU/Linux, collect2 will
never generate a temporary .c file.
Is there any information about how GCC start up constructors for C/C++
are generated and called before main you could point me to please. I'd
like to understand how it works.
[.]
Take a look at the config.log file to see the test that failed.
Thanks, I had ibgmp3-dev, libmpfr-dev, libmpc-dev missing. The former
is 0.7-1 in current Ubuntu, so I took from April's pre-release package
(and deps). Not sure if this has been discussed, but my feedback would
be for gcc build not to depend on packages until they are in the
mainstream distros.
I've attached collect2 patch. Let me know what you think of it.
If happy with the patch. I'll prepare another which changes all the
int 0/1 flags to be bool and true/false.
Please include my address in any replies.
Best regards, Jon
2010-02-03 Jon Grant <jg.s...@jguk.org>
* collect2.c: Handle --version as well as -v.
Likewise handle --help as well as -h.
Display Usage when --help given on command line.
vflag, debug (and additional helpflag) use bool instead of int.
Index: collect2.c
===================================================================
--- collect2.c (revision 156482)
+++ collect2.c (working copy)
@@ -174,7 +174,7 @@
int number;
};
-int vflag; /* true if -v */
+bool vflag; /* true if -v or --version */
static int rflag; /* true if -r */
static int strip_flag; /* true if -s */
static const char *demangle_flag;
@@ -193,7 +193,8 @@
/* Current LTO mode. */
static enum lto_mode_d lto_mode = LTO_MODE_NONE;
-int debug; /* true if -debug */
+bool debug; /* true if -debug */
+bool helpflag; /* true if --help */
static int shared_obj; /* true if -shared */
@@ -1228,7 +1229,7 @@
for (i = 1; argv[i] != NULL; i ++)
{
if (! strcmp (argv[i], "-debug"))
- debug = 1;
+ debug = true;
else if (! strcmp (argv[i], "-flto") && ! use_plugin)
{
use_verbose = true;
@@ -1458,7 +1459,7 @@
if (use_verbose && *q == '-' && q[1] == 'v' && q[2] == 0)
{
/* Turn on trace in collect2 if needed. */
- vflag = 1;
+ vflag = true;
}
}
obstack_free (&temporary_obstack, temporary_firstobj);
@@ -1588,7 +1589,7 @@
case 'v':
if (arg[2] == '\0')
- vflag = 1;
+ vflag = true;
break;
case '-':
@@ -1619,6 +1620,10 @@
}
else if (strncmp (arg, "--sysroot=", 10) == 0)
target_system_root = arg + 10;
+ else if (strncmp (arg, "--version", 9) == 0)
+ vflag = true;
+ else if (strncmp (arg, "--help", 9) == 0)
+ helpflag = true;
break;
}
}
@@ -1720,6 +1725,17 @@
fprintf (stderr, "\n");
}
+ if (helpflag)
+ {
+ fprintf (stderr, "collect2 is a GCC utility to arrange and call ");
+ fprintf (stderr, "various initialization functions at start time.\n");
+ fprintf (stderr, "Wrapping the linker and generating an additional ");
+ fprintf (stderr, "temporary `.c' of constructor fnctions if needed.\n");
+ fprintf (stderr, "Usage: collect2 [options]\n");
+ fprintf (stderr, " -v, --version Display version\n");
+ fprintf (stderr, " -debug Enable debug output. `gcc -Wl,-debug'\n");
+ }
+
if (debug)
{
const char *ptr;