This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
improved patch to fix a POSIX compliance bug in gcc.c
- To: gcc-patches at gcc dot gnu dot org
- Subject: improved patch to fix a POSIX compliance bug in gcc.c
- From: Jens Schweikhardt <schweikh at schweikhardt dot net>
- Date: Tue, 6 Mar 2001 19:05:32 +0100
hello, world\n
once again an improvement (not to the C code) but an added
ChangeLog entry plus a patch for the texinfo doc. I hope this
satifies the requirements to get this patch committed. If there
is something wrong with it or missing *please* let me know.
Regards,
Jens
ChangeLog:
* gcc.c (process_command): Allow -l lib in addition to -llib
for POSIX compliance.
* invoke.texi: update section on Link Options accordingly.
--- gcc.c.orig Fri Feb 9 22:22:06 2001
+++ gcc.c Sat Feb 10 09:50:47 2001
@@ -3290,6 +3290,14 @@
n_infiles++;
i++;
}
+ else if (strcmp (argv[i], "-l") == 0)
+ {
+ if (i + 1 == argc)
+ fatal ("argument to `-l' is missing");
+
+ n_infiles++;
+ i++;
+ }
else if (strncmp (argv[i], "-l", 2) == 0)
n_infiles++;
else if (strcmp (argv[i], "-save-temps") == 0)
@@ -3730,6 +3738,14 @@
{
infiles[n_infiles].language = "*";
infiles[n_infiles++].name = argv[++i];
+ }
+ else if (strcmp (argv[i], "-l") == 0)
+ { /* POSIX allows separation of -l and the lib arg;
+ canonicalize by concatenating -l with its arg */
+ register char *libarg = xmalloc (3 + strlen (argv[++i]));
+ sprintf (libarg, "-l%s", argv[i]);
+ infiles[n_infiles].language = "*";
+ infiles[n_infiles++].name = libarg;
}
else if (strncmp (argv[i], "-l", 2) == 0)
{
--- invoke.texi.old Sun Mar 4 18:25:35 2001
+++ invoke.texi Sun Mar 4 18:52:17 2001
@@ -3604,10 +3604,13 @@
@cindex Libraries
@item -l@var{library}
-Search the library named @var{library} when linking.
+@itemx -l @var{library}
+Search the library named @var{library} when linking. (The second
+alternative with the library as a separate argument is only for
+POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the
-linker searches processes libraries and object files in the order they
+linker searches and processes libraries and object files in the order they
are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
to functions in @samp{z}, those functions may not be loaded.