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

Reduce the number of dependencies on std #1224

Merged
merged 5 commits into from
Feb 9, 2023
Merged

Conversation

kitlith
Copy link
Contributor

@kitlith kitlith commented Jan 30, 2023

Works on #1204

I separated the changes to the integration tests into a separate commit in case we don't want to change them.

Some other things I considered doing in this PR, but have other breakages:

  • change std::os::raw::* to core::ffi::*
    • My best guess is that this also requires changes to bindgen
  • change String to alloc::string::String when generating the string utilities
    • This would require putting an extern crate alloc; somewhere, and I'm not sure where we want to do that, or if we want to do that unconditionally.
  • change std::boxed::Box to alloc::boxed::Box
    • Same issues as String
    • Additionally, there is a question of how to handle this in known types. If you keep both std and alloc in there, then it causes duplicate codegen (in c++ iirc? maybe there's a flag we could use to disable codegen for one of them)

I'm not sure what changes I'd make to the readme for this, but I figure that's something to consider once the tests are fixed.

Testing to ensure this change does what I want it to is actually somewhat difficult, as ideally you'd test against a target that is no_std (so that accidental std inclusions get caught), but has a c++ toolchain with lib(std)c++ available (so that cxx compiles, and so that the generated autocxx code compiles). building with zig doesn't help because it doesn't build lib(std)c++ for you. There probably is a target that wouldn't be too difficult to set that up for, but I haven't put much time into looking for one.

@google-cla
Copy link

google-cla bot commented Jan 30, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adetaylor
Copy link
Collaborator

Thanks for having a crack at this. lifetime.rs lines 164-166 specify std::pin::Pin in a weird way! Hopefully that matches the symptoms you're seeing.

@kitlith
Copy link
Contributor Author

kitlith commented Jan 30, 2023

yeah, okay, I don't feel bad for missing that.

tbh encoding the paths to these types as part of what the macro relies on to do its job seems fragile (as demonstrated here), but idk if there's a better way to do it from a proc macro.

latest commit fixes the failing tests locally, so I'm marking as ready for review.

@kitlith kitlith marked this pull request as ready for review January 30, 2023 23:11
@adetaylor
Copy link
Collaborator

Thanks! Merging.

@adetaylor adetaylor merged commit 59eaac1 into google:main Feb 9, 2023
@kitlith kitlith deleted the no_std branch February 9, 2023 22:37
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.

None yet

2 participants