Skip to content

Fix wasm32 build on version 46 #15102

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 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ jobs:
uses: ./.github/actions/setup-builder
with:
rust-version: stable
- name: Install dependencies
run: |
apt-get update -qq
apt-get install -y -qq clang
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this I got: https://github.com/XiangpengHao/datafusion/actions/runs/13744579987/job/38437951143#step:6:144

warning: [email protected]+zstd.1.5.6: ToolExecError: Command LC_ALL="C" "sccache" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fno-exceptions" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/__w/datafusion/datafusion/target/wasm32-unknown-unknown/debug/build/zstd-sys-789e7626e12bcd14/out/44ff4c55aa9e5133-debug.o" "-c" "zstd/lib/common/debug.c" with args clang did not execute successfully (status code exit status: 2).cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `clang` installed?
warning: [email protected]+zstd.1.5.6: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `clang` installed?
warning: [email protected]+zstd.1.5.6: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `clang` installed?
warning: [email protected]+zstd.1.5.6: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `clang` installed?
warning: [email protected]+zstd.1.5.6: sccache: error: failed to execute compile
warning: [email protected]+zstd.1.5.6: sccache: caused by: cannot find binary path

So I added clang here

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build with wasm-pack
Expand Down
2 changes: 1 addition & 1 deletion datafusion/datasource-parquet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object_store = { workspace = true }
parking_lot = { workspace = true }
parquet = { workspace = true }
rand = { workspace = true }
tokio = { workspace = true, features = ["fs"] }
tokio = { workspace = true }

[dev-dependencies]
chrono = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions datafusion/datasource-parquet/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ impl FileFormat for ParquetFormat {
}

/// Coerces the file schema if the table schema uses a view type.
#[cfg(not(target_arch = "wasm32"))]
pub fn coerce_file_schema_to_view_type(
table_schema: &Schema,
file_schema: &Schema,
Expand Down Expand Up @@ -516,7 +515,6 @@ pub fn coerce_file_schema_to_view_type(
/// If the table schema uses a string type, coerce the file schema to use a string type.
///
/// See [ParquetFormat::binary_as_string] for details
#[cfg(not(target_arch = "wasm32"))]
pub fn coerce_file_schema_to_string_type(
table_schema: &Schema,
file_schema: &Schema,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/wasmtest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ chrono = { version = "0.4", features = ["wasmbind"] }
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
datafusion = { workspace = true }
datafusion = { workspace = true, features = ["parquet"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you help me understand what is different about the parquet viewer that isn't covered by the existing test?

Here's the secret @alamb . I think the workspace datafusion has all features disabled. If we enable parquet feature here, we should be able to see compile error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed you are right -- I verified I got a compile error without the code changes in this PR

andrewlamb@Andrews-MacBook-Pro-2:~/Software/datafusion/datafusion/wasmtest$ wasm-pack build --dev

Compiling datafusion-datasource-csv v46.0.0 (/Users/andrewlamb/Software/datafusion/datafusion/datasource-csv)
error[E0432]: unresolved import `crate::file_format::coerce_file_schema_to_view_type`
   --> datafusion/datasource-parquet/src/opener.rs:23:40
    |
23  |     coerce_file_schema_to_string_type, coerce_file_schema_to_view_type,
    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                        |
    |                                        no `coerce_file_schema_to_view_type` in `file_format`
    |                                        help: a similar name exists in the module: `coerce_file_schema_to_string_type`
    |
note: found an item that was configured out
   --> datafusion/datasource-parquet/src/file_format.rs:470:8
    |
470 | pub fn coerce_file_schema_to_view_type(
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
   --> datafusion/datasource-parquet/src/file_format.rs:469:1
    |
469 | #[cfg(not(target_arch = "wasm32"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0425]: cannot find function `coerce_file_schema_to_view_type` in this scope
   --> datafusion/datasource-parquet/src/file_format.rs:726:27
    |
519 | / pub fn coerce_file_schema_to_string_type(
520 | |     table_schema: &Schema,
521 | |     file_schema: &Schema,
522 | | ) -> Option<Schema> {
...   |
571 | | }
    | |_- similarly named function `coerce_file_schema_to_string_type` defined here
...
726 |       if let Some(merged) = coerce_file_schema_to_view_type(&table_schema, &file...
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `coerce_file_schema_to_string_type`

datafusion-common = { workspace = true, default-features = true }
datafusion-execution = { workspace = true }
datafusion-expr = { workspace = true }
Expand Down