Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 499356 - dev-lang/R problems with custom USE flags
Summary: dev-lang/R problems with custom USE flags
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-26 14:46 UTC by Michael Schubert
Modified: 2014-04-07 20:08 UTC (History)
1 user (show)

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


Attachments
R-3.0.2.ebuild patch (R-3.0.2.ebuild.patch,1011 bytes, patch)
2014-02-10 22:03 UTC, Michael Schubert
Details | Diff
R-3.0.2.ebuild patch (R-3.0.2.ebuild.patch,1011 bytes, patch)
2014-02-10 22:06 UTC, Michael Schubert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schubert 2014-01-26 14:46:53 UTC
(a) dev-lang/R with USE=tk is not using prefix path for tcl/tkConfig.sh

(Upstream report: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=15647)

If I run:

    ./configure --libdir=/some/prefix --with-tcltk

I would expect that that "checking for *.sh" in library (sub)directories searches in ${libdir} before any other guessed locations. However, it does not:

    checking for tclConfig.sh... no
    checking for tclConfig.sh in library (sub)directories...  /usr/lib64/tclConfig.sh
    checking for tkConfig.sh... no
    checking for tkConfig.sh in library (sub)directories... /usr/lib64/tkConfig.sh

(here, ${libdir} was /some/prefix and the files found were some outside)

I'd consider this (i.e., that Gentoo provides --libdir and R does not search it for the config files) an R bug and reported it there, but this may take a while to be fixed, if at all.

Workaround patch:
--- configure.ac.orig    2014-01-24 23:14:46.151754852 +0000
+++ configure.ac 2014-01-24 23:14:31.946442971 +0000
@@ -380,11 +380,11 @@ fi],
 AC_ARG_WITH([tcl-config],
 [AS_HELP_STRING([--with-tcl-config=TCL_CONFIG],[specify location of tclConfig.sh @<:@@:>@])],
 [TCL_CONFIG="${withval}"],
-[TCL_CONFIG=""])
+[TCL_CONFIG="${libdir}/tclConfig.sh"])
 AC_ARG_WITH([tk-config],
 [AS_HELP_STRING([--with-tk-config=TK_CONFIG],[specify location of tkConfig.sh @<:@@:>@])],
 [TK_CONFIG="${withval}"],
-[TK_CONFIG=""])
+[TK_CONFIG="${libdir}/tkConfig.sh"])


(b) --with-blas= requires directory, but pkg-config from ebuild provides the linker flags

If I run:

    ./configure --libdir=/some/prefix --with-blas

the configure call is:

    configure --with-blas=-L/path/to/usr/lib/blas/reference -lblas

when it should be:

    configure --with-blas=/path/to/usr/lib/blas/reference

Patch:
--- R-3.0.2.ebuild.orig	2014-01-26 14:38:09.707069380 +0000
+++ R-3.0.2.ebuild	2014-01-26 14:21:27.221276947 +0000
@@ -82,6 +82,8 @@ src_prepare() {
 	# https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14953
 	epatch "${FILESDIR}"/${PN}-3.0.0-rmath-shared.patch
 
+	epatch "${FILESDIR}"/${PN}-3.0.2-tcltk.patch
+
 	# fix packages.html for doc (gentoo bug #205103)
 	sed -i \
 		-e "s:../../../library:../../../../$(get_libdir)/R/library:g" \
@@ -139,7 +141,7 @@ src_configure() {
 		--with-system-bzlib \
 		--with-system-pcre \
 		--with-system-xz \
-		--with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
+		--with-blas="$($(tc-getPKG_CONFIG) --libs-only-L blas | sed 's:^-L::')" \
 		--docdir="${EPREFIX}/usr/share/doc/${PF}" \
 		rdocdir="${EPREFIX}/usr/share/doc/${PF}" \
 		$(use_enable nls) \
Comment 1 Benda Xu gentoo-dev 2014-01-26 22:37:32 UTC
Thanks, mschu. I can confirm the bug.

I think libdir is used for R to install to, not for the configure to search for libraries. Will --with-tcltk=/path/to/tclck do?

Not sure if there is a cleaner solution for blas.
Comment 2 Michael Schubert 2014-01-26 22:49:13 UTC
For Tcl/Tk,

--with-tk-config=/path/to/tkConfig.sh --with-tcl-config=/path/to/tclConfig.sh

will work.

For BLAS,

--with-blas="$($(tc-getPKG_CONFIG) --variable=libdir blas)"

would also work.
Comment 3 Michael Schubert 2014-01-26 23:12:23 UTC
Sorry, I realized I did not answer your question.

--with-tcltk=$EPREFIX/usr/lib

does not work.
Comment 4 Benda Xu gentoo-dev 2014-01-26 23:41:33 UTC
(In reply to Michael Schubert from comment #2)
> For Tcl/Tk,
> 
> --with-tk-config=/path/to/tkConfig.sh --with-tcl-config=/path/to/tclConfig.sh
> 
> will work.
> 
> For BLAS,
> 
> --with-blas="$($(tc-getPKG_CONFIG) --variable=libdir blas)"
> 
> would also work.

Let's patch it like this then.
Comment 5 Michael Schubert 2014-02-10 22:03:47 UTC
Created attachment 370102 [details, diff]
R-3.0.2.ebuild patch

Fixes for blas cflags instead of libdir and using prefix tcl/tk-config.

Tested on RHEL host. configure with blas and USE +/- tk are clean.
Comment 6 Michael Schubert 2014-02-10 22:06:27 UTC
Created attachment 370104 [details, diff]
R-3.0.2.ebuild patch

CORRECTION: applied in the right direction
Comment 7 Benda Xu gentoo-dev 2014-02-17 12:36:16 UTC
Thanks Michael, commited. Please find my updated patch below, leveraging use_with. Enjoy!

./ChangeLog
+  17 Feb 2014; Benda Xu <heroxbd@gentoo.org> R-3.0.2.ebuild:
+  Pass correct blas path to configure, pass {tk,tcl}-config scripts to configure
+  explicitly for Prefix. Credits to Michael Schubert, bug 499356.
+


@@ -157,6 +157,8 @@
                $(use_with readline) \
                $(use_with tiff libtiff) \
                $(use_with tk tcltk) \
+               $(use_with tk tk-config "${EPREFIX}"/usr/lib/tkConfig.sh) \
+               $(use_with tk tcl-config "${EPREFIX}"/usr/lib/tclConfig.sh) \
                $(use_with X x)
 }
Comment 8 Benda Xu gentoo-dev 2014-04-07 11:46:54 UTC
The --with-blas change is not seriously reflected upon. I am going to revert it as pointed out by  Robert McGehee on bug 505904.
Comment 9 Michael Schubert 2014-04-07 11:59:38 UTC
The fix was needed and did work when I submitted it.

If I'm not mistaken, gentoo BLAS changed in the meantime to no longer link libblas.so to the BLAS currently eselected, but have pkg-config take care linking the right one.

I played around with this a while ago and could not get R to link the right BLAS without explicitly re-introducing the symlink. I'll have another look later today, but I suspect the fix will be more complicated than just reverting.
Comment 10 Benda Xu gentoo-dev 2014-04-07 12:04:45 UTC
Michael, if you have trouble configuring the correct blas library, please file a bug on the corresponding blas implementation. We (science herd) are in a transition into a new framework of blas, there might be such glitches. My Prefix outputs:

$ pkg-config --libs blas
-lrefblas

after all.
Comment 11 Benda Xu gentoo-dev 2014-04-07 12:08:55 UTC
(In reply to Michael Schubert from comment #9)
> The fix was needed and did work when I submitted it.
> 
> If I'm not mistaken, gentoo BLAS changed in the meantime to no longer link
> libblas.so to the BLAS currently eselected, but have pkg-config take care
> linking the right one.
> 
> I played around with this a while ago and could not get R to link the right
> BLAS without explicitly re-introducing the symlink. I'll have another look
> later today, but I suspect the fix will be more complicated than just
> reverting.

Yes, it might be more complicated than my first thought. What blas are you using?
Comment 12 Michael Schubert 2014-04-07 20:08:58 UTC
I am using openblas from ::science.

I can confirm linking of openblas works with R 3.0.3 and the original pkg-config --libs, so I second reverting for the current version of R (I did not re-test with 3.0.2 but I can recall it not working - however, that was with the old blas structure).