-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: Enable WASM compilation by making sqlparser's recursive-protection optional #16418
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
fix: Enable WASM compilation by making sqlparser's recursive-protection optional #16418
Conversation
…ility This change addresses the PSM "section too large" error when building DataFusion for WebAssembly by making sqlparser's recursive-protection feature optional. Changes: - Set default-features = false for sqlparser in workspace Cargo.toml - Add sqlparser_std and sqlparser_recursive_protection features to datafusion crate - Include these features in datafusion's default features for backward compatibility This allows WASM builds to exclude the problematic dependency chain: sqlparser → recursive → stacker → psm While maintaining full compatibility for non-WASM builds. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
The std feature is required for sqlparser to compile properly. Without it, basic types and imports are missing.
datafusion/core/Cargo.toml
Outdated
@@ -79,6 +81,9 @@ recursive_protection = [ | |||
"datafusion-physical-optimizer/recursive_protection", | |||
"datafusion-sql/recursive_protection", | |||
] | |||
# Enable sqlparser's default features for backward compatibility | |||
sqlparser_std = ["sqlparser/std"] | |||
sqlparser_recursive_protection = ["sqlparser/recursive-protection"] |
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.
Is there any need to add this new sqlparser_recursive_protection = ["sqlparser/recursive-protection"]
feature? could we instead just add it to the recursive_protection existing feature?
recursive_protection = [
"datafusion-common/recursive_protection",
"datafusion-expr/recursive_protection",
"datafusion-optimizer/recursive_protection",
"datafusion-physical-optimizer/recursive_protection",
"datafusion-sql/recursive_protection",
"sqlparser/recursive-protection", # Add this???
]
I also don't fully understand why we need a new feature for sqlparser_std as that would seem to already be enabled
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.
Oh, yeah, good call. Made these updates in 485a505
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.
Thank you for this contribution @jonmmease -- I think wasm is a very important target.
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.
Makes sense to me -- thank you @jonmmease
Thanks again @jonmmease |
Summary
This PR fixes the WASM compilation issue (#13513) by making sqlparser's
recursive-protection
feature optional. This allows DataFusion to be compiled for WebAssembly targets without encountering the "LLVM error: section too large" error caused by the PSM (Portable Stack Manipulation) dependency.Background
When compiling DataFusion for WASM (target
wasm32-unknown-unknown
), the build fails with:The dependency chain causing this issue is:
The PSM crate is incompatible with WebAssembly because.
As noted in the PSM documentation itself:
The Fix
This PR implements a solution that maintains backward compatibility while enabling WASM builds:
default-features = false
for sqlparser to prevent automatic inclusion ofrecursive-protection
sqlparser_std
→ enablessqlparser/std
sqlparser_recursive_protection
→ enablessqlparser/recursive-protection
Usage
After this change:
For WASM builds (no PSM dependency):
For regular builds (unchanged behavior):
Related Issues and Context
recursive-protection
feature flag #13887 which made recursive_protection optional in datafusion-sqlNotes
While PR #13887 made
recursive_protection
optional in datafusion-sql, it didn't fully solve the WASM compilation issue because sqlparser itself was still being pulled in with its default features across multiple DataFusion crates. This PR completes the fix by ensuring sqlparser's default features can be controlled at the workspace level.