When using the GNU LD linker via the nightly-gnu or stable-gnu toolchain (Windows OS), one might run into a linker error like this:
bin/ld.exe: error: export ordinal too large: 88000 or any number above 65536(2^16/16bit)
The error was also previously dicussed in this thread but final closure was not reached before mod-bot auto closed it after 90 days:
In the thread it was suggested just not to use the gnu-toolchain and instead msvc. That might not be an option because the project uses cygwin/mingw, msys2 or similar. One user claimed to have found a difficult solution mixing gnu and msvc, but did not specify further.
I ran into the same error as describe in this issue
using rextendr to link rust to R on windows
The problem is actually not that difficult to solve. It seems the issue arises as the linker for static linking uses a 16bit symbol table. If not specifying what symbols to export, potentially any symbol in the stack of rust crates will be exported. This can easily exceed 65k limit. Likely a project only need to exposed a few hundreds of symbols in a API, the rest can stay internal. You just need to specify which to the linker
I'm not allowed to post more links as I'm a new user. I put the linker doc urls in the github-issue.
You may need to interact with the LD linker via e.g. gcc. Pay attention to the differnt command-line syntax for interacting directly with linker or via gcc. Via gcc -Wl[arg1],[arg2],[arg3] can be used to pass on args to the linker. It is also possible to provide a tmp.def file naming what symbols to export and instruct the linker to use this. If unsure how the symbols are named, it was for me possible to intercept the auto-generated tmp.def be disabling clean up of temp files. No mangle helps alot. As a thumbrule, anything mangled was not intended for export.