Re: [PATCH] collect2 should accept more AIX linker flags to change shared library search order

2013-02-05 Thread Michael Haubenwallner

On 02/04/2013 10:33 PM, David Edelsohn wrote:
> 2013-02-04  Michael Haubenwallner 
> 
>   Accept all flags that enable aix runtime linking to change the
>   library search order. Also there is a disabling flag.

> This patch is okay, and I agree that it should use strncmp.

Updated to use strcmp/strncmp. While at it, also check for "-bexport:" instead
of "-bexport", as this (and "-bE:") always needs the filename anyway.

> Do you have SVN write access?

Nope.

Thank you!
/haubi/
2013-02-05  Michael Haubenwallner 

	Accept all flags that enable aix runtime linking to change the
	library search order. Also there is a disabling flag.
	* collect2.c (aixrtl_flag): Enabled by -G and -bsvr4 too, disabled
	by -bnortl. Use strcmp,strncmp for all these aix flags too. And
	-bexport always needs the filename, so test for '-bexport:'.
---
 gcc/collect2.c |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index 0db908f..99dd41d 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -1022,20 +1022,20 @@ main (int argc, char **argv)
 	  selected_linker = USE_GOLD_LD;
 
 #ifdef COLLECT_EXPORT_LIST
-	/* since -brtl, -bexport, -b64 are not position dependent
-	   also check for them here */
-	if ((argv[i][0] == '-') && (argv[i][1] == 'b'))
-  	  {
-	arg = argv[i];
-	/* We want to disable automatic exports on AIX when user
-	   explicitly puts an export list in command line */
-	if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
-	  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;
-	  }
+	/* These flags are position independent, although their order
+	   is important - subsequent flags override earlier ones. */
+	else if (strcmp (argv[i], "-b64") == 0)
+	aix64_flag = 1;
+	/* -bexport:filename always needs the :filename */
+	else if (strncmp (argv[i], "-bE:", 4) == 0
+	  || strncmp (argv[i], "-bexport:", 9) == 0)
+	export_flag = 1;
+	else if (strcmp (argv[i], "-brtl") == 0
+	  || strcmp (argv[i], "-bsvr4") == 0
+	  || strcmp (argv[i], "-G") == 0)
+	aixrtl_flag = 1;
+	else if (strcmp (argv[i], "-bnortl") == 0)
+	aixrtl_flag = 0;
 #endif
   }
 vflag = debug;
-- 
1.7.3.4



Re: [PATCH] collect2 should accept more AIX linker flags to change shared library search order

2013-02-04 Thread David Edelsohn
2013-02-04  Michael Haubenwallner 

Accept all flags that enable aix runtime linking to change the
library search order. Also there is a disabling flag.
* collect2.c (aixrtl_flag): Enabled by -G and -bsvr4 too. Disabled
by -bnortl. No false positive on -brtllib or -bnortllib.


This patch is okay, and I agree that it should use strncmp.

Do you have SVN write access?

Thanks, David


Re: [PATCH] collect2 should accept more AIX linker flags to change shared library search order

2013-02-04 Thread Ian Lance Taylor
On Mon, Feb 4, 2013 at 5:56 AM, Michael Haubenwallner
 wrote:
>
> when using "-shared -Wl,-G" to create AIX shared libraries for use with 
> runtime linking,
> without also using "-Wl,-brtl" collect2 still does search for lib.a before 
> lib.so,
> eventually registering global constructors found in static lib.a, which are 
> not exported
> by lib.so, so the subsequent link step fails resolving these symbols.

This is OK if it's OK with the AIX maintainers (do we have any AIX
maintainers?  dje?).

I'll also preapprove a patch to use strcmp and strncmp here, I have no
idea why this code is checking character by character.

Ian