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

Fix procedural macros #260

Merged
merged 3 commits into from
Jul 31, 2021
Merged

Fix procedural macros #260

merged 3 commits into from
Jul 31, 2021

Conversation

necauqua
Copy link
Contributor

@necauqua necauqua commented Jul 21, 2021

Currently procedural macros do not work outside of uefi crate, because they are referencing crate-local items (Guid, Protocol etc.) and when invoked from a crate other than 'uefi' those items cannot be found (well because the other crate does not have them).

This is a known (as I learned) procedural macro issue and the latest best workaround is what I implemented here - allow 'uefi' to reference itself by ::uefi and then use ::uefi in those macros.

As an additional bonus (I can revert that if you have objections but it's neat and does not break anything) I made the 'entry' macro always make the exported entry function have the name 'efi_main', which is required by the rust efi target I think.

Anyway, with that change, users can name their entry function whatever they want (right now that leads to cryptic errors iirc), and the fact that this is an entry function is clearly marked by the #[entry] attribute above it.

@GabrielMajeri
Copy link
Collaborator

Thank you, the changes look great!

I made the 'entry' macro always make the exported entry function have the name 'efi_main', which is required by the rust efi target I think

Could you also update the docs to mention that the main function can be named in any way, but will be renamed to efi_main by the proc macro?

@necauqua
Copy link
Contributor Author

necauqua commented Jul 22, 2021

I've also added the 'extern crate rlibc' thing to said doc, because that one took me an extra minute at some point :)

@GabrielMajeri GabrielMajeri merged commit 8eb1948 into rust-osdev:master Jul 31, 2021
@GabrielMajeri
Copy link
Collaborator

Thanks for the contribution!

nicholasbishop added a commit to nicholasbishop/uefi-rs that referenced this pull request Sep 7, 2021
The proc macros now work correctly outside of the uefi crate thanks to
the improvements made in rust-osdev#260.
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 this pull request may close these issues.

2 participants