Rev 78879 | Rev 78892 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
The R for Windows Build Process===============================from the point of view of a Unix installer of R.Compilation of C/Fortran code is done in two pathways.1) standard and add-on packages, the most similar to Unix.The primary Makefiles are$(R_HOME)/etc${R_ARCH}/Makeconfshare/make/winshlib.mkincluded in that order. Some settings in Makeconf are substituted inetc/Makeconf by fixed/Makefile, taken from MkRules.2) Everything else, where the primary Makefile is MkRules which iswhere all the customization is done. This is included by allMakefile.win files under directories above this one and./Makefile./cran/Makefile./fixed/Makefile./front-ends/Makefile./getline/Makefile./installer/Makefileand replaces Unix's top-level Makeconf.The largest difference from Unix (even a R-shlib build) is the use ofDLLs, which require the exported symbols to be listed (via nm) in a.def file and fed to the compiler with the object files for linking.In recent years DLLs are linked to directly as libraries, but thereremains provision for import libraries via lib%.dll.a: %.def rules.Making executables has a number of Windows-specific features, done infront-ends/Makefile:- A resource compiler is used to compile in a manifest, which in turnincludes an icon.- LINKFLAGS includes flags for the stack size and to allow addressingover 2GB for 32-bit executables.The default is to compile without debug info: this can be enabled byusing 'make DEBUG=T' from this directory, or install add-on packageswith Rcmd INSTALL --debug. Otherwise DLLs and executables arestripped.Link-Time Optimization======================To enable LTO, set the LTO macro in MkRules.local, to -flto or e.g. -flto=8.Cross-compilation=================Linux distributions including Fedora, Debian and Ubuntu providecross-compilers and many cross-compiled librarues for both 32- and64-bit Windows. For example, on Fedora 32 for a 64-bit build onemight install RPMsmingw-binutils-genericmingw-filesystem-basemingw64-binutilsmingw64-bzip2-mingw64-bzip2-staticmingw64-cppmingw64-crtmingw64-curlmingw64-curlmingw64-filesystemmingw64-gccmingw64-gcc-c++- (not needed for R itself)mingw64-gcc-gfortranmingw64-headersmingw64-libgompmingw64-libidn2mingw64-libssh2mingw64-opensslmingw64-pcre2mingw64-pcre2-staticmingw64-pkg-configmingw64-readlinemingw64-termcapmingw64-winpthreadsmingw64-xz-libsmingw64-xz-libs-staticmingw64-zlibmingw64-zlib-static(for packages grDevices and tcltk)mingw64-libpng.noarchmingw64-libpng-static.noarchmingw64-libjpeg-turbo.noarchmingw64-libjpeg-turbo-static.noarchmingw64-libtiff.noarchmingw64-libtiff-static.noarchmingw64-cairo.noarchmingw64-cairo-static.noarchmingw64-tcl.noarchmingw64-tk.noarchor install the mingw32- variants for a 32-bit build. At the time ofwriting this used GCC 9.2.1.To build almost all the compiled code, set BINPREF in MkRules.local, e.g. toWIN = 64BINPREF64 = /usr/bin/x86_64-w64-mingw32-orWIN = 32BINPREF = /usr/bin/i686-w64-mingw32-Setting LTO is supported.Then in this directorymake MkRules rbuild rpackages-cross(Currently it does not build grDevices which need additionallibraries.)To make the cairo devices, install the appropriate RPMs, setUSE_CAIRO = TRUECAIRO_CPPFLAGS = -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/cairoCAIRO_LIBS = "-lcairo -lpixman-1 -lpng -lz -lgdi32 -lmsimg32"in MkRules.local and runmake cairodevices