Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 478434 - toolchain-binutils.eclass: add prefix support
Summary: toolchain-binutils.eclass: add prefix support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: prefix-gx86
  Show dependency tree
 
Reported: 2013-07-28 06:57 UTC by Benda Xu
Modified: 2013-09-30 08:08 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
toolchain-binutils.patch (toolchain-binutils.patch,6.40 KB, patch)
2013-07-28 06:58 UTC, Benda Xu
Details | Diff
toolchain-binutils.patch (toolchain-binutils.patch,5.71 KB, patch)
2013-08-12 08:15 UTC, Benda Xu
Details | Diff
toolchain-binutils.patch (toolchain-binutils.patch,4.94 KB, patch)
2013-08-17 10:41 UTC, Benda Xu
Details | Diff
toolchain-binutils.patch (toolchain-binutils.patch,5.53 KB, patch)
2013-09-29 02:41 UTC, Benda Xu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benda Xu gentoo-dev 2013-07-28 06:57:47 UTC
merge Prefix changes of toolchain-binutils.eclass

Reproducible: Always
Comment 1 Benda Xu gentoo-dev 2013-07-28 06:58:38 UTC
Created attachment 354380 [details, diff]
toolchain-binutils.patch

Prefix support including solaris and mint
Comment 2 Benda Xu gentoo-dev 2013-08-12 07:10:08 UTC
Fellows of toolchain herd, could you please have a look at the patch? They are straight forward like other prefixify efforts.

Luca, please help. Giving toolchain eclasses Prefix support will make rap easier to get included.

One exception is the TPREFIX var. I am not sure of its origin. I guess we needed it only for prefix-chaining. Correct me if I am wrong, @Fabian, @Michael.

It's okay not to include TPREFIX at this point.
Comment 3 Fabian Groffen gentoo-dev 2013-08-12 07:42:30 UTC
TPREFIX indeed stands for "Target Prefix", I remember introducing it, but not exactly what was the problem.  It had to do with cross-prefix IIRC, but since that's broken for a while -- in fact we don't support it any more, I guess we can simplify into using EPREFIX again.

A standing issue is whether or not the eclass should mangle the EPREFIX into an absolute path.  Some say not doing so results in a GCC that doesn't lookup search paths correctly, others say it works fine.  Since the bootstrap script tries to use an absolute path these days, I'd be happy with just warning, or something, but leaving the value of EPREFIX alone.
Comment 4 Benda Xu gentoo-dev 2013-08-12 08:15:20 UTC
Created attachment 355742 [details, diff]
toolchain-binutils.patch

dropped TPREFIX as per Fabian's comment.

