[R-pkg-devel] Is there an Rtools40 changelog?

James Lamb j@y|@mb20 @end|ng |rom gm@||@com
Thu May 14 04:45:53 CEST 2020


Thank you very much for the help!

This definitely answered my question. I wasn't familiar with pacman before.

For the curious, I've had success generating a .def file from R.dll with
*objdump.exe*, a utility that exists in prior Rtools distributions and
the current ones. With something like the R code below.

```r
# [description]
#     Create a definition file (.def) from a .dll file, using objdump.
#
# [usage]
#
#     Rscript make-r-def.R something.dll something.def
#
# [references]
#    * https://www.cs.colorado.edu/~main/cs1300/doc/mingwfaq.html

args <- commandArgs(trailingOnly = TRUE)

IN_DLL_FILE <- args[[1L]]
OUT_DEF_FILE <- args[[2L]]
DLL_BASE_NAME <- basename(IN_DLL_FILE)

print(sprintf("Creating '%s' from '%s'", OUT_DEF_FILE, IN_DLL_FILE))

# use objdump to dump all the symbols
OBJDUMP_FILE <- "objdump-out.txt"
exit_code <- system2(
    command = "objdump"
    , args = c(
        "-p"
        , shQuote(IN_DLL_FILE)
    )
    , stdout = OBJDUMP_FILE
)

objdump_results <- readLines(OBJDUMP_FILE)
result <- file.remove(OBJDUMP_FILE)

# Only one table in the objdump results matters for our purposes,
# see https://www.cs.colorado.edu/~main/cs1300/doc/mingwfaq.html
start_index <- which(
    grepl(
        pattern = "[Ordinal/Name Pointer] Table"
        , x = objdump_results
        , fixed = TRUE
    )
)
empty_lines <- which(objdump_results == "")
end_of_table <- empty_lines[empty_lines > start_index][1L]

# Read the contents of the table
exported_symbols <- objdump_results[(start_index + 1L):end_of_table]
exported_symbols <- gsub("\t", "", exported_symbols)
exported_symbols <- gsub(".*\\] ", "", exported_symbols)
exported_symbols <- gsub(" ", "", exported_symbols)

# Write R.def file
writeLines(
    text = c(
        paste0("LIBRARY \"", DLL_BASE_NAME, "\"")
        , "EXPORTS"
        , exported_symbols
    )
    , con = OUT_DEF_FILE
    , sep = "\n"
)
```

On Tue, May 12, 2020 at 2:39 AM Jeroen Ooms <jeroenooms using gmail.com> wrote:

> On Sun, May 10, 2020 at 11:31 PM James Lamb <jaylamb20 using gmail.com> wrote:
> >
> > Hello,
> >
> > I am a maintainer on the LightGBM project, focused on that project's R
> > package. The R package is not available on CRAN yet (we are working on
> it),
> > so for now our users must build it from source.
> >
> > The package includes compilation of a C++ library, and we link to R.dll /
> > R.so to use R-provided functions like Rprintf.
> >
> > With the release of R4.0 and Rtools40, we recently received reports from
> > our users that they are unable to build our package on Windows systems
> with
> > R 4.0 and Rtools 4.0 (https://github.com/microsoft/LightGBM/issues/3064
> ).
> >
> > After some investigation, I've learned that the following changes in
> > Rtools40 (relative to Rtools35) broke our installation process:
> >
> >    - *gendef.exe* was removed
> >    - *mingw32-make.exe* was removed
> >    - paths like "mingw_64/bin" were changed to "mingw64/bin"
> >
>
> Some utilities that were previously bundled with all rtools
> installations can now be installed with the package manager.
>
> To install gendef use:
>
>      pacman -S mingw-w64-{i686,x86_64}-tools
>
> To install mingw32-make.exe use:
>
>       pacman -S mingw-w64-{i686,x86_64}-make
>
> To install both of the at once you can use:
>
>       pacman -S mingw-w64-{i686,x86_64}-{tools,make}
>
> Note that it's often better to use 'make.exe' which is included with
> all rtools installations instead of mingw32-make.exe.
>
> These changes were a result of switching to an msys2 based toolchain.
> The default rtools40 installer only includes the things needed to
> build CRAN packages or base-R. Extra stuff such as system libraries,
> debuggers, cmake, etc, are all optionally available via the package
> manager.
>


-- 
James Lamb
GitHub <https://github.com/jameslamb> | Twitter
<https://twitter.com/_jameslamb> | LinkedIn
<https://www.linkedin.com/in/jameslamb1/>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list