extendr / rextendr

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

`x86_64-w64-mingw32.static.posix\bin/ld.exe` linker cannot handle large rust crates #211

Closed sorhawell closed 1 year ago

sorhawell commented 1 year ago

problem:

The following error occours if compiling a big project with latest rextendr on windows: C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: error: export ordinal too large: 88000

issue

It seems the rtools42 gnu linker currently uses a 16bit enumeration of symbols (ordinal symbol table). If using a large rust crate such as polars the compilation will fail for windows as this table is exceeded.

Minimal reproducible example:

I have made a minimal inclusion of polarsin helloextendr to show the error here

What I could google:

one tried to solve the issue by moving back mvsc another needed to use gnu/msys2 but alledgely got by doing some mix msys2+mvsc compiling

Some golang people have the same isssue and are discussion to limit the number of exported symbols

... and it seems the gophers found some kind of solution here

Ilia-Kosenkov commented 1 year ago

(Following discord discussion, a public summary) This is an issue with linker. Other framework and tools face this problem as well, and there appears to be no one-fits-all solution. We will try to explore what we can do to solve it. Unfortunately, at this point no ETA.

sorhawell commented 1 year ago

something like this patch-function could be a candidate fix:

sorhawell commented 1 year ago

useful url-links to linker LD docs:

win32 cygwin options linker command options

sorhawell commented 1 year ago

For the case of most rextendr projects almost the same .def file can be used to solve the problem. Only change name of package: see this example