-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R-package] Add support for R 4.0 (fixes #3064, fixes #3024) #3065
Conversation
@jameslamb Great efforts! Thanks a lot!
Is there any available discussion or reason a least why they did it? Or it was done without public discussion? Maybe you know. |
I don't know of any, but the fact that I don't know doesn't mean it was done without public discussion. I haven't had much luck using search engines and these changes are not mentioned at the official Rtools40 page, so I just posted a message to the message sent to `r-package-devel`
I am going to keep working on this, so we can unblock users who've started upgrading to R 4.0. |
Got a response to the email I sent to the The full response is included below. My takeaways:
Full response
|
Makes sense!
Absolutely agree with you! (But I'm not an R maintainer!) |
@jameslamb Found the following note in CMake docs. Just want to let you know.
|
36813b7
to
8342c27
Compare
🤒 yep thank you for sharing this. I've been experimenting with it tonight and found that to be true. That really complicates things. I think until the package is on CRAN, we need to keep up with the changes in the R toolchain in That means
|
@jameslamb |
In my proposal, if you set If a user does that with Rtools35, it will "just work" because those tools are bundled in Rtools35. If a user does that on R4.0, they will be responsible for making sure there is a Does that make sense? |
Those are all files created from the unit tests or examples. I think that to keep this PR's size from growing (so that it can be reviewed more quickly), we should just bump the allowed NOTEs to 4 here, then have a followup PR that removes it and sets allowed NOTEs back to 3. |
@guolinke @StrikerRUS ok I have this passing all CI, and I've added GitHub Actions jobs for R 4.0. Could you please give this a review when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameslamb Great work as always!
Left some very minor comments below:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add R version to the name for fast navigation from a PR page:
LightGBM/.github/workflows/main.yml
Line 13 in ce95d9c
name: ${{ matrix.task }} (${{ matrix.os }}, ${{ matrix.compiler }}) |
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
fixed in c65a910 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments based on the latest changes.
R-package/README.md
Outdated
As of `Rtools` 4.0, some common paths changed and software was removed from `Rtools`. If you are using `R` 4.0 or later and the corresponding `Rtools`, you need to add one additional path to `PATH`. | ||
|
||
* `Rtools` usr bin: | ||
- example: `C:\Rtools\usr\bin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just add this path to the case If you have `Rtools` 4.0, example:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh I thought I did that already! sorry, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! now I remember. That section you're referring to is documenting how the R package will fall back to msys2 if you don't have Visual Studio.
Adding this /usr/bin
path is important specifically for the case of Visual Studio (the default), because that path is where objdump.exe
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooooooooh I misunderstood! Yes you're right, ok those two are definitely duplicates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost missed this one, sorry! Just fixed this in d0e995f.
I also added one more fix in that commit noticed during testing...if using system2()
instead of {processx}
, you have to shQuote(args)
in because on of the args is a file path to R.dll
, which might have spaces. This isn't necessary with {processx}
because it does that quoting for you on Windows.
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope we can change it too, but I really think it's necessary to have those jobs since R 4.0 is so new. Once we merge this I will try again with GitHub Actions and Windows.
I think that when @guolinke made the 4 GitHub Actions steps from #3119 required, the mechanism in GitHub is to store the job names. So now that we have new names, GitHub thinks 8 non-required things have run and 4 required things have not yet run. I think the solution will be that once we merge this, the set of required checks needs to be updated. That will have to be done again whenever I manage to move the Windows R jobs, and at least one more time when we introduce CRAN builds (which I am waiting to do until this PR is finalized and merged). After those things, we should be changing CI jobs much less frequently and focusing on the actual contents of the library. |
Thanks as always for the thorough review @StrikerRUS ! @guolinke can you please review when you have time? I would like an approval from an R maintainer before this is merged. |
@guolinke apologies for bothering you...since you are the only admin (I think) on the repo, we'll need your help to merge this. The set of required GitHub Actions tasks needs to change since the names of the GitHub Actions tasks have changed: #3065 (comment) I think you will need to use administrator privileges to merge this pull request, then go into the repo's settings and change the set of required tasks. Sorry for the inconvenience, it is one of the annoying things about GitHub Actions :/ |
@jameslamb no problem! |
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Experimental fix for #3064. Opening this PR to show the way I'm thinking about adding support for R 4.0. I will remove the
[WIP]
and request reviewers when it's ready for review, but any comments before then are welcomed if you have time!R4.0 breaking changes that affect LightGBM
gendef.exe
removed from Rtools 😭mingw32-make.exe
is no longer bundled withRtools
😭Rtools
paths removed underscores, somingw_64/
becomesmingw64/
😂Short description of the fix
gendef.exe fix
Building the
LightGBM
R package on Windows with Visual Studio compilers requiresgendef.exe
. That was bundled in previous versions ofRTools
but isn't part ofRtools
4.0.This PR replaces it with an R script that uses
objdump.exe
, software bundled in old and new distributions ofRtools
.mingw32-make.exe fix
Using
Rtools/usr/bin/make.exe
instead ofRtools/mingw_64/bin/mingw32-make.exe
if using R version 4.0 or greater.mingw path change fix
It includes updates to docs and CI scripts for the
mingw_64/
-->mingw64/
change.How you can test this
In a Windows environment with R 4.0, Rtools 4.0, CMake, and Visual Studio, run the following:
Long Description
Here's how building the R package with Visual Studio works today:
R.dll
to use R-provided C/C++ functions such asRprintf
for printing..lib
file (https://docs.microsoft.com/en-us/cpp/build/reference/link-input-files?redirectedfrom=MSDN&view=vs-2019).lib
file fromR.dll
on Windows, we create a definition file (.def
) and then use that to make a library file (.lib
).R.dll
ships with RR.def
is created fromR.dll
, usinggendef.exe
R.lib
is created fromR.def
usingdlltool.exe
The issue:
gendefe.exe
is not part of RTools 4.0.My solution in this PR is to use
objdump.exe
+ an R script to generateR.def
.objdump
creates output intended for humans not machines...it uses indentation and special chracters to make the file visually appealing. So the R script is used to runobjdump
, but more importantly to read in the text it produces and do some simple cleaning to get it into a machine-friendly format that can be re-written as a.def
file.From the "How to create a def file from a dll" section of this amazing MinGW documentation.
References
A lot of the content for this PR was totally new to me. Here are some links I found very helpful.
.def
file: text file that contains the names of objections exported from a DLL.lib
file: a library file, basically a specific format that describe DLL so a linker understands how to link to it