[RFC] Attribute to specify ordinals of exported functions

Hi everyone!

I've been working on a draft RFC for adding a new #[export_ordinal(n)] attribute.

The reasoning behind it, is that if you need an exported function to be in a specific ordinal position, you currently have to create a definition file. Once you start using a definition file, from then on, every exported function will also have to be added to that definition file, even if the ordinal positions don't matter.

I'm looking for some feedback/opinions on it, as it's my first time writing an RFC.

Edit: RFC PR is at [RFC] Add `#[export_ordinal(n)]` attribute by MeguminSama · Pull Request #3641 · rust-lang/rfcs · GitHub

Thanks a ton!

I'm not a Windows person (haven't used Windows since XP), but isn't the whole concept of ordinal exports a legacy thing that isn't supposed to be used in new binaries? As such it is a very niche thing to need this?

While it's somewhat uncommon, I'm not aware of it being deprecated or considered legacy in any way - at least according to the Microsoft docs.

3 Likes

Seems reasonable to me, given that we have link_ordinal.

4 Likes

Even it it were, it would be necessary in order to (ergonomically) provide a compatible ABI from a Rust implementation of libraries expecting its symbols to be looked up by index.

2 Likes