Skip to content

Build with a stable compiler without the platform module - #378

Open
ogoffart wants to merge 2 commits into
rust-osdev:mainfrom
ogoffart:olivier/stable-without-platform
Open

ogoffart wants to merge 2 commits into
rust-osdev:mainfrom
ogoffart:olivier/stable-without-platform

Conversation

@ogoffart

@ogoffart ogoffart commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

For programs that build the interpreter from the tables themselves (Interpreter::new) and are built with a stable compiler, such as a UEFI boot manager reading the battery.

The allocator API, which needs nightly, is only used by the platform module and Interpreter::new_from_platform. They are now behind a platform feature, on by default; default-features = false, features = ["aml"] builds with a stable compiler. CI builds that configuration, so it keeps working.


This would allow me to use this crate with a stable compiler.

For programs that build the interpreter from the tables themselves
(Interpreter::new) and are built with a stable compiler, such as a UEFI
boot manager reading the battery.

The allocator API, which needs nightly, is only used by the `platform`
module and `Interpreter::new_from_platform`. They are now behind a
`platform` feature, on by default; `default-features = false, features =
["aml"]` builds with a stable compiler. CI builds that configuration, so
it keeps working.
@martin-hughes

Copy link
Copy Markdown
Contributor

Nice idea, thanks @ogoffart. I have also wondered about using a stable compiler, but didn't realise it'd be so straightforward 😆

One question: does the "alloc" feature actually do anything now? Is it worth just removing it?

With the platform module behind its own feature, `alloc` only enabled
`extern crate alloc`, which only the aml and platform features need:
it did nothing on its own. The crate now uses alloc when either is on.
CI's i686 build without the interpreter uses `platform` instead.
@ogoffart

Copy link
Copy Markdown
Contributor Author

yes that's true, the alloc feature itself don't make sense. I've removed it.

@martin-hughes martin-hughes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very sensible to me. I think this is an area where I'd like to get @IsaacWoods to double-check, since he knows the background of why the features were designed how they were - any thoughts Isaac?

@IsaacWoods

IsaacWoods commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Thanks for the PR @ogoffart and for your recent contributions!
In terms of these changes - there is a risk of allowing the feature set to evolve in terms of requirements as opposed to logical division of functionality; I'm not necessarily against, but seems worthy of thought on our intentions here.

I personally develop against the nightly compiler routinely, and find working around things awaiting stabilisation quite irritating. Without digging into rationale (and with a huge amount of respect to the complicated work on the Rust compiler by contributors), I don't understand why to_vec_in was not stabilised alongside the rest of the allocator API. However, I know other people like to develop against stable, so if it's already easy enough, perhaps we should.

So the question becomes - if we reworked the use of to_vec_in so platform did not require nightly (seems the accepted workaround is Vec::with_capacity_in and then extend_from_slice or equivalent), would there still be value in the feature? I think yes - platform is effectively an optional exception to the crate, and we still require a feature to gate off allocating stuff.

This may seem pedantic; I just want to lay out my thinking about what the features should represent.
So yes, I'm for the platform feature (and that makes alloc redundant), but:

  • Perhaps we should think about getting rid of the need for allocator_ext and therefore committing to the stable compiler across the crate?
  • I feel wording of the documentation could make it clearer that platform and aml are two, separate, functionality-adding extensions that both require allocator support. I don't think the documentation should make promises about which bits need nightly/stable if we keep both. This could be addressed in this PR or in a drive-by elsewhen.

@martin-hughes thoughts?

@ogoffart

Copy link
Copy Markdown
Contributor Author

My motivation here is only to be able to use this crate with a stable compiler for my utility (a UEFI boot loader that queries the battery status)
If the feature were to use the stabilized allocator API from Rust 1.100 and no other nightly feature, I'd be happy. I don't know if there is any other usecase to take platform out.

@martin-hughes

Copy link
Copy Markdown
Contributor

Thanks both - my thoughts.

I know other people like to develop against stable, so if it's already easy enough, perhaps we should.

I agree. I tend to use Stable when I can. Sometimes working around things waiting to be stabilised is annoying, but equally it's annoying if things get removed from Nightly 😆 (e.g. kwzhao/x2apic-rs#32). Stable would also increase the crate's potential reach. On balance, I'm happy with the principle of "if it's easy enough".

Question though: is there a chance of needing nightly again in future? That would be a breaking change. Personally, I think the chance is fairly low - we've pushed back on adding allocator API to Interpreter pending library improvements (it would needs alloc in String, and probably allocator_ext to be finished), and I don't see anything else in the pipeline that looks like a "must have".

Perhaps we should think about getting rid of the need for allocator_ext and therefore committing to the stable compiler across the crate?

I think this is a reasonable plan - I support it. to_vec_in looks like a good target for a polyfill of some kind. As above, we've put allocator support for the main Interpreter as a lower priority so other missing allocator features in Stable aren't likely to trip us up.

To be fully "stable" we'd also need to remove the public = true / public dependencies work until it stabilises (tracking issue)

None of this seems blocking.

would there still be value in the feature? I think yes - platform is effectively an optional exception to the crate

Yes, agree - I use the platform module and quite like it.

I feel wording of the documentation could make it clearer that platform and aml are two, separate, functionality-adding extensions that both require allocator support. I don't think the documentation should make promises about which bits need nightly/stable if we keep both. This could be addressed in this PR or in a drive-by elsewhen.

Fair comment. I had half an eye on this so I don't mind tweaking it later.


TL;DR:

Good thoughts @IsaacWoods. Does what I've written help?

What should we do for this PR? Assuming you think switching to stable is a good move, is it fair to say you'd like this PR to do all of that by:

  • Altering or polyfilling the use of to_vec_in
  • Removing the allocator_ext feature flag
  • Removing the public dependency flags
  • Deleting the rust-toolchain.toml file
  • Optionally (but ideally) be a bit clearer in the docs
  • Probably a few other minor tasks

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.

3 participants