The patch is ready to be included.
Comment 5 Luca Barbato gentoo-dev 2013-08-12 08:39:16 UTC
Looks fine, does it work with crossdev?
Comment 6 Benda Xu gentoo-dev 2013-08-12 12:50:22 UTC
(In reply to Luca Barbato from comment #5)
> Looks fine, does it work with crossdev?

Yes, because it includes all the changes in Prefix overlay.
Comment 7 Ryan Hill (RETIRED) gentoo-dev 2013-08-12 16:54:30 UTC
This needs Mike's approval to go in.
Comment 8 SpanKY gentoo-dev 2013-08-15 17:17:57 UTC
Comment on attachment 355742 [details, diff]
toolchain-binutils.patch

> 	# enable gold if available (installed as ld.gold)
>-	if use cxx ; then
>+	# PREFIX LOCAL: Linux only (fails to compile on Solaris, MiNT #353410)
>+	if [[ ${CHOST} == *-linux* ]] && use cxx ; then

imo, this should be masked in the profiles rather than encoding targets in the eclass

>+	[[ ${CHOST} == *"-solaris"* ]] && use nls && append-libs -lintl

this should be fixed in the source rather than hacked in here

>+		--infodir="${EPREFIX}"${DATAPATH}/info
>+		--mandir="${EPREFIX}"${DATAPATH}/man

does this work instead:
  --infodir='$(datadir)/info'
  --mandir='$(datadir)/man'

>+		--libexecdir="${EPREFIX}"${LIBPATH}

this would be:
  --libexecdir='$(libdir)'

>+				--with-binutils-ldscript-dir="${EPREFIX}"/${LIBPATH}/ldscripts

this would be:
  --with-binutils-ldscript-dir='$(libdir)/ldscripts'

>-	if [[ ! -e ${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
>+	if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
> 		local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
> 		choice=${choice//$'\n'/ }
> 		choice=${choice/* }
> 		if [[ -z ${choice} ]] ; then
>-			env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
>+			env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/binutils-config -u ${CTARGET}
> 		else
> 			binutils-config ${choice}
> 		fi

this doesn't make sense.  binutils-config is in $PATH and that is where we should be executing it from.

the other $D->$ED changes look fine
Comment 9 Benda Xu gentoo-dev 2013-08-17 10:33:28 UTC
(In reply to SpanKY from comment #8)
> Comment on attachment 355742 [details, diff] [details, diff]
> toolchain-binutils.patch
> 
> > 	# enable gold if available (installed as ld.gold)
> >-	if use cxx ; then
> >+	# PREFIX LOCAL: Linux only (fails to compile on Solaris, MiNT #353410)
> >+	if [[ ${CHOST} == *-linux* ]] && use cxx ; then
> 
> imo, this should be masked in the profiles rather than encoding targets in
> the eclass
> 
> >+	[[ ${CHOST} == *"-solaris"* ]] && use nls && append-libs -lintl
> 
> this should be fixed in the source rather than hacked in here
> 

kicked out.

> >+		--infodir="${EPREFIX}"${DATAPATH}/info
> >+		--mandir="${EPREFIX}"${DATAPATH}/man
> 
> does this work instead:
>   --infodir='$(datadir)/info'
>   --mandir='$(datadir)/man'
> 
> >+		--libexecdir="${EPREFIX}"${LIBPATH}
> 
> this would be:
>   --libexecdir='$(libdir)'
> 
> >+				--with-binutils-ldscript-dir="${EPREFIX}"/${LIBPATH}/ldscripts
> 
> this would be:
>   --with-binutils-ldscript-dir='$(libdir)/ldscripts'

No they don't work. This results in 

configure --infodir=$(datadir)/info ...

where bash tries to expand $(datadir) and fails.

If we pass --libexecdir=\''$(libdir)'\' to ${myconf[@]}, it results in

configure --libexecdir='$(libdir)' ...

which gives an error of 

> configure: error: expected an absolute directory name for --libexecdir: $(libdir)'

Therefore let me retain the original ugly ones.
 
> >-	if [[ ! -e ${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
> >+	if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
> > 		local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
> > 		choice=${choice//$'\n'/ }
> > 		choice=${choice/* }
> > 		if [[ -z ${choice} ]] ; then
> >-			env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
> >+			env -i ROOT="${ROOT}" "${EPREFIX}"/usr/bin/binutils-config -u ${CTARGET}
> > 		else
> > 			binutils-config ${choice}
> > 		fi
> 
> this doesn't make sense.  binutils-config is in $PATH and that is where we
> should be executing it from.

Applied.
 
> the other $D->$ED changes look fine

Thanks.
Comment 10 Benda Xu gentoo-dev 2013-08-17 10:41:41 UTC
Created attachment 356280 [details, diff]
toolchain-binutils.patch

revised patch as per comment 8
Comment 11 SpanKY gentoo-dev 2013-09-05 10:02:20 UTC
(In reply to Benda Xu from comment #9)
> > does this work instead:
> 
> No they don't work. This results in 
> 
> configure --infodir=$(datadir)/info ...
> 
> where bash tries to expand $(datadir) and fails.

i think you misread the output.  the ebuild does not expand $(datadir).  that is what using arrays and quoting things fixes.

whether the configure script itself expands things is a different story.  i'm guessing it does considering the line you posted:
> > configure: error: expected an absolute directory name for --libexecdir: $(libdir)'
Comment 12 Benda Xu gentoo-dev 2013-09-21 13:11:59 UTC
(In reply to SpanKY from comment #11)

> i think you misread the output.  the ebuild does not expand $(datadir). 
> that is what using arrays and quoting things fixes.
> 
> whether the configure script itself expands things is a different story. 
> i'm guessing it does considering the line you posted:
> > > configure: error: expected an absolute directory name for --libexecdir: $(libdir)'

Yes, you are right. The ebuild has no problem with this.

While configure do execute it, treating it as bash expression:

 * QA Notice: command not found:
 * 
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      checking for suffix of executables... checking for C compiler default output file name... /home/benda/gnto/bin/bash: line 2: datadir: command n
ot found
 *      checking for strcasecmp... /home/benda/gnto/bin/bash: line 2: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found
 *      /home/benda/gnto/bin/bash: line 4: datadir: command not found

I guess we have no cleaner way to do it than the existing one.
Comment 13 SpanKY gentoo-dev 2013-09-28 23:06:01 UTC
Comment on attachment 356280 [details, diff]
toolchain-binutils.patch

> 	cat <<-EOF > env.d
> 		TARGET="${CTARGET}"
> 		VER="${BVER}"
>-		LIBPATH="${LIBPATH}"
>+		LIBPATH="${EPREFIX}/${LIBPATH}"
> 		FAKE_TARGETS="${FAKE_TARGETS}"
> 	EOF

doesn't this result in double slashes ?  shouldn't it be just ${EPREFIX}${LIBPATH} ?
Comment 14 Benda Xu gentoo-dev 2013-09-29 02:41:12 UTC
Created attachment 359724 [details, diff]
toolchain-binutils.patch

Yes, it should. Patch refreshed.

extra: adding ED and EROOT fallback

+: ${ED:=${D}}
+: ${EROOT:=${ROOT}}
Comment 15 SpanKY gentoo-dev 2013-09-30 00:45:56 UTC
(In reply to Benda Xu from comment #14)

this looks fine.  feel free to commit.
Comment 16 Christoph Junghans (RETIRED) gentoo-dev 2013-09-30 02:28:56 UTC
+  30 Sep 2013; Christoph Junghans <ottxor@gentoo.org>
+  toolchain-binutils.eclass:
+  add prefix support
+
Comment 17 Benda Xu gentoo-dev 2013-09-30 08:08:52 UTC
Thanks Mike and Chris.