-
Notifications
You must be signed in to change notification settings - Fork 24
[Windows] Is it possible to include Rust toolchain in Rtools? #21
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
Comments
Reading through the documents for Rtools, I wonder whether we may have to start a conversation with the maintainers first. In this section it says that we can only contribute static libraries, but that probably won't work for libclang. In this section it says that we can alternatively provide additional build tools but those should only be used to build more packman packages. But we need additional build tools to be used during the R package build. @yutannihilation Do you want to initiate this conversation with the Rtools maintainers? |
Thanks, I didn't notice this... After some thinking, I now feel this is less important.
Let's hold this issue on hold for a while. |
Yes, I think we're good at this time. It might be more important to add Rust than libclang. I've also been thinking that long-term, if this project gets widely used, we should try to convince the R core team to distribute the bindings as part of their official distribution. In this way we'd know that we always have the correct bindings for each R version and platform. |
Rtools cannot be used for |
Not sure if this issue is worth keeping open, but I removed libclang from the issue title because we basically agreed it's not very important. |
@yutannihilation, it looks like we have got the new Rtools version, like, today. |
Oh, cool. It might be just that they moved the artifacts from Bintray to somewhere because Bintray is retiring (I saw some commits related to this on r-windows/rtools-base recently), but it's worth checking! |
@yutannihilation, I checked that it contains our fix, so now I am working to reproduce the errors we had before to see if this fix actually helps. I'll post updates here and in extendr/rextendr#91. |
FYI, the CI pulls Rtools by hard-coded name, so unless they change it we won't get a new version: |
Can we specify |
@yutannihilation, I think we can because the |
I created a pull request: r-lib/actions#287. Hope this works... |
I am struggling to make the CI work. It not only does not seem to care about Rtools version, it also runs incorrect snapshot tests, taking the snapshot for Locally though it seems to work fine. |
With old Rtools: r_path <- normalizePath(dirname(system2("where", "R.exe", stdout = TRUE)[1]))
cargo_path <- normalizePath(dirname(system2("where", "cargo.exe", stdout = TRUE)[1]))
rtools_home <- normalizePath("C:\\rtools40") # Point this to a correct Rtools
rtools_path <- normalizePath(paste(rtools_home, "usr\\bin", sep = "\\"))
old_path <- Sys.getenv("PATH")
new_path <- paste(r_path, cargo_path, rtools_path, sep = ";")
Sys.setenv(PATH = new_path)
Sys.setenv(RTOOLS40_HOME = rtools_home)
rextendr::rust_function("fn add(a:i32, b:i32) -> i32 {a + b}", toolchain = "stable-x86_64-pc-windows-msvc")
#> i build directory: C:\Users\[redacted]\AppData\Local\Temp\RtmpQZ4isS\file13c42b8519a5
#> Error: Rust code could not be compiled successfully. Aborting.
add(42L, 100500L)
#> Error in add(42L, 100500L): could not find function "add"
Created on 2021-05-04 by the reprex package (v2.0.0) With new Rtools: r_path <- normalizePath(dirname(system2("where", "R.exe", stdout = TRUE)[1]))
cargo_path <- normalizePath(dirname(system2("where", "cargo.exe", stdout = TRUE)[1]))
rtools_home <- normalizePath("C:\\rtools40_test") # Point this to a correct Rtools
rtools_path <- normalizePath(paste(rtools_home, "usr\\bin", sep = "\\"))
old_path <- Sys.getenv("PATH")
new_path <- paste(r_path, cargo_path, rtools_path, sep = ";")
Sys.setenv(PATH = new_path)
Sys.setenv(RTOOLS40_HOME = rtools_home)
rextendr::rust_function("fn add(a:i32, b:i32) -> i32 {a + b}", toolchain = "stable-x86_64-pc-windows-msvc")
#> i build directory: C:\Users\[redacted]\AppData\Local\Temp\RtmpuCsL8P\file251c1567143f
#> v Writing file C:/Users/[redacted]/AppData/Local/Temp/RtmpuCsL8P/file251c1567143f/target/extendr_wrappers.R.
add(42L, 100500L)
#> [1] 100542 Created on 2021-05-04 by the reprex package (v2.0.0) |
One of the major annoyances of github actions that should be easy to fix but for some reason they don't is that you can't manually clear the cache. See here on how it can be done: |
I have finally resolved all the issues. The faulty test was due to my local outdated version of {cli}, after updating it I got the new snapshot into the CI.
There are some problems with pulling the latest rtools40v2, see discussion here: |
Pleased to hear this is going well.
…On Tue, 4 May 2021, 16:55 Ilia, ***@***.***> wrote:
I have finally resolved all the issues. The faulty test was due to my
local outdated version of {cli}, after updating it I got the new snapshot
into the CI.
The tests are run using nearly-empty PATH, which is set to point to
binaries of R, cargo, and rtools' /usr/bin (see extendr/rextendr#91
(comment)
<extendr/rextendr#91 (comment)>).
Here are the results:
- Failing R CMD check using old rtools40
https://github.com/Ilia-Kosenkov/rextendr/runs/2501911452?check_suite_focus=true#step:9:314
- Successful R CMD check using new rtools40v2
https://github.com/Ilia-Kosenkov/rextendr/runs/2501911453?check_suite_focus=true#step:10:182
(the error is actually due to a warning issued in the absence of
qpdf...)
There are some problems with pulling the latest rtools40v2, see discussion
here:
r-lib/actions#287 <r-lib/actions#287>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL36XCZNVKY5GLTD5GHZXLTMAKF5ANCNFSM4UVG2TPQ>
.
|
It seems it's not impossible to add Rust to Rtools. This recent email from Tomas Kalibera clarifies how to add a new library. https://stat.ethz.ch/pipermail/r-devel/2021-December/081382.html It's probably not very easy, though. There's an existing issue about adding Rust on the upstream (MXE) repository, but it seems there has been little discussion so far. |
I'm closing this because
Feel free to reopen or file a new issue if necessary! |
Currently libR-sys requires users to install standalone MSYS2 for libclang, but as extendr/extendr#13 suggests, it might be good to use Rtools' MSYS2 for simplicity.
Rtools' MSYS uses a dedicated repository, which has only the limited number of packages available. To add some packages there, we can send a pull request to r-windows/rtools-packages repo, according to this document: System Libraries in Rtools40.
The text was updated successfully, but these errors were encountered: