extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
190 stars 28 forks source link

The issue still persists #325

Closed studsttat closed 9 months ago

studsttat commented 9 months ago

Tried calling rust_function() from the documentation and it produces an error:


> rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
ℹ build directory: C:/Users/Lenovo/AppData/Local/Temp/RtmpWyEKPF/file6c879685895
Opening fd 2
   Compiling proc-macro2 v1.0.70
   Compiling libR-sys v0.6.0
   Compiling paste v1.0.14
   Compiling extendr-api v0.6.0
error: could not compile `extendr-api` (build script) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `paste` (build script) due to 2 previous errors
error: could not compile `proc-macro2` (build script) due to 2 previous errors
error: could not compile `libR-sys` (build script) due to 2 previous errors
Error in `invoke_cargo()`:
! Rust code could not be compiled successfully. Aborting.
✖ error: linking with `link.exe` failed: exit code: 1
JosiahParry commented 9 months ago

What is the output of rust_sitrep()?

studsttat commented 9 months ago

Hi. This is the output of rust_sitrep()

> rust_sitrep()
Rust infrastructure sitrep:
✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)
✔ "cargo": 1.74.1 (ecb9851af 2023-10-18)
ℹ host: x86_64-pc-windows-msvc
ℹ toolchains: stable-x86_64-pc-windows-msvc (default) and
  nightly-x86_64-pc-windows-msvc
ℹ target: x86_64-pc-windows-msvc
! Target x86_64-pc-windows-gnu is required on this host machine
ℹ Run `rustup target add x86_64-pc-windows-gnu` to install it
JosiahParry commented 9 months ago

@studsttat notice the last line. From your terminal run rustup target add x86_64-pc-windows-gnu

studsttat commented 9 months ago

This is my rust_sitrep after running rustup target add x86_64-pc-windows-gnu in terminal:

> rust_sitrep()
Rust infrastructure sitrep:
✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)
✔ "cargo": 1.74.1 (ecb9851af 2023-10-18)
ℹ host: x86_64-pc-windows-msvc
ℹ toolchains: stable-x86_64-pc-windows-msvc (default) and
  nightly-x86_64-pc-windows-msvc
ℹ targets: x86_64-pc-windows-gnu and x86_64-pc-windows-msvc

I tried to write a function in Rust command and this is what I got:

> rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
ℹ build directory: C:/Users/Lenovo/AppData/Local/Temp/RtmpyUQ2mf/file171468757754
Opening fd 2
    Updating crates.io index
 Downloading crates ...
  Downloaded proc-macro2 v1.0.71
  Downloaded syn v2.0.43
   Compiling proc-macro2 v1.0.71
   Compiling unicode-ident v1.0.12
   Compiling libR-sys v0.6.0
   Compiling paste v1.0.14
   Compiling extendr-api v0.6.0
error: could not compile `extendr-api` (build script) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `paste` (build script) due to 2 previous errors
error: could not compile `proc-macro2` (build script) due to 2 previous errors
error: could not compile `libR-sys` (build script) due to 2 previous errors
Error in `invoke_cargo()`:
! Rust code could not be compiled successfully. Aborting.
✖ error: linking with `link.exe` failed: exit code: 1
JosiahParry commented 9 months ago

I'm sorry, I'm not a windows user and don't know how to further help other than rustup default stable-x86_64-pc-windows-msvc

Ilia-Kosenkov commented 9 months ago

I am puzzled as well. Let us try to debug further. Can you please run

pkgbuild::has_rtools(debug = TRUE)

and post here the output? (You might need to install {pkgbuild} if it is not available for you)

studsttat commented 9 months ago

This is the output of pkgbuild::has_rtools(debug = TRUE):

> pkgbuild::has_rtools(debug = TRUE)
Found in Rtools 4.3 installation folder
[1] TRUE
Ilia-Kosenkov commented 9 months ago

Ok then I have no idea. Let us try something different then? If you could install {usethis} (unless it is already available), then run in some temporary folder:

usethis::create_package("build.test")
rextendr::use_extendr()

Wait till it finishes, then try

rextendr::document()

If you get any errors, please post them here. If you get here without an issue, try

hello_world()

which calls into Rust library and should print out "Hello world!".

studsttat commented 9 months ago

Ok, I tried everything so here's what I got:

When I run

usethis::create_package("build.test")
rextendr::use_extendr()

It gave me this result:

> usethis::create_package("build.test")
New project 'build.test' is nested inside an existing project './', which is rarely a good idea.
If this is unexpected, the here package has a function, `here::dr_here()` that reveals why './' is regarded as a project.
Do you want to create anyway?

1: Absolutely not
2: Absolutely
3: Negative

Selection: rextendr::use_extendr()
Enter an item from the menu, or 0 to exit
Selection: 2
✔ Creating 'build.test/'
✔ Setting active project to 'D:/R/R-INT/build.test'
✔ Creating 'R/'
✔ Writing 'DESCRIPTION'
Package: build.test
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R (parsed):
    * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID)
Description: What the package does (one paragraph).
License: `use_mit_license()`, `use_gpl3_license()` or friends to
    pick a license
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
✔ Writing 'NAMESPACE'
✔ Writing 'build.test.Rproj'
✔ Adding '^build\\.test\\.Rproj$' to '.Rbuildignore'
✔ Adding '.Rproj.user' to '.gitignore'
✔ Adding '^\\.Rproj\\.user$' to '.Rbuildignore'
✔ Opening 'D:/R/R-INT/build.test/' in new RStudio session
✔ Setting active project to '<no active project>'

I'm surprised that it was redirected into new session and it automatically creates an R project named `build.test'.

In that new session, I ran and it gave me this result:

> rextendr::document()
✔ Saving changes in the open files.
ℹ First time using rextendr. Upgrading automatically...
ℹ Setting `Config/rextendr/version` to "0.3.1.9000" in the DESCRIPTION file.
ℹ Setting `SystemRequirements` to "Cargo (rustc package manager)" in the DESCRIPTION file.
ℹ Generating extendr wrapper functions for package: build.test.
Error in `register_extendr()`:
! Unable to register the extendr module.
✖ Could not find file src/entrypoint.c.
• Are you sure this package is using extendr Rust code?
Run `rlang::last_trace()` to see where the error occurred.

Lastly, I ran the hello_world() and it didn't work.

Ilia-Kosenkov commented 9 months ago

You did it from an existing project (that is what usethis tells you). Could you please run it from an empty directory?

studsttat commented 9 months ago

Ok, I am sorry. So, I closed my R Project and evaluate this code

usethis::create_package("build.test")
rextendr::use_extendr()

in an empty project. After I run them:

usethis::create_package("build.test") ✔ Creating 'build.test/' ✔ Setting active project to 'C:/Users/Lenovo/Documents/build.test' ✔ Creating 'R/' ✔ Writing 'DESCRIPTION' Package: build.test Title: What the Package Does (One Line, Title Case) Version: 0.0.0.9000 Authors@R (parsed):

  • First Last first.last@example.com [aut, cre] (YOUR-ORCID-ID) Description: What the package does (one paragraph). License: use_mit_license(), use_gpl3_license() or friends to pick a license Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 ✔ Writing 'NAMESPACE' ✔ Writing 'build.test.Rproj' ✔ Adding '^build\.test\.Rproj$' to '.Rbuildignore' ✔ Adding '.Rproj.user' to '.gitignore' ✔ Adding '^\.Rproj\.user$' to '.Rbuildignore' ✔ Opening '.../build.test/' in new RStudio session ✔ Setting active project to '' rextendr::use_extendr() Error: Path '' does not appear to be inside a project or package. Read more in the help for proj_get(). ✔ Setting active project to ''

And again, it redirected into new session, an R project, named build.test in new session (new RStudio window).

After this, I tried to run rextendr::document() in the build.test() project session and I got an error.

> rextendr::document()
✔ Saving changes in the open files.
ℹ First time using rextendr. Upgrading automatically...
ℹ Setting `Config/rextendr/version` to "0.3.1.9000" in the DESCRIPTION file.
ℹ Setting `SystemRequirements` to "Cargo (rustc package manager)" in the DESCRIPTION file.
ℹ Generating extendr wrapper functions for package: build.test.
Error in `register_extendr()`:
! Unable to register the extendr module.
✖ Could not find file src/entrypoint.c.
• Are you sure this package is using extendr Rust code?
Run `rlang::last_trace()` to see where the error occurred.
Ilia-Kosenkov commented 9 months ago

Oh this is Rstudio toying with us. I am not a n expert in Rstudio. @JosiahParry, can you help us create a new rextendr-based package in Rstudio? If not, I will try it myself in the evening or later tomorrow.

JosiahParry commented 9 months ago

Hm. It says src/entrypoint.c does not exist. I feel like this might be a working directory issue? I've included a gif of how I would go about creating a new package using RStudio.

Another thing that I can imagine happening is that theres a suggested package that you don't have installed and {rextendr}'s code to work without it is making a bit of a bug.

What does the src/ directory look like for you?

image

Screen Recording 2024-01-03 at 08 32 58

studsttat commented 9 months ago

After creating build.test, I immediately ran rextendr::use_extendr() to create source file for Rust.

> rextendr::use_extendr()
✔ Setting active project to 'D:/R/build.test'
ℹ First time using rextendr. Upgrading automatically...
ℹ Setting `Config/rextendr/version` to "0.3.1.9000" in the DESCRIPTION file.
ℹ Setting `SystemRequirements` to "Cargo (rustc package manager)" in the DESCRIPTION file.
✔ Creating src/rust/src.
✔ Writing 'src/entrypoint.c'
✔ Writing 'src/Makevars'
✔ Writing 'src/Makevars.win'
✔ Writing 'src/Makevars.ucrt'
✔ Writing 'src/.gitignore'
✔ Adding '^src/\\.cargo$' to '.Rbuildignore'
✔ Writing 'src/rust/Cargo.toml'
✔ Writing 'src/rust/src/lib.rs'
✔ Writing 'src/build.test-win.def'
✔ Writing R/extendr-wrappers.R
✔ Finished configuring extendr for package build.test.
• Please run `rextendr::document()` for changes to take effect.

But then, again, the issue still persists.

