Closed bezirg closed 2 years ago
Hello @bezirg. Thanks for reporting this.
Since the error is complaining about a missing C type SEXPREC
, perhaps the change of R versions requires modifying the includes in Internal.hsc.
https://github.com/tweag/HaskellR/blob/afac2e6279cee422d2112c2c5a31d9a35ff54302/inline-r/src/Foreign/R/Internal.hsc#L45-L48
If it amounts to that, it could be a matter of conditionally adjusting the includes when R is at a newer version.
I also have this problem :-(
I also ran into that. R 4.2.1 on Ubuntu 18.04.6.
Just hit this in Debian Testing (R 4.2.1).
After looking at this a bit more in detail. I'm afraid it won't be as easy as re-ordering headers.
Note that the internal structure of the
SEXPREC
is not made available to R Extensions: ratherSEXP
is an opaque pointer, and the internals can only be accessed by the functions provided.
https://cran.r-project.org/doc/manuals/r-release/R-ints.html
The internals are just not exported anymore. And while we could just use SET_TAG, SETCDR, SETCAR, and LENGTH; I've no idea how to deal with the ALIGN hack...
-- | Extract the data pointer from a vector.
unsafeSEXPToVectorPtr :: SEXP s a -> Ptr ()
unsafeSEXPToVectorPtr s = (unsexp s) `plusPtr` #{size SEXPREC_ALIGN}
-- | Inverse of 'vectorPtr'.
unsafeVectorPtrToSEXP :: Ptr a -> SomeSEXP s
unsafeVectorPtrToSEXP s = SomeSEXP $ sexp $ s `plusPtr` (- #{size SEXPREC_ALIGN})
For unsafeSEXPToVectorPtr
, there is STDVEC_DATAPTR
; but for the inverse unsafeVectorPtrToSEXP
, I fail to find a suitable fix.
As unsafeVectorPtrToSEXP
is not used internally, I'm tempted to suggest it being removed.
This of course only makes Internal.hsc
work. HExp.hsc
is a whole another issue. The reliance on peek and poke with internal types poses a major headache there.
After looking some more at this, this will get really complicated. The part of missing_r
that seems to hook into the GC... I have no idea how to fix that up. For the rest of HExp.hsc
there is a set of accessors that can be used for most of the peek calls. Poke is much harder, as I wasn't able to find the corresponding setters for all the fields we use.
size and alightment for the storage instance will also need some hard thinking to get right :-/
At this point, it's easier for me to just fix an older R version than try to make this compatible with 4.2
@angerman thanks for looking at this
pokeHExp
, etc. Turns out that the getter functions are enough, because we usually construct R values through quasiquotation and evaluation, and only really need to inspect them from Haskell, not construct them.
Using R 4.1.3 i can
cabal build inline-r-0.10.5
.Using latest R 4.2.0 (that also is on stable ArchLinux), I get on
cabal build inline-r-0.10.5
:I am not sure if this is a bug of this Haskell library, a bug from the Archlinux packaging side, or a bug from the upstream R dev side.