Subject: Re: How Buildlink3 handles -Xlinker
To: Masao Uebayashi <uebayasi@pultek.co.jp>
From: Johnny C. Lam <jlam@NetBSD.org>
List: tech-pkg
Date: 03/13/2004 15:15:22
--lrZ03NoBR/3+SXJZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Mar 13, 2004 at 01:16:49PM +0900, Masao Uebayashi wrote:
> 
> I found converting all "-Xlinker xxx" into "-Wl,xxx" with stripping
> "-Wl," in "xxx" in marshalling phase works.
> 
> I admit this process is more than what marshall phase should does, and
> messing up things a bit, but I can't find any other better place to
> process two sequencial arguments in Buildlink3.

Please try the following patch instead.  It's more complete in how it
handles the equivalence between "-Xlinker" and "-Wl,", as well as being
tolerant of errors like "-Xlinker -Wl,*".

Please note that I won't be able to commit this patch to pkgsrc during
the freeze as it's infrastructure-related and could potentially affect
a slew of packages.  I'll look into committing it after the 2004Q1
branch is released.

	Cheers,

	-- Johnny Lam <jlam@NetBSD.org>

--lrZ03NoBR/3+SXJZ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Xlinker.diff"

Index: marshall
===================================================================
RCS file: /cvsroot/pkgsrc/mk/buildlink3/marshall,v
retrieving revision 1.9
diff -u -r1.9 marshall
--- marshall	13 Feb 2004 16:49:53 -0000	1.9
+++ marshall	13 Mar 2004 15:09:58 -0000
@@ -17,17 +17,36 @@
 # Merge "-Wl,R -Wl,/path/to/dir" into a single argument
 # "-Wl,R/path/to/dir" and merge "-Wl,--rpath -Wl,/path/to/dir" into
 # "-Wl,--rpath,/path/to/dir" so that we can look them up in the cache.
+# Also deal with "-Xlinker" being equivalent to "-Wl,".
 #
--Wl,-R)
-	nextarg=`$echo "X$1" | $Xsed -e "s|^-Wl,||g"`
-	arg="$arg$nextarg"
-	shift
-	;;
--Wl,-rpath|-Wl,-rpath-link|\
--Wl,--rpath|-Wl,--rpath-link)
-	nextarg=`$echo "X$1" | $Xsed -e "s|^-Wl,||g"`
-	arg="$arg,$nextarg"
-	shift
+-Xlinker|-Wl,-R|-Wl,-rpath|-Wl,-rpath-link|-Wl,--rpath|-Wl,--rpath-link)
+	R=
+	case $arg in
+	-Xlinker)
+		case $1 in
+		-Wl,-R)				R="$1";	     shift ;;
+		-Wl,-rpath|-Wl,-rpath-link)	R="$1,";     shift ;;
+		-Wl,--rpath|-Wl,--rpath-link)	R="$1,";     shift ;;
+		-Wl,*)				arg="$1";    shift ;;
+		-R)				R="-Wl,$1";  shift ;;
+		-rpath|-rpath-link)		R="-Wl,$1,"; shift ;;
+		--rpath|--rpath-link)		R="-Wl,$1,"; shift ;;
+		esac
+		;;
+	-Wl,-R)					R="$arg"  ;;
+	-Wl,-rpath|-Wl,-rpath-link)		R="$arg," ;;
+	-Wl,--rpath|-Wl,--rpath-link)		R="$arg," ;;
+	esac
+	if $test -n "$R"; then
+		nextarg=$1; shift
+		case $nextarg in
+		-Xlinker)  nextarg=$1; shift ;;
+		esac
+		case $nextarg in
+		-Wl,*)	nextarg=`$echo "X$nextarg" | $Xsed -e "s|^-Wl,||g"` ;;
+		esac
+		arg="$R$nextarg"
+	fi
 	;;
 #
 # If we're linking a shared library by "cc -shared -o /srcdir/shlib",

--lrZ03NoBR/3+SXJZ--