> rextendr::document()
✔ Saving changes in the open files.
ℹ Generating extendr wrapper functions for package: build.test.
ℹ Re-compiling build.test (debug build)
── R CMD INSTALL ──────────────────────────────────────────────────────────────────────────────
─  installing *source* package 'build.test' ... (371ms)
   ** using staged installation
   ** libs
   using C compiler: 'gcc.exe (GCC) 12.3.0'
   rm -Rf build.test.dll ./rust/target/x86_64-pc-windows-gnu/release/libbuild_test.a entrypoint.o
   gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG     -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall -gdwarf-2 -mfpmath=sse -msse2 -mstackrealign  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
   mkdir -p ./rust/target/libgcc_mock
   # `rustc` adds `-lgcc_eh` flags to the compiler, but Rtools' GCC doesn't have
   # `libgcc_eh` due to the compilation settings. So, in order to please the
   # compiler, we need to add empty `libgcc_eh` to the library search paths.
   #
   # For more details, please refer to
   # https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316
   touch ./rust/target/libgcc_mock/libgcc_eh.a
   # CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2
   if [ "true" != "true" ]; then \
    export CARGO_HOME=/d/R/build.test/src/.cargo; \
   fi && \
    export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="x86_64-w64-mingw32.static.posix-gcc.exe" && \
    export LIBRARY_PATH="${LIBRARY_PATH};/d/R/build.test/src/./rust/target/libgcc_mock" && \
    cargo build --target=x86_64-pc-windows-gnu --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
       Updating crates.io index
    Downloading crates ...
     Downloaded proc-macro2 v1.0.75
     Downloaded syn v2.0.47
      Compiling proc-macro2 v1.0.75
      Compiling unicode-ident v1.0.12
      Compiling libR-sys v0.6.0
      Compiling paste v1.0.14
      Compiling extendr-api v0.6.0
   error: linking with `link.exe` failed: exit code: 1
     |
     = note: "link.exe" "/NOLOGO" "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\rustcfX0yLJ\\symbols.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\proc-macro2-f7efbf8985639062\\build_script_build-f7efbf8985639062.build_script_build.771ab174aa3b8333-cgu.0.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\proc-macro2-f7efbf8985639062\\build_script_build-f7efbf8985639062.build_script_build.771ab174aa3b8333-cgu.1.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\proc-macro2-f7efbf8985639062\\build_script_build-f7efbf8985639062.1ddtyharyyf2489m.rcgu.o" "/LIBPATH:D:\\R\\build.test\\src\\./rust/target\\release\\deps" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0953e6946d141dd5.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-1541b450ccd763fe.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-5a09e425bafc4516.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-ecda5ec957e5b02b.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-29558c79058a1d33.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-79041b320290d8f0.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-286439bfb959d33a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-605b14b8e032564a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-0b31dbf49adf39ca.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-f7d2d3884e227169.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-1e7d41cbc2b494d8.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-061ba68cd65fd4a1.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-8b085e5ea89ddf02.rlib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\R\\build.test\\src\\./rust/target\\release\\build\\proc-macro2-f7efbf8985639062\\build_script_build-f7efbf8985639062.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
     = note: link: extra operand 'D:\\R\\build.test\\src\\./rust/target\\release\\build\\proc-macro2-f7efbf8985639062\\build_script_build-f7efbf8985639062.build_script_build.771ab174aa3b8333-cgu.0.rcgu.o'
             Try 'link --help' for more information.

   error: linking with `link.exe` failed: exit code: 1
     |
     = note: "link.exe" "/NOLOGO" "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\rustc8q0vR4\\symbols.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\paste-403c4626310ef579\\build_script_build-403c4626310ef579.build_script_build.6e1b6c360108f5ae-cgu.0.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\paste-403c4626310ef579\\build_script_build-403c4626310ef579.build_script_build.6e1b6c360108f5ae-cgu.1.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\paste-403c4626310ef579\\build_script_build-403c4626310ef579.pnr8nrxonjbb16d.rcgu.o" "/LIBPATH:D:\\R\\build.test\\src\\./rust/target\\release\\deps" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0953e6946d141dd5.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-1541b450ccd763fe.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-5a09e425bafc4516.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-ecda5ec957e5b02b.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-29558c79058a1d33.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-79041b320290d8f0.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-286439bfb959d33a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-605b14b8e032564a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-0b31dbf49adf39ca.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-f7d2d3884e227169.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-1e7d41cbc2b494d8.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-061ba68cd65fd4a1.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-8b085e5ea89ddf02.rlib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\R\\build.test\\src\\./rust/target\\release\\build\\paste-403c4626310ef579\\build_script_build-403c4626310ef579.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
     = note: link: extra operand 'D:\\R\\build.test\\src\\./rust/target\\release\\build\\paste-403c4626310ef579\\build_script_build-403c4626310ef579.build_script_build.6e1b6c360108f5ae-cgu.0.rcgu.o'
             Try 'link --help' for more information.

   error: linking with `link.exe` failed: exit code: 1
     |
     = note: "link.exe" "/NOLOGO" "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\rustcvbJkJK\\symbols.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\extendr-api-cfe21ff84217fdcf\\build_script_build-cfe21ff84217fdcf.build_script_build.50bd966fd10e2a3e-cgu.0.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\extendr-api-cfe21ff84217fdcf\\build_script_build-cfe21ff84217fdcf.4bydvx0a46bay7w.rcgu.o" "/LIBPATH:D:\\R\\build.test\\src\\./rust/target\\release\\deps" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0953e6946d141dd5.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-1541b450ccd763fe.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-5a09e425bafc4516.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-ecda5ec957e5b02b.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-29558c79058a1d33.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-79041b320290d8f0.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-286439bfb959d33a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-605b14b8e032564a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-0b31dbf49adf39ca.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-f7d2d3884e227169.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-1e7d41cbc2b494d8.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-061ba68cd65fd4a1.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-8b085e5ea89ddf02.rlib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\R\\build.test\\src\\./rust/target\\release\\build\\extendr-api-cfe21ff84217fdcf\\build_script_build-cfe21ff84217fdcf.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
     = note: link: extra operand 'D:\\R\\build.test\\src\\./rust/target\\release\\build\\extendr-api-cfe21ff84217fdcf\\build_script_build-cfe21ff84217fdcf.build_script_build.50bd966fd10e2a3e-cgu.0.rcgu.o'
             Try 'link --help' for more information.

   note: `link.exe` returned an unexpected error

   note: in the Visual Studio installer, ensure the "C++ build tools" workload is selected

   error: could not compile `proc-macro2` (build script) due to previous error
   warning: build failed, waiting for other jobs to finish...
   error: could not compile `paste` (build script) due to previous error
   error: could not compile `extendr-api` (build script) due to previous error
   error: linking with `link.exe` failed: exit code: 1
     |
     = note: "link.exe" "/NOLOGO" "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\rustcKSotio\\symbols.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.build_script_build.949b8c14e14de5f1-cgu.0.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.build_script_build.949b8c14e14de5f1-cgu.1.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.build_script_build.949b8c14e14de5f1-cgu.2.rcgu.o" "D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.2v1lqxtfde6gf1e.rcgu.o" "/LIBPATH:D:\\R\\build.test\\src\\./rust/target\\release\\deps" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "kernel32.lib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0953e6946d141dd5.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-1541b450ccd763fe.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-5a09e425bafc4516.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-ecda5ec957e5b02b.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-29558c79058a1d33.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-79041b320290d8f0.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-286439bfb959d33a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-605b14b8e032564a.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-0b31dbf49adf39ca.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-f7d2d3884e227169.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-1e7d41cbc2b494d8.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-061ba68cd65fd4a1.rlib" "C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-8b085e5ea89ddf02.rlib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Lenovo\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
     = note: link: extra operand 'D:\\R\\build.test\\src\\./rust/target\\release\\build\\libR-sys-8601cb0d28b0514e\\build_script_build-8601cb0d28b0514e.build_script_build.949b8c14e14de5f1-cgu.0.rcgu.o'
             Try 'link --help' for more information.

   error: could not compile `libR-sys` (build script) due to previous error
   make: *** [Makevars.win:24: rust/target/x86_64-pc-windows-gnu/release/libbuild_test.a] Error 101
   ERROR: compilation failed for package 'build.test'
─  removing 'C:/Users/Lenovo/AppData/Local/Temp/RtmpyglhOQ/devtools_install_294076c82d8f/build.test'
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
Ilia-Kosenkov commented 9 months ago

Ah yes, now it makes sense -- I actually saw a similar thing myself on my laptop, where I accidentally nuked my VS installation. It is a rust toolchain issue, see this:

note: in the Visual Studio installer, ensure the "C++ build tools" workload is selected

Check this link for installation guidelines.

studsttat commented 9 months ago

And...it finally works.

> rextendr::rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
ℹ build directory: C:/Users/Lenovo/AppData/Local/Temp/RtmpmmIAfc/file2ebc7ec4bda
Opening fd 2
    Updating crates.io index
   Compiling proc-macro2 v1.0.75
   Compiling unicode-ident v1.0.12
   Compiling libR-sys v0.6.0
   Compiling paste v1.0.14
   Compiling extendr-api v0.6.0
   Compiling once_cell v1.19.0
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling extendr-macros v0.6.0
   Compiling rextendr1 v0.0.1 (C:\Users\Lenovo\AppData\Local\Temp\RtmpmmIAfc\file2ebc7ec4bda)
    Finished dev [unoptimized + debuginfo] target(s) in 19.27s
✔ Writing C:/Users/Lenovo/AppData/Local/Temp/RtmpmmIAfc/file2ebc7ec4bda/target/extendr_wrappers.R
> add(1,2)
[1] 3
JosiahParry commented 9 months ago

@studsttat may we close out this issue? :)

studsttat commented 9 months ago

If it is necessary, you may now close this issue.