This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
collect2 library file extension search order (PR target/18720)
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 09 Jan 2005 17:12:26 -0500
- Subject: collect2 library file extension search order (PR target/18720)
On AIX, the -brtl linker option to enable runtime linking changes
the ordering of shared library file extensions to search for ".so" before
".a". This patch changes the AIX-only portion of GCC's collect2 linker
wrapper to match that behavior.
Bootstrapped and regression tested on powerpc-ibm-aix5.2.0.0. Committed
to mainline.
I will bootstrap with GCC-3.4 branch and commit there when successful.
David
PR target/18720
* collect2.c (main): Set aixrtl_flag for -brtl option.
(resolve_lib_name): Search for .so file extension before .a
if aixrtl_flag set.
Index: collect2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/collect2.c,v
retrieving revision 1.167
diff -c -p -r1.167 collect2.c
*** collect2.c 9 Nov 2004 10:12:15 -0000 1.167
--- collect2.c 9 Jan 2005 21:57:18 -0000
*************** static const char *demangle_flag;
*** 185,190 ****
--- 185,191 ----
#ifdef COLLECT_EXPORT_LIST
static int export_flag; /* true if -bE */
static int aix64_flag; /* true if -b64 */
+ static int aixrtl_flag; /* true if -brtl */
#endif
int debug; /* true if -debug */
*************** static struct path_prefix cmdline_lib_di
*** 242,248 ****
static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */
static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
&libpath_lib_dirs, NULL};
- static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extensions */
#endif
static void handler (int);
--- 243,248 ----
*************** main (int argc, char **argv)
*** 1087,1092 ****
--- 1087,1094 ----
export_flag = 1;
else if (arg[2] == '6' && arg[3] == '4')
aix64_flag = 1;
+ else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l')
+ aixrtl_flag = 1;
break;
#endif
*************** resolve_lib_name (const char *name)
*** 2594,2599 ****
--- 2596,2603 ----
{
char *lib_buf;
int i, j, l = 0;
+ /* Library extensions for AIX dynamic linking. */
+ const char * const libexts[2] = {"a", "so"};
for (i = 0; libpaths[i]; i++)
if (libpaths[i]->max_len > l)
*************** resolve_lib_name (const char *name)
*** 2612,2625 ****
const char *p = "";
if (list->prefix[strlen(list->prefix)-1] != '/')
p = "/";
! for (j = 0; libexts[j]; j++)
{
sprintf (lib_buf, "%s%slib%s.%s",
! list->prefix, p, name, libexts[j]);
! if (debug) fprintf (stderr, "searching for: %s\n", lib_buf);
if (file_exists (lib_buf))
{
! if (debug) fprintf (stderr, "found: %s\n", lib_buf);
return (lib_buf);
}
}
--- 2616,2630 ----
const char *p = "";
if (list->prefix[strlen(list->prefix)-1] != '/')
p = "/";
! for (j = 0; j < 2; j++)
{
sprintf (lib_buf, "%s%slib%s.%s",
! list->prefix, p, name,
! libexts[(j + aixrtl_flag) % 2]);
! if (debug) fprintf (stderr, "searching for: %s\n", lib_buf);
if (file_exists (lib_buf))
{
! if (debug) fprintf (stderr, "found: %s\n", lib_buf);
return (lib_buf);
}
}