Skip to content
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

Duplicate definition of Rf_isS4 #243

Closed
andyquinterom opened this issue Jun 13, 2024 · 7 comments
Closed

Duplicate definition of Rf_isS4 #243

andyquinterom opened this issue Jun 13, 2024 · 7 comments

Comments

@andyquinterom
Copy link
Contributor

andyquinterom commented Jun 13, 2024

I'm trying to complite a package on a machine that seems to require rebuilding the R library.

R Version: 4.2.1

When I try to compile libR-sys I get the following compilation error.

   31    Compiling libR-sys v0.7.0 (/home/andres/libR-sys)
   30 error[E0428]: the name `R_altrep_Coerce_method_t` is defined multiple times
   29    --> /home/andres/libR-sys/target/debug/build/libR-sys-12a2d53e43b7ed60/out/bindings.rs:578:1
   28     |
   27 578 | / pub type R_altrep_Coerce_method_t =
   26 579 | |     ::std::option::Option<unsafe extern "C" fn(arg1: SEXP, arg2: ::std::os::raw::c_int) -> SEXP>;
   25     | |_________________________________________________________________________________________________^ `R_altrep_Coerce_method_t` redefined here
   24     |
   23    ::: src/lib.rs:80:1
   22     |
   21 80  | / pub type R_altrep_Coerce_method_t =
   20 81  | |     ::std::option::Option<unsafe extern "C" fn(arg1: SEXP, arg2: SEXPTYPE) -> SEXP>;
   19     | |____________________________________________________________________________________- previous definition of the type `R_altrep_Coerce_method_t` here
   18     |
   17     = note: `R_altrep_Coerce_method_t` must be defined only once in the type namespace of this module
   16
   15 error[E0428]: the name `Rf_isS4` is defined multiple times
   14     --> /home/andres/libR-sys/target/debug/build/libR-sys-12a2d53e43b7ed60/out/bindings.rs:1698:5
   13      |
   12 1698 |     pub fn Rf_isS4(arg1: SEXP) -> Rboolean;
   11      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rf_isS4` redefined here
   10      |
    9     ::: src/lib.rs:83:1
    8      |
    7 83   | pub unsafe fn Rf_isS4(arg1: SEXP) -> Rboolean {
    6      | --------------------------------------------- previous definition of the value `Rf_isS4` here
    5      |
    4      = note: `Rf_isS4` must be defined only once in the value namespace of this module
    3
    2 For more information about this error, try `rustc --explain E0428`.
    1 error: could not compile `libR-sys` (lib) due to 2 previous errors

I think the error is pretty self explanatory, there is definition duplication between lib.rs and the different bindings.

I am 100% willing to help out with this issue. However, some guidance on the implications of changing these values would be appriciated as guidance.

@andyquinterom
Copy link
Contributor Author

Simply removing the defintions from the lib.rs seems to work, but I don't know if I am missing somehting

@andyquinterom
Copy link
Contributor Author

We need perhaps a way to check if the bindings were generated at compile time and remove the code from lib.rs

@CGMossa
Copy link
Member

CGMossa commented Jun 13, 2024

Can you pull from libr-Sys? We have an extensive ci testing process and this case should have been checked.

@andyquinterom
Copy link
Contributor Author

Pulled directly from the main branch. Same error. I will try to get it to properly compile and see if it breaks on any other R version. I will try to see what I can do in terms of CI to test for this

@andyquinterom
Copy link
Contributor Author

@CGMossa The library seems to compile and tests seem to pass when the def of isS4 is deleted on the bindings-linux-x86_64-R4.2.rs file. Would this have any significant implications?

The tests pass both normally and with -F use-bindgen

image

@CGMossa
Copy link
Member

CGMossa commented Jun 13, 2024

Yes.. It could be that this particular version hasn't had its bindings updated, for some strange reason.

We basically write a custom binding definition for those two items instead of what bindgen thinks it should be. So we block them on bindgen, and add them manually.

Check if they are in the other cached binding files.. They shouldn't be.

@CGMossa
Copy link
Member

CGMossa commented Jun 13, 2024

Okay maybe your version of R is just old enough that the bindings wasn't generated for it. That makes sense. I can maybe do something about this... But it will take some time. I'd recommend hand altering these cached bindings, or running with use-bindgen features for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants