Skip to content

feat(ffi): added default-engine-rustls feature and extern "C" for .h file #1023

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

Merged
merged 6 commits into from
Jul 12, 2025

Conversation

mightyshazam
Copy link
Contributor

This PR adds a feature default-engine-rustls to allow users to use the feature in the kernel. Additionally, it adds cpp_compat = true to the cbindgen.toml file so that it will add a section to add the extern "C" wrapper.

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

What changes are proposed in this pull request?

  1. This commit updates the generated delta_kernel_ffi.h to include c++ compatibility to that it will include extern "C" so that code generation will appropriately not try to use mangled method names.
  2. Added the feature delta-engine-rustls to the ffi project in order to use the same feature from the kernel.

How was this change tested?

Tested against the dotnet implementation of delta lake.

@mightyshazam mightyshazam changed the title feat(ffi): added default-engine-rustls feature and extern "C"for .h file feat(ffi): added default-engine-rustls feature and extern "C" for .h file Jun 18, 2025
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.97%. Comparing base (d3b47ce) to head (da5eaa9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1023   +/-   ##
=======================================
  Coverage   82.97%   82.97%           
=======================================
  Files          93       93           
  Lines       21979    21979           
  Branches    21979    21979           
=======================================
  Hits        18238    18238           
  Misses       2786     2786           
  Partials      955      955           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hntd187
Copy link
Collaborator

hntd187 commented Jun 18, 2025

Isn't the entire name space surrounded in extern "C" I could be wrong last I checked it was C++ compatible.

@mightyshazam
Copy link
Contributor Author

Isn't the entire name space surrounded in extern "C" I could be wrong last I checked it was C++ compatible.

It is with this change. It wasn't previously. The ffi crate also generates a .hpp file for C++.

Copy link
Collaborator

@hntd187 hntd187 left a comment

Choose a reason for hiding this comment

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

LGMT

Copy link
Collaborator

@zachschuermann zachschuermann left a comment

Choose a reason for hiding this comment

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

in the core kernel crate we get away with defining a 'default-engine-base' feature - I wonder if we could do something similar here to avoid having to check both features at each cfg?

@mightyshazam
Copy link
Contributor Author

mightyshazam commented Jun 18, 2025

in the core kernel crate we get away with defining a 'default-engine-base' feature - I wonder if we could do something similar here to avoid having to check both features at each cfg?

I considered it after looking at the kernel config. The difference between the two is that the kernel base feature actually does something. In the ffi crate the features would look like

default-engine = ["delta_kernel/default-engine", "default-engine-base", "delta_kernel/arrow"]
default-engine-rustls = ["delta_kernel/default-engine-rustls", "default-engine-base", "delta_kernel/arrow"]
default-engine-base = []

It saves us verbosity, but it doesn't provide any real value, and, if someone were to enable it without one of the corresponding engine features, the code wouldn't compile.
A base feature is my preferred option. I just couldn't think of a good way to make it work. Maybe if it were like this

default-engine = ["delta_kernel/default-engine", "default-engine-base"]
default-engine-rustls = ["delta_kernel/default-engine-rustls", "default-engine-base"]
default-engine-base = ["delta_kernel/default-engine-base", "delta_kernel/arrow"]

It's redundant, but it doesn't cause surprise failure.
EDIT: I see that delta_kernel doesn't build with just default-engine-base. I'll make the switch.

Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

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

Awesome thanks! Just a small nit. I can merge once that's addressed

ffi/Cargo.toml Outdated
default-engine-rustls = ["delta_kernel/default-engine-rustls", "default-engine-base"]

# this is an 'internal' feature flag which has all the shared bits from default-engine and
# default-engine-rustls
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we add a comment that the check in kernel/lib.rs that you've enabled one of default-engine or default-engine-rustls will ensure that we don't just enable default-engine-base here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed you meant adding a comment referencing the check in kernel/lib.rs to the Cargo.toml for ffi. That's what I did. Let me know if that was what you were getting at.

@mightyshazam mightyshazam force-pushed the default-engine-rustls branch from d223638 to e46526b Compare June 26, 2025 17:31
@mightyshazam mightyshazam force-pushed the default-engine-rustls branch from 9039a8a to ec39d6c Compare July 8, 2025 12:18
Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

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

Lgtm! Thanks for taking this on!

@nicklan nicklan added the breaking-change Change that require a major version bump label Jul 12, 2025
@nicklan nicklan merged commit 327b331 into delta-io:main Jul 12, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Change that require a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants