extendr / rextendr

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

Issue when compiling extendr-macros #381

Closed PMassicotte closed 2 months ago

PMassicotte commented 2 months ago

Using available information, I am trying to create a package, but I am getting this error when running rextendr::document():

[ins] r$> usethis::create_package("rustr")
✔ Creating rustr/.
✔ Setting active project to "/home/filoche/Desktop/rustr".
✔ Creating R/.
✔ Writing DESCRIPTION.
Package: rustr
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.3.2
✔ Writing NAMESPACE.

[ins] r$> rextendr::use_extendr()
ℹ First time using rextendr. Upgrading automatically...
ℹ Setting `Config/rextendr/version` to "0.3.1"
✔ 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/rustr-win.def.
✔ Writing R/extendr-wrappers.R.
✔ Finished configuring extendr for package rustr.
• Please update the system requirement in DESCRIPTION file.
• Please run `rextendr::document()` for changes to take effect.

[ins] r$> rextendr::document()
ℹ Generating extendr wrapper functions for package: rustr.
ℹ Re-compiling rustr (debug build)
── R CMD INSTALL ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package ‘rustr’ ...
   ** using staged installation
   ** libs
   using C compiler: ‘gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0’
   rm -Rf rustr.so ./rust/target/release/librustr.a entrypoint.o
   gcc -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/r-base-EawLoD/r-base-4.4.1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/r-base-EawLoD/r-base-4.4.1=/usr/src/r-base-4.4.1-1.2404.0 -Wdate-time -D_FORTIFY_SOURCE=3  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
   # In some environments, ~/.cargo/bin might not be included in PATH, so we need
   # to set it here to ensure cargo can be invoked. It is appended to PATH and
   # therefore is only used if cargo is absent from the user's PATH.
   if [ "true" != "true" ]; then \
    export CARGO_HOME=/home/filoche/Desktop/rustr/src/.cargo; \
   fi && \
    export PATH="/home/filoche/.local/share/bob/nvim-bin:/home/filoche/.juliaup/bin:/home/filoche/.pyenv/bin:/home/filoche/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/filoche/.juliaup/bin:/home/filoche/.cargo/bin:/home/filoche/.local/bin:/home/filoche/bin:/home/filoche/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/bin:/home/filoche/.fzf/bin:/home/filoche/.cargo/bin" && \
    cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
       Updating crates.io index
        Locking 10 packages to latest compatible versions
      Compiling proc-macro2 v1.0.86
      Compiling unicode-ident v1.0.12
      Compiling libR-sys v0.7.1
      Compiling paste v1.0.15
      Compiling extendr-api v0.7.0
      Compiling once_cell v1.19.0
      Compiling quote v1.0.37
      Compiling syn v2.0.77
      Compiling extendr-macros v0.7.0
   error[E0425]: cannot find function, tuple struct or tuple variant `Rf_isValidString` in this scope
       --> /home/filoche/.cargo/registry/src/index.crates.io-6f17d22bba15001f/extendr-api-0.7.0/src/robj/rinternals.rs:358:18
        |
   358  |         unsafe { Rf_isValidString(self.get()).into() }
        |                  ^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `Rf_isBlankString`
        |
       ::: /home/filoche/Desktop/rustr/src/./rust/target/release/build/libR-sys-d642c90fb8b3bb73/out/bindings.rs:1294:5
        |
   1294 |     pub fn Rf_isBlankString(arg1: *const ::std::os::raw::c_char) -> Rboolean;
        |     ------------------------------------------------------------------------ similarly named function `Rf_isBlankString` defined here

   error[E0425]: cannot find function, tuple struct or tuple variant `Rf_isValidStringF` in this scope
       --> /home/filoche/.cargo/registry/src/index.crates.io-6f17d22bba15001f/extendr-api-0.7.0/src/robj/rinternals.rs:363:18
        |
   363  |         unsafe { Rf_isValidStringF(self.get()).into() }
        |                  ^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `Rf_isBlankString`
        |
       ::: /home/filoche/Desktop/rustr/src/./rust/target/release/build/libR-sys-d642c90fb8b3bb73/out/bindings.rs:1294:5
        |
   1294 |     pub fn Rf_isBlankString(arg1: *const ::std::os::raw::c_char) -> Rboolean;
        |     ------------------------------------------------------------------------ similarly named function `Rf_isBlankString` defined here

   For more information about this error, try `rustc --explain E0425`.
   error: could not compile `extendr-api` (lib) due to 2 previous errors
   make: *** [Makevars:16: rust/target/release/librustr.a] Error 101
   ERROR: compilation failed for package ‘rustr’
─  removing ‘/tmp/RtmpArwzt6/devtools_install_1366361b2e9a7/rustr’
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'R' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.

Looks like there is something about conflicting names/scoping.

Anything I missed on my side?

CGMossa commented 2 months ago

Hallo! Yes! We are very aware of this, and we are trying to handle it. Let me write back when we've got this resolved.

CGMossa commented 2 months ago

Hello again.. We just made a new patch release of extendr and all of its crates. If try to build again, and see what happens, that would be great.

Troubleshooting: You might need to go to src/rust/ folder in the terminal and run cargo clean followed by cargo update. I don't think that's necessary but it is possible.

PMassicotte commented 2 months ago

Let me try.

PMassicotte commented 2 months ago

It is working with 0.7.1.

I had to do cargo update.

[nav] r$> rextendr::document()
ℹ Generating extendr wrapper functions for package: rustr.
ℹ Re-compiling rustr (debug build)
── R CMD INSTALL ────────────────────────────────────────────────────────────────────────────────────
─  installing *source* package ‘rustr’ ...
   ** using staged installation
   ** libs
   using C compiler: ‘gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0’
   rm -Rf rustr.so ./rust/target/release/librustr.a entrypoint.o
   gcc -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/r-base-EawLoD/r-base-4.4.1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/r-base-EawLoD/r-base-4.4.1=/usr/src/r-base-4.4.1-1.2404.0 -Wdate-time -D_FORTIFY_SOURCE=3  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
   # In some environments, ~/.cargo/bin might not be included in PATH, so we need
   # to set it here to ensure cargo can be invoked. It is appended to PATH and
   # therefore is only used if cargo is absent from the user's PATH.
   if [ "true" != "true" ]; then \
    export CARGO_HOME=/home/filoche/Desktop/rustr/src/.cargo; \
   fi && \
    export PATH="/home/filoche/.local/share/bob/nvim-bin:/home/filoche/.juliaup/bin:/home/filoche/.pyenv/bin:/home/filoche/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/filoche/.juliaup/bin:/home/filoche/.cargo/bin:/home/filoche/.local/bin:/home/filoche/bin:/home/filoche/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/bin:/home/filoche/.fzf/bin:/home/filoche/.cargo/bin" && \
    cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
    Downloading crates ...
     Downloaded extendr-macros v0.7.1
     Downloaded extendr-api v0.7.1
      Compiling extendr-api v0.7.1
      Compiling extendr-macros v0.7.1
      Compiling rustr v0.1.0 (/home/filoche/Desktop/rustr/src/rust)
       Finished `release` profile [optimized] target(s) in 2.44s
   if [ "true" != "true" ]; then \
    rm -Rf /home/filoche/Desktop/rustr/src/.cargo && \
    rm -Rf ./rust/target/release/build; \
   fi
   gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -o rustr.so entrypoint.o -L./rust/target/release -lrustr -L/usr/lib/R/lib -lR
   installing to /tmp/Rtmp4mzxH2/devtools_install_1990832b5c200/00LOCK-rustr/00new/rustr/libs
   ** checking absolute paths in shared objects and dynamic libraries
─  DONE (rustr)
✔ Writing 'R/extendr-wrappers.R'
ℹ Updating rustr documentation
Writing NAMESPACE
ℹ Loading rustr
Writing NAMESPACE
Writing hello_world.Rd

Thank you very much for this work.