-
Notifications
You must be signed in to change notification settings - Fork 185
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
Revisiting no_std in ICU4X #812
Comments
There's a little bit of use of Vec in LocaleCanonicalizer, but that is largely driven by the Vec like field on LanguageIdentifier. There's also a use of String to work around some awkwardness parsing an extension value. I think a little work on the APIs for LanguageIdentifier/Locale and it would be easy to remove this stuff. In general, I think supporting |
|
Next step: assess the work involved and find an assignee. |
praise: Thanks for leaving nice notes on the conversation here, it helps get up to speed here, since I missed this meeting. |
I'm planning to spend the next week-ish trying stuff here. My initial direction will actually be to have both no_std and no_std-but-alloc support where possible, and perhaps that goal will be too lofty, but I'd like to start with that and downgrade to no_std-with-alloc if it doesn't work. My main goal is to figure out what challenges are involved and how much work this will take. I'm aware of the shape of the challenges for this kind of refactor; however it's as of yet unclear if they apply to our specific situation. We'll see! I'll probably have some kind of draft PR that might not be representative of how we actually want to do this. |
I've been making some progress, I managed to get icu_capi's serde dependency off std (which I anticipated would be a bigger task). A larger issue is that we use |
rust-lang/cargo#9696 is making it harder for me to do this, but it's not actually a limitation in the final situation, it just makes it harder to work on this incrementally. |
immediately realized that i need to do more error work. I think for now I might actually drop the usage of |
core_error does solve our problem but it's prerelease |
#865 makes progress, however it doesn't remove |
Useful awk script for adding imports# gawk -f std.awk -i inplace file.rs file.rs
# find src -name *.rs | xargs -I {} gawk -f std.awk -i inplace {} {}
NR==FNR{
if(!/\/\/\//) {
if(/\yString\y/) {
string = 1;
}
if(/Vec/) {
vec = 1;
}
if(/\yBox\y/) {
box = 1;
}
if(/\yAny\y/) {
any = 1;
}
if(/\yATypeId\y/) {
typeid = 1;
}
if(/\yvec[!]/) {
vecm = 1;
}
if(/\yformat[!]/) {
format = 1;
}
if(/\yto_string\y/) {
tostring = 1;
}
}
next
}
{
if(/^use / && use == 0) {
use = 1
if(any == 1) {
print "use core::any::Any;"
}
if(typeid == 1) {
print "use core::any::TypeId;"
}
if(box == 1) {
print "use alloc::boxed::Box;"
}
if(format == 1) {
print "use alloc::format;"
}
if(string == 1) {
print "use alloc::string::String;"
}
if(tostring == 1) {
print "use alloc::string::ToString;"
}
if(vec == 1) {
print "use alloc::vec::Vec;"
}
if(vecm == 1) {
print "use alloc::vec;"
}
}
if(!/\/\/\//) {
gsub(/std::rc::Rc/,"alloc::rc::Rc");
gsub(/std::sync::Arc/,"alloc::sync::Arc");
gsub(/std::borrow::Cow/,"alloc::borrow::Cow");
gsub(/std::borrow::ToOwned/,"alloc::borrow::ToOwned");
gsub(/\sToOwned/," alloc::borrow::ToOwned");
gsub(/std::/,"core::");
}
print $0;
} |
2021 follow-up to #77
The allocator remains one of the largest chunks of code size in WASM files, and it has been reported to us by some customers (such as .NET) that it can cause integration issues.
I would therefore like us to revisit
no_std
as a baseline in ICU4X, meaning no allocator (more specifically, types that require heap allocations, likeVec
andString
, would be off limits from core library code).With #78 and #667, the data provider will support zero-alloc. We are fairly close in some other areas. FixedDecimal and LanguageIdentifier both have a
Vec
-like field; we would need to decide what to do with these: perhaps return an error code if overflow would occur?Most importantly, I don't want to embark on
no_std
without the full support of the team. I truly thinkno_std
is an achievable and noble goal for us, but it will require commitment and a team culture whereno_std
is the norm. More specifically, although I don't think it should be a requirement that everything in the ICU4X core library isno_std
, I want that to be the exception, not the rule. New features should land withno_std
support by default, unless team members provide a technical justification otherwise.The text was updated successfully, but these errors were encountered: