[Rd] R build failure under gcc 4.9's link time optimization

2014-12-14 Thread Hin-Tak Leung
R fails to build with visibility on and gcc 4.9's link time optimzation, because
of its practice of building part of it as archive first. Specifically
it builds some bundled libraries as archive first, the symbols of which
are then entirely invisible in gcc 4.9.

The Matrix package also does this awful practice, with CHOLMOD.a COLAMD.a AMD.a 
SuiteSparse_config.a .

One way of fixing R is:

diff --git a/src/main/Makefile.in b/src/main/Makefile.in
index 908b7ab..ce015b4 100644
--- a/src/main/Makefile.in
+++ b/src/main/Makefile.in
@@ -86,7 +86,7 @@ ALL_CPPFLAGS = $(ZLIB_CPPFLAGS) $(BZLIB_CPPFLAGS) 
$(PCRE_CPPFLAGS) \
 R_ZLIBS = @BUILD_ZLIB_TRUE@ ../extra/zlib/libz.a
 R_BZLIBS = @BUILD_BZLIB_TRUE@ ../extra/bzip2/libbz2.a
 R_PCRE = @BUILD_PCRE_TRUE@ ../extra/pcre/libpcre.a
-R_TRE = @BUILD_TRE_TRUE@ ../extra/tre/libtre.a
+R_TRE = @BUILD_TRE_TRUE@ `ls ../extra/tre/*.o`
 R_XDR = @BUILD_XDR_TRUE@ ../extra/xdr/libxdr.a
 R_XZ = @BUILD_XZ_TRUE@  ../extra/xz/liblzma.a
 R_LIBINTL = @BUILD_LIBINTL_TRUE@ ../extra/intl/libintl.a

According the gcc changes doc, setting $AR is probably better. (untested).

Here is the relevant excerpt from https://gcc.gnu.org/gcc-4.9/changes.html

Link-time optimization (LTO) improvements: 
When using a linker plugin, compiling with the -flto option now generates slim 
object files (.o) which only contain intermediate language representation for 
LTO. Use -ffat-lto-objects to create files which contain additionally the 
object code. To generate static libraries suitable for LTO processing, use 
gcc-ar and gcc-ranlib; to list symbols from a slim object file use gcc-nm. 
(This requires that ar, ranlib and nm have been compiled with plugin support.)

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Significant memory leak when using XML on Windows

2014-12-14 Thread Jeroen Ooms
On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson 
wrote:
>
> I'd so much appreciate if someone could have a look at this. If I can be of
> any help whatsoever, please let me know!
>

Your current code uses various functions from XML and rvest so it is not a
*minimal* reproducible example. Even if you are unfamiliar with C, you
should be able to investigate exactly which function in the XML package you
think has issues. Once you found the problematic R function, inspect the
source code or use debug() to see if you can narrow it down even further,
preferably to a particular call to C.

Moreover you should create a reproducible example that allows us (and you)
to test if this problem appears on other systems such as OSX or linux.
Development and debugging on Windows is very painful so your windows-only
example is not too helpful. Making people use windows is not a good
strategy for getting help.

If the "leak" does not appear on other systems, it is likely a problem in
the libxml2 windows library on cran. In that case we can try to link
against another build. On the other hand, if the problem does appear across
systems, and you have provided a minimal reproducible example that
pinpoints the problematic C function, we can help you review/debug the code
C to see if/where some allocated object is not properly freed.

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Significant memory leak when using XML on Windows

2014-12-14 Thread Duncan Temple Lang
Janko and I have been in touch.
This is, I believe, a Windows specific issue and a compilation issue.
I could be wrong, but that is my impression from other reports.

When I have time (?! :-)), I will deal with it. Hopefully this will
be very soon.

Thanks Janko.

 D.


On 12/14/14, 7:54 PM, Jeroen Ooms wrote:
> On Thu, Dec 11, 2014 at 12:13 PM, Janko Thyson
> mailto:janko.thy...@gmail.com>> wrote:
> 
> I'd so much appreciate if someone could have a look at this. If I can
> be of any help whatsoever, please let me know!
> 
> 
> Your current code uses various functions from XML and rvest so it is
> not a *minimal* reproducible example. Even if you are unfamiliar with
> C, you should be able to investigate exactly which function in the
> XML package you think has issues. Once you found the problematic R
> function, inspect the source code or use debug() to see if you can
> narrow it down even further, preferably to a particular call to C.
> 
> Moreover you should create a reproducible example that allows us (and
> you) to test if this problem appears on other systems such as OSX or
> linux. Development and debugging on Windows is very painful so your
> windows-only example is not too helpful. Making people use windows is
> not a good strategy for getting help.
> 
> If the "leak" does not appear on other systems, it is likely a
> problem in the libxml2 windows library on cran. In that case we can
> try to link against another build. On the other hand, if the problem
> does appear across systems, and you have provided a minimal
> reproducible example that pinpoints the problematic C function, we
> can help you review/debug the code C to see if/where some allocated
> object is not properly freed.
> 
> 
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Significant memory leak when using XML on Windows

2014-12-14 Thread Jeroen Ooms
On Sun, Dec 14, 2014 at 8:07 PM, Duncan Temple Lang
 wrote:
>
> Janko and I have been in touch.
> This is, I believe, a Windows specific issue and a compilation issue.

If it does not appear on other systems, it might be the windows build
of libxml2 (or one of the dozens of problems that gcc warns about...).

To test, I compiled new static libraries for the latest version
(libxml2 2.9.2) and rebuilt the XML package. Janko, could try to
install this new version and see if the problem is still there? (from
the R windows menu bar, select "install from local zip file"):
http://www.stat.ucla.edu/~jeroen/xml/XML_3.98-.zip

The static libs are here in case anyone needs them:
http://www.stat.ucla.edu/~jeroen/xml/libxml2-2.9.2-mingw-w64.zip

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel