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

Learn unsafe Rust: Provide initial content for the chapter "ABI and FFI" #150

Open
4 of 17 tasks
darkwisebear opened this issue Jan 18, 2025 · 6 comments
Open
4 of 17 tasks
Assignees
Labels
coding guidelines Related to work in the Coding Guidelines Subcommittee tracking issue An issue that gathers activities toward a larger goal

Comments

@darkwisebear
Copy link

darkwisebear commented Jan 18, 2025

Todo

Provide initial content for the ABI and FFI chapter of the Learn unsafe Rust book.

Proposed content

  • Explain ABI and what "C ABI/FFI" actually means
    • What aspects of the ABI are defined by C and which aren't
    • How compilers and compiler settings influence the ABI
    • What aspects are influenced by the ABI
    • Mismatching calling conventions / padding (aka ABI)
    • Note on different calling conventions, esp. on x86
  • Explain unsafety categories in FFI
    • Explain main building blocks of the Rust FFI
    • Mismatching function signatures
    • Mismatching type declarations
    • Unsafe actions beyond the FFI boundary
    • Moveability/self-reference, especially with C++ move constructors
    • Ownership
    • C++ topics
      • Dealing with standard library data structures
      • Exceptions thrown from C++ code
  • Mitigations for FFI unsafety
    • Existing FFI tooling (bindgen, cbindgen, cxx)
    • Checks that can be done on FFI and Rust side
    • cRABI (?)
@PLeVasseur PLeVasseur added coding guidelines Related to work in the Coding Guidelines Subcommittee tracking issue An issue that gathers activities toward a larger goal labels Jan 19, 2025
@darkwisebear
Copy link
Author

I started writing stuff and uploaded that to my personal repo fork: https://github.com/darkwisebear/learn_unsafe_rust/blob/initial_content_abi_ffi/src/core_unsafety/abi_and_ffi.md. Feel free to create PRs to that or comment here on what's there already.

@PLeVasseur
Copy link
Collaborator

Hey @darkwisebear, thanks for kicking this off for ABI and FFI :)

I'd like to keep our merges back to the repo consistent. Consider opening a PR based on your branch to here to raise awareness. I'm very happy to merge even partially completed sections as @iglesias has been doing.

@darkwisebear
Copy link
Author

I can open a draft PR; I don't want to merge it as-is, it's really half-baked still, but people can anyway already start commenting if they want to.

@PLeVasseur
Copy link
Collaborator

Hey sorry I probably was not clear! I meant to open a PR to this repo, not the Learn unsafe Rust, with any intermediate work. That way we can have a chance to collaborate and merge pieces. I agree that for contributing back to Learn unsafe Rust we'd want one comprehensive package of work.

@darkwisebear
Copy link
Author

@PLeVasseur Understood, yeah, I can do that. I will just put the file into a subdir of this repo, keeping the structure of the original repo.

@PLeVasseur
Copy link
Collaborator

@PLeVasseur Understood, yeah, I can do that. I will just put the file into a subdir of this repo, keeping the structure of the original repo.

Great, sounds like a good plan! Thanks for starting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coding guidelines Related to work in the Coding Guidelines Subcommittee tracking issue An issue that gathers activities toward a larger goal
Development

No branches or pull requests

2 participants