-
-
Notifications
You must be signed in to change notification settings - Fork 586
fix(allocator): Add allocator_api
feature to allow usage of core::alloc::
#10676
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
nightly
feature to enable allocator_api
featurenightly
feature to enable allocator_api
feature
Can you provide some context on how you are using this crate which requires nightly? |
It's not specifically that this crate requires a nightly compiler, but as
// When the `nightly` feature is enabled, use `core::alloc` ...
#[cfg(feature = "nightly")]
pub use core::alloc::*
// ... otherwise use own definitions to allow usage on stable toolchain
#[cfg(not(feature = "nightly"))]
pub use self::alloc::*
Generally, this means that any crate depending on |
And a bit more concrete: We utilize the allocator |
I see the reason. We only have a few places that rely on |
I currently use my branch directly, so I would not see updates from your side. I would prefer to not use a fork, so if we could merge it and if not required anymore removing it would be great! |
CodSpeed Instrumentation Performance ReportMerging #10676 will not alter performanceComparing Summary
|
We'll need to keep In short: I expect we'll be using This PR is a good way to make that workable for downstream users who are on nightly. My only comments are:
|
The CI failures are because we run Maybe add a feature |
I was about to ask about what we do about the CI, it just took me a bit to figure out where |
Actually... (and sorry I didn't notice this earlier)... zakarumych/allocator-api2#30 has now been merged and it removes the As far as I understand, that would also solve the problem, and would avoid these unpleasant workarounds with features in Oxc. |
It was already asked if a new release could be done in zakarumych/allocator-api2#30 (comment). But even if the crate would be released, |
If |
OK. I see your point. Thanks for making the changes I requested. Some of the docs for other features wasn't quite correct (our fault - they should have been documented already). I've added docs for them in #10695. Please could you rebase on top of it? Concerning the CI failures: I'd like to consult with @Boshen on this, as it's not my area. My suggestion is:
Maybe the best name for that feature is Unfortunately, Boshen is largely away from desk for next few days, so it may take a little time for him to come back on this. |
Thanks, much appreciated! Quick question on process: do you squash-merge PRs on your end, or would you prefer contributors to squash commits themselves before merging? On the feature name — No rush on merging this — I’m happy to work off my own branch for now using |
nightly
feature to enable allocator_api
featureallocator_api
feature to allow usage of core::alloc::
Any updates on the CI issue? |
@overlookmotel @TimDiekmann A few updates:
|
Thanks very much @NeuralModder. We're in the process of replacing So, if I'm understanding right, if we bump |
Yes, as far as I can see, we would not need this anymore then. Instead, we'd need a small build-script to detect the nightly toolchain and conditionally enable the allocator-api feature. I'm happy to adjust this PR to account for this. I'd do something like I did for |
Thanks for coming back. We are using
You clearly understand this better than me, so please say if that's not an ideal solution. |
Sure, that works as well, that prevents an additional dependency as well 🙂 |
Actually, it seems that
A workaround would be to at least use fn main() {
println!("cargo:rustc-check-cfg=cfg(nightly)");
if rustversion::cfg!(nightly) {
println!("cargo:rustc-cfg=nightly");
}
} which would allow checking #![cfg_attr(nightly, feature(allocator_api))] But let's wait for I prepared the changes for the new |
@@ -0,0 +1,6 @@ | |||
fn main() { | |||
println!("cargo:rustc-check-cfg=cfg(nightly)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to prevent a warning on #[cfg(nightly)]
. This effectively adds nightly
to the list of allowed cfg-attributes for the crate.
@@ -20,6 +20,7 @@ | |||
//! Usage of this feature is not advisable, and it will be removed as soon as we're able to. | |||
#![warn(missing_docs)] | |||
#![cfg_attr(nightly, feature(allocator_api))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, we simply use allocator_api
when we're on nightly. This is the correct usage of allocator_api2
since version 0.3.0
. This keeps the allocator-api
isolated in this crates. Downstream crates do not need to care anymore (unless they use allocator_api2
as a direct dependency as well).
Just to update you on where we're at... We have a prototype of our new allocator which is going to replace So before we can replace So, in short, we are progressing towards replacing |
@overlookmotel could you take another look at this PR? I updated the changes to use |
This reverts commit 5adc2e3.
Actually, it seems that |
Hi,
The crate
allocator-api2
has a feature flag "nightly" to either use the#![feature(allocator_api)]
-based types fromcore::alloc
or use their own. Ifallocator-api2
is used by another crate at the same time which enables theallocator-api2/nightly
feature, a compile error will happen due to feature flag unification of Cargo asoxc_-_allocator
will then use the re-exported types fromcore::alloc
throughallocator_api2
which will result in the error that theallocator_api
feature is not enabled.There is a quite easy fix: Simply add
#![feature(allocator_api)]
to the top ofoxc-allocator
'slib.rs
. However, as this requires a nightly compiler, the possibly easiest way to stay compatible is to add anightly
feature.I don't know the exact procedure to contribute to this repository, but as it's effectively a 4-line change I thought I'd just open a PR.
Relevant issue: