Unverified Commit 6b59ba26 authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Fix compiling S3 crate for wasm (#3590)

## Motivation and Context
Running `cargo build --target wasm32-unknown-unknown
--no-default-features` on an S3 crate has stopped working since
https://github.com/smithy-lang/smithy-rs/pull/3465 with the following
error:
```
error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/[REDACTED]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.14/src/lib.rs:352:9
    |
352 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
353 | |                         default, you may need to enable the \"js\" feature. \
354 | |                         For more information see: \
355 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^
```

To address the issue, this PR updates an S3's dependency on `ahash` in a
way that disables default features.

## Testing
Updated the existing test `integration-tests/webassembly` so that
`check-aws-sdk-standalone-integration-tests` will run `cargo check`
`aws-sdk-s3` against both `wasm32-wasi` and `wasm32-unknown-unknown`
(the updated check would break if we removed `default-features = false`
from the `ahash` dependency).

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 7fbdcc2b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -34,3 +34,10 @@ message = "Change some credentials related info log messages to debug."
references = ["smithy-rs#3546"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "orf"


[[aws-sdk-rust]]
message = "Fix an S3 crate's dependency on `ahash` so the crate can be compiled for `wasm32-unknown-unknown`."
references = ["smithy-rs#3590", "aws-sdk-rust#1131"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "ysaito1001"
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ repository = "https://github.com/smithy-lang/smithy-rs"
# Used by lru, and this forces it to be a later version that avoids
# https://github.com/tkaitchuck/aHash/issues/200
# when built with `cargo update -Z minimal-versions`
ahash = "0.8.11"
ahash = { version = "0.8.11", default-features = false }
aws-credential-types = { path = "../aws-credential-types" }
aws-runtime = { path = "../aws-runtime", features = ["http-02x"] }
aws-sigv4 = { path = "../aws-sigv4" }
+4 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@ for f in *; do
      else
         # The webassembly tests use a custom runner set in config.toml that
         # is not picked up when running the tests outside of the package
         cd webassembly && cargo component test --all-features --all-targets && cd ..
         # The tests are written for `wasm32-wasi` but the manifest config also specifies
         # `wasm32-unknown-unknown` so we can ensure the test build on that platform as well.
         # For executing the tests, however, we explicitly choose a target `wasm32-wasi`.
         cd webassembly && cargo component test --all-features --target wasm32-wasi && cd ..
      fi
   fi
done
+1 −1
Original line number Diff line number Diff line
[build]
target = "wasm32-wasi"
target = ["wasm32-unknown-unknown", "wasm32-wasi"]

[target.wasm32-wasi]
rustflags = ["-C", "opt-level=1"]
+1 −1
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ data class CargoDependency(
    companion object {
        // Forces AHash to be a later version that avoids
        // https://github.com/tkaitchuck/aHash/issues/200
        val AHash: CargoDependency = CargoDependency("ahash", CratesIo("0.8.11"))
        val AHash: CargoDependency = CargoDependency("ahash", CratesIo("0.8.11"), defaultFeatures = false)
        val OnceCell: CargoDependency = CargoDependency("once_cell", CratesIo("1.16"))
        val Url: CargoDependency = CargoDependency("url", CratesIo("2.3.1"))
        val Bytes: CargoDependency = CargoDependency("bytes", CratesIo("1.0.0"))
Loading