From hin-tak.leung at cimr.cam.ac.uk  Mon Jan 15 19:49:35 2007
From: hin-tak.leung at cimr.cam.ac.uk (Hin-Tak Leung)
Date: Mon, 15 Jan 2007 18:49:35 +0000
Subject: [Rd] mingw-cross with R 2.4.x Re: wine and build difference between
 R.2.4.0 and R 2.4.1 windows binaries?
In-Reply-To: <45A7D2C3.1050204@cimr.cam.ac.uk>
References: <45A53E92.6070104@cimr.cam.ac.uk>
	<45A545B1.6070508@stats.uwo.ca>	<45A6250C.3020802@cimr.cam.ac.uk>
	<45A629E0.8090100@stats.uwo.ca>	<45A79EB8.8010606@cimr.cam.ac.uk>	<Pine.LNX.4.64.0701121446340.11132@gannet.stats.ox.ac.uk>	<45A7BF93.1090109@cimr.cam.ac.uk>
	<45A7CE6F.2050103@stats.uwo.ca> <45A7D2C3.1050204@cimr.cam.ac.uk>
Message-ID: <45ABCCBF.3080204@cimr.cam.ac.uk>

Hin-Tak Leung wrote:
<snipped>
> 2.4.0 works and 2.4.1/2.5dev crashes, all on the same machine with
> the same version of wine in en_GB.UTF-8 locale.
> 
> export |grep 'LANG'
> declare -x LANG="en_GB.UTF-8"
> 
> I found all 3 versions of Rgui.exe hangs (and not crashes) if I run
> wine under LANG=C .
> 
> I think it would be most interesting to try building the older 2.4.0
> with newer mingw - that would distinguish whether it is code change
> in R or change in mingw. (I'll give this a try in the next few days).

I have managed to build both R 2.4.0 and 2.4.1 with the newer
mingw 3.11+ (both crashes under wine and works okay under XP)
and can now confirm that the wine crash seems to be due to mingw change.

Some comments, notes below, in case it may be useful to others (and
also a good reminder for myself as well):

- building the cross-compiler itself was relatively easy with the
   latest cross-build script from mingw, except by default it doesn't do
   the bleeding-edge component versions.

My /usr/bin/R is 32-bit 2.4.1 and my /usr/bin/R64 is 64-bit 2.4.0 -
so I can cross-build two different versions of R. (cross-build R 
requires the *exact same* version of native R).

binutils-2.17.50-20060824-1-src.tar.gz
gcc-ada-3.4.5-20060117-1-src.tar.gz
gcc-core-3.4.5-20060117-1-src.tar.gz
gcc-g++-3.4.5-20060117-1-src.tar.gz
gcc-g77-3.4.5-20060117-1-src.tar.gz
gcc-java-3.4.5-20060117-1-src.tar.gz
gcc-objc-3.4.5-20060117-1-src.tar.gz
mingw-runtime-3.11-20061202-1-src.tar.gz
w32api-3.8-src.tar.gz

- Although http://www.murdoch-sutherland.com/Rtools/ states
that mingw-runtime-3.11 is required, there was a bug with
mingw-runtime-3.11-src.tar.gz for cross-build. (20061202 is
a post-release fix which wasn't much advertised as such). The nature
of the problem about GCC_NO_EXECUTABLES was discussed in this thread:
http://www.arcknowledge.com/gmane.comp.gnu.mingw.devel/2006-11/threads.html#00029

- I needed to copy R/src/intl and R/src/extra/pcre from 2.4.1 to 2.4.0
to get the older R 2.4.0 to build against newer mingw.

- for both versions, symbol export doesn't work and a big chunk
   of R won't link; my initial work around was to stick
    "-Wl,--export-all-symbols" (...barbaric...) to get some executable
    to link.
   later I worked out the proper way is to do
     export NM=/path-to/bin/i386-mingw32-nm
   and also edit the R/src/gnuwin32/Makefile and replaces the two lines
   of this portion of sed code (8 dots):
      $(SED) -n 's/^........ [BCDRT] _/ /p'
   with this (16 dots):
       $(SED) -n 's/^................ [BCDRT] _/ /p'

It seems that the SED change is in R trunk (with "s/^.* ...").
and the NM export is probably not necessary and due to
my mistake somewhere on dependency generation, as Mkrules does
make NM=$(BINPREF)nm .



[Rd] mingw-cross with R 2.4.x Re: wine and build difference between R.2.4.0 and R 2.4.1 windows binaries?
Hin-Tak Leung