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}/Makeconf share/make/winshlib.mk included in that order. Some settings in Makeconf are substituted in etc/Makeconf by fixed/Makefile, taken from MkRules. 2) Everything else, where the primary Makefile is MkRules which is where all the customization is done. This is included by all Makefile.win files in directories above this one and ./Makefile ./fixed/Makefile ./front-ends/Makefile ./getline/Makefile ./installer/Makefile and replaces Unix's top-level Makeconf. The largest difference from Unix (even a R-shlib build) is the use of DLLs, 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 there remains provision for import libraries via lib%.dll.a: %.def rules. Making executables has a number of Windows-specific features, done in front-ends/Makefile: - A resource compiler is used to compile in version information, an icon and a manifest. Also done for version information in all the other DLLs under bin and modules (R.dll Rblas.dll Rgraphapp.dll Riconv.dll Rlapack.dll lapack.dll). - LINKFLAGS includes flags for the stack size and to allow addressing over 2GB for 32-bit executables. A resource compiler is used to add version information to the DLLs under directories bin and modules. The default is to compile without debug info: this can be enabled by using 'make DEBUG=T' from this directory, or install add-on packages with Rcmd INSTALL --debug. Otherwise DLLs and executables are stripped. Link-Time Optimization ====================== To enable LTO for building R set the LTO macro in MkRules.local, to -flto or e.g. -flto=8 to use 8 threads. Checking of packages with LTO can be performed by setting the LTO_OPT macro to -flto in MkRules.local and using Rcmd INSTALL --use-LTO. For an installed version of R it should suffice to edit the value of LTO_OPT in the etc/*/Makeconf files or to set it in a personal or site Makevars file. [Unlike a Unix-alike, LTO/LTO_OPT are used for Fortran as well as C/C++.] Cross-compilation ================= The instructions which were here were for R <= 4.1, and have not yet been rewriten for the UCRT-based build used for 4.2.