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

Update Cargo.toml #7

Merged
merged 4 commits into from
Sep 7, 2023
Merged

Update Cargo.toml #7

merged 4 commits into from
Sep 7, 2023

Conversation

lveyde
Copy link

@lveyde lveyde commented Sep 2, 2023

Usage of zlib backend for flate2 causes a compilation failure. One should use a rust_backend instead.

Otherwise a libz-sys crate compilation error similar to this will occur:

Updating crates.io index

Compiling libz-sys v1.1.12
Checking priority-queue v1.3.2
The following warnings were emitted during compilation:

warning: error: unknown target triple 'wasm32-wasi', please use -triple or -arch

error: failed to run custom build command for libz-sys v1.1.12

Caused by:
process didn't exit successfully: /home/lveyde/git/rust/Create_a_Microservice_in_Rust/lveyde-a-stateful-microservice-lp/order_management/target/debug/build/libz-sys-0ed89978f8121fe7/build-script-build (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=ZLIB_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_wasm32-wasi
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_wasm32_wasi
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_wasm32-wasi
cargo:rerun-if-env-changed=PKG_CONFIG_wasm32_wasi
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_wasm32-wasi
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_wasm32_wasi
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo-warning=pkg-config has not been configured to support cross-compilation.

Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via
PKG_CONFIG environment variable.
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_wasm32-wasi
CC_wasm32-wasi = None
cargo:rerun-if-env-changed=CC_wasm32_wasi
CC_wasm32_wasi = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
cargo:rerun-if-env-changed=CFLAGS_wasm32-wasi
CFLAGS_wasm32-wasi = None
cargo:rerun-if-env-changed=CFLAGS_wasm32_wasi
CFLAGS_wasm32_wasi = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
running: "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/lveyde/git/rust/Create_a_Microservice_in_Rust/lveyde-a-stateful-microservice-lp/order_management/target/wasm32-wasi/debug/build/libz-sys-7cf7184cfca6fdb6/out/lib/src/zlib/adler32.o" "-c" "src/zlib/adler32.c"
cargo:warning=error: unknown target triple 'wasm32-wasi', please use -triple or -arch

exit status: 1

--- stderr

error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/lveyde/git/rust/Create_a_Microservice_in_Rust/lveyde-a-stateful-microservice-lp/order_management/target/wasm32-wasi/debug/build/libz-sys-7cf7184cfca6fdb6/out/lib/src/zlib/adler32.o" "-c" "src/zlib/adler32.c" with args "clang" did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...

Usage of zlib backend for flate2 causes a compilation failure.
One should use a rust_backend instead.

Signed-off-by: Lev Veyde <[email protected]>
@lveyde
Copy link
Author

lveyde commented Sep 2, 2023

Forced-pushed the same patch with Signed-off-by added, to make the DCO happy.

@lveyde
Copy link
Author

lveyde commented Sep 2, 2023

The issue seems to be related to this one: issue 172

Basically, on many platforms the llvm/clang doesn't support wasm32.

@juntao
Copy link
Member

juntao commented Sep 3, 2023

Hmm @CaptainVincent can you help review this? Thanks.

Signed-off-by: Lev Veyde <[email protected]>
@CaptainVincent
Copy link
Member

@lveyde
Hi, could you provide your build command and reproduce steps?
Are you running cargo build --target wasm32-wasi under this repo? Or are you using this crate as a dependency in another repo and encountering errors? If so, could you also provide the repository where the build fails?

Because I am unable to reproduce the issue locally and
it looks like the CI for the zlib backend added last time is running well (link).

I'll also give your PR a try later, but I'd like to confirm what issue we're addressing first. Thank you.

@lveyde
Copy link
Author

lveyde commented Sep 5, 2023

@lveyde Hi, could you provide your build command and reproduce steps? Are you running cargo build --target wasm32-wasi under this repo? Or are you using this crate as a dependency in another repo and encountering errors? If so, could you also provide the repository where the build fails?

Because I am unable to reproduce the issue locally and it looks like the CI for the zlib backend added last time is running well (link).

I'll also give your PR a try later, but I'd like to confirm what issue we're addressing first. Thank you.

Yes, certainly. Im using it as a dependency in my own project, and it gets compiled together with other dependency tree.

I'm using CentOS 7.9, and the main issue is that it's llvm/clang version doesn't support compilation into wasm targets.
Thus one can't compile any C code into Wasm on this distro (without using unsupported version of llvm/clang by i.e. compiling it from source).
That doesn't affect any native Rust code, as Rust comes with it's own compiler, but compiling any wrappers around C code will fail.

Requiring flate2/zlib as a direct dependency of mysql_async_wasi is causing the inclusion of libz-sys crate (which is a wrapper around zlib), even if one uses a feature option to choose a different configuration, i.e. "default", which normally was not supposed to include zlib.
And since the libz-sys crate doesn't contain a native Rust code, but rather C code, that as mentioned, causes a clang to fail to compile it into the required wasm32 target.

I think that using a rust_backend instead provides a good solution in this case.

Copy link
Member

@CaptainVincent CaptainVincent left a comment

Choose a reason for hiding this comment

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

I add one suggestion.

Cargo.toml Outdated Show resolved Hide resolved
Copy link
Member

@CaptainVincent CaptainVincent left a comment

Choose a reason for hiding this comment

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

Two minor changes are needed. I've reviewed the rest part, and it looks fine.

README.md Outdated Show resolved Hide resolved
README.md Outdated
flate2 = { version = "*", default-features = false, features = ["rust_backend"] }
```

* `default` – enables the following set of crate's and dependencies' features:

- `native-tls-tls`
- `flate2/zlib"
- `flate2/rust_backend"
Copy link
Member

Choose a reason for hiding this comment

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

  • flate2/rust_backend

this too.

Reworked the features, and updated the README.md file to reflect
the changes in the default configuration.

Also fixed some references to the original crate.

Signed-off-by: Lev Veyde <[email protected]>
Copy link
Member

@CaptainVincent CaptainVincent left a comment

Choose a reason for hiding this comment

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

LGTM. @juntao Could your help ship this.

@juntao
Copy link
Member

juntao commented Sep 7, 2023

I increased the minor version number so that I can publish this crate. Thank you!

@juntao juntao merged commit 117e143 into WasmEdge:master Sep 7, 2023
2 checks passed
@lveyde
Copy link
Author

lveyde commented Sep 8, 2023

I increased the minor version number so that I can publish this crate. Thank you!

Sure, no problem!

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.

3 participants