Repository: bytecodealliance/wasmtime
Pull request #7304 (2023-10-19 22:52:46)

A couple of small refactorings to the egraph elaboration pass
@jameysharp and I noticed a couple of refactoring opportunities while reading through the elaboration pass:

* The elaboration loop doesn't need to match on the top of the stack as a reference, because each case pops it immediately. Instead we can pop and match on the popped value.
* Computing the cost of a pure `ValueDef::Result` was using the block that contains the instruction to determine the level, but since pure values will not be in the DFG yet, this would default to `LoopLevel::root()` unconditionally. This also meant that the `Cost::at_level` function turned into an identity function on the cost given, making it unnecessary.

Co-authored-by: Jamey Sharp <jsharp@fastly.com>

<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->



Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 30a379510..b626972d2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3327,7 +3327,9 @@ dependencies = [
  "cap-std",
  "env_logger 0.10.0",
  "futures",
+ "log",
  "once_cell",
+ "tracing",
  "wasi-cap-std-sync",
  "wasi-common",
  "wasmtime",
diff --git a/ci/run-wasi-nn-example.sh b/ci/run-wasi-nn-example.sh
index 74bab3bd3..6f433bc3e 100755
--- a/ci/run-wasi-nn-example.sh
+++ b/ci/run-wasi-nn-example.sh
@@ -39,7 +39,7 @@ pushd $WASMTIME_DIR/crates/wasi-nn/examples/classification-example
 cargo build --release --target=wasm32-wasi
 cp target/wasm32-wasi/release/wasi-nn-example.wasm $TMP_DIR
 popd
-cargo run -- run --dir fixture::$TMP_DIR -S nn $TMP_DIR/wasi-nn-example.wasm
+cargo run -- run --dir $TMP_DIR::fixture -S nn $TMP_DIR/wasi-nn-example.wasm
 
 # Build and run another example, this time using Wasmtime's graph flag to
 # preload the model.
@@ -47,7 +47,7 @@ pushd $WASMTIME_DIR/crates/wasi-nn/examples/classification-example-named
 cargo build --release --target=wasm32-wasi
 cp target/wasm32-wasi/release/wasi-nn-example-named.wasm $TMP_DIR
 popd
-cargo run -- run --dir fixture::$TMP_DIR -S nn,nn-graph=openvino::$TMP_DIR \
+cargo run -- run --dir $TMP_DIR::fixture -S nn,nn-graph=openvino::$TMP_DIR \
     $TMP_DIR/wasi-nn-example-named.wasm
 
 # Clean up the temporary directory only if it was not specified (users may want
diff --git a/cranelift/codegen/src/egraph/cost.rs b/cranelift/codegen/src/egraph/cost.rs
index 9cfb0894c..bc807df02 100644
--- a/cranelift/codegen/src/egraph/cost.rs
+++ b/cranelift/codegen/src/egraph/cost.rs
@@ -33,12 +33,6 @@ use crate::ir::Opcode;
 #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
 pub(crate) struct Cost(u32);
 impl Cost {
-    pub(crate) fn at_level(&self, loop_level: usize) -> Cost {
-        let loop_level = std::cmp::min(2, loop_level);
-        let multiplier = 1u32 << ((10 * loop_level) as u32);
-        Cost(self.0.saturating_mul(multiplier)).finite()
-    }
-
     pub(crate) fn infinity() -> Cost {
         // 2^32 - 1 is, uh, pretty close to infinite... (we use `Cost`
         // only for heuristics and always saturate so this suffices!)
diff --git a/cranelift/codegen/src/egraph/elaborate.rs b/cranelift/codegen/src/egraph/elaborate.rs
index 6acf83cba..5815352a5 100644
--- a/cranelift/codegen/src/egraph/elaborate.rs
+++ b/cranelift/codegen/src/egraph/elaborate.rs
@@ -7,7 +7,7 @@ use super::Stats;
 use crate::dominator_tree::DominatorTree;
 use crate::fx::FxHashSet;
 use crate::ir::{Block, Function, Inst, Value, ValueDef};
-use crate::loop_analysis::{Loop, LoopAnalysis, LoopLevel};
+use crate::loop_analysis::{Loop, LoopAnalysis};
 use crate::scoped_hash_map::ScopedHashMap;
 use crate::trace;
 use crate::unionfind::UnionFind;
@@ -211,26 +211,24 @@ impl<'a> Elaborator<'a> {
                 // at this point, only the side-effecting skeleton),
                 // then it must be computed and thus we give it zero
                 // cost.
-                ValueDef::Result(inst, _) if self.func.layout.inst_block(inst).is_some() => {
-                    best[value] = (Cost::zero(), value);
-                }
                 ValueDef::Result(inst, _) => {
-                    trace!(" -> value {}: result, computing cost", value);
-                    let inst_data = &self.func.dfg.insts[inst];
-                    let loop_level = self
-                        .func
-                        .layout
-                        .inst_block(inst)
-                        .map(|block| self.loop_analysis.loop_level(block))
-                        .unwrap_or(LoopLevel::root());
-                    // N.B.: at this point we know that the opcode is
-                    // pure, so `pure_op_cost`'s precondition is
-                    // satisfied.
-                    let cost = self.func.dfg.inst_values(inst).fold(
-                        pure_op_cost(inst_data.opcode()).at_level(loop_level.level()),
-                        |cost, value| cost + best[value].0,
-                    );
-                    best[value] = (cost, value);
+                    if let Some(_) = self.func.layout.inst_block(inst) {
+                        best[value] = (Cost::zero(), value);
+                    } else {
+                        trace!(" -> value {}: result, computing cost", value);
+                        let inst_data = &self.func.dfg.insts[inst];
+                        // N.B.: at this point we know that the opcode is
+                        // pure, so `pure_op_cost`'s precondition is
+                        // satisfied.
+                        let cost = self
+                            .func
+                            .dfg
+                            .inst_values(inst)
+                            .fold(pure_op_cost(inst_data.opcode()), |cost, value| {
+                                cost + best[value].0
+                            });
+                        best[value] = (cost, value);
+                    }
                 }
             };
             debug_assert_ne!(best[value].0, Cost::infinity());
@@ -259,12 +257,9 @@ impl<'a> Elaborator<'a> {
     }
 
     fn process_elab_stack(&mut self) {
-        while let Some(entry) = self.elab_stack.last() {
+        while let Some(entry) = self.elab_stack.pop() {
             match entry {
-                &ElabStackEntry::Start { value, before } => {
-                    // We always replace the Start entry, so pop it now.
-                    self.elab_stack.pop();
-
+                ElabStackEntry::Start { value, before } => {
                     debug_assert_ne!(value, Value::reserved_value());
                     let value = self.func.dfg.resolve_aliases(value);
 
@@ -376,15 +371,13 @@ impl<'a> Elaborator<'a> {
                     }
                 }
 
-                &ElabStackEntry::PendingInst {
+                ElabStackEntry::PendingInst {
                     inst,
                     result_idx,
                     num_args,
                     remat,
                     before,
                 } => {
-                    self.elab_stack.pop();
-
                     trace!(
                         "PendingInst: {} result {} args {} remat {} before {}",
                         inst,
diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml
index 3d359437e..43980e8dc 100644
--- a/crates/c-api/Cargo.toml
+++ b/crates/c-api/Cargo.toml
@@ -11,17 +11,19 @@ publish = false
 
 [lib]
 name = "wasmtime"
-crate-type = ["staticlib", "cdylib", "rlib"]
+crate-type = ["staticlib", "cdylib"]
 doc = false
 test = false
 doctest = false
 
 [dependencies]
-env_logger = { workspace = true }
+env_logger = { workspace = true, optional = true }
 anyhow = { workspace = true }
 once_cell = { workspace = true }
 wasmtime = { workspace = true, features = ['cranelift'] }
 wasmtime-c-api-macros = { path = "macros" }
+log = { workspace = true }
+tracing = { workspace = true }
 
 # Optional dependency for the `wat2wasm` API
 wat = { workspace = true, optional = true }
@@ -36,9 +38,22 @@ wasi-common = { workspace = true, optional = true }
 futures = { workspace = true, optional = true }
 
 [features]
-default = ['profiling', 'wat', 'wasi', 'cache', 'parallel-compilation', 'async']
+default = [
+  'profiling',
+  'wat',
+  'wasi',
+  'cache',
+  'parallel-compilation',
+  'async',
+  'coredump',
+  'addr2line',
+]
 async = ['wasmtime/async', 'futures']
 profiling = ["wasmtime/profiling"]
 cache = ["wasmtime/cache"]
 parallel-compilation = ['wasmtime/parallel-compilation']
 wasi = ['wasi-cap-std-sync', 'wasmtime-wasi', 'cap-std', 'wasi-common']
+logging = ['dep:env_logger']
+disable-logging = ["log/max_level_off", "tracing/max_level_off"]
+coredump = ["wasmtime/coredump"]
+addr2line = ["wasmtime/addr2line"]
diff --git a/crates/c-api/src/engine.rs b/crates/c-api/src/engine.rs
index 67785fc03..06a2b1b3f 100644
--- a/crates/c-api/src/engine.rs
+++ b/crates/c-api/src/engine.rs
@@ -19,6 +19,7 @@ pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
     // Note that we `drop` the result here since this fails after the first
     // initialization attempt. We don't mind that though because this function
     // can be called multiple times, so we just ignore the result.
+    #[cfg(feature = "logging")]
     drop(env_logger::try_init());
 
     Box::new(wasm_engine_t {
diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs
index cb0e45a42..2a194684f 100644
--- a/crates/wasi-http/src/lib.rs
+++ b/crates/wasi-http/src/lib.rs
@@ -10,9 +10,9 @@ pub mod bindings {
     wasmtime::component::bindgen!({
         path: "wit",
         interfaces: "
-            import wasi:http/incoming-handler@0.2.0-rc-2023-10-18;
-            import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
-            import wasi:http/types@0.2.0-rc-2023-10-18;
+            import wasi:http/incoming-handler@0.2.0-rc-2023-11-05;
+            import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
+            import wasi:http/types@0.2.0-rc-2023-11-05;
         ",
         tracing: true,
         async: false,
diff --git a/crates/wasi-http/wit/command-extended.wit b/crates/wasi-http/wit/command-extended.wit
index 310b736ba..00cee3aaf 100644
--- a/crates/wasi-http/wit/command-extended.wit
+++ b/crates/wasi-http/wit/command-extended.wit
@@ -1,6 +1,6 @@
 // All of the same imports and exports available in the wasi:cli/command world
 // with addition of HTTP proxy related imports:
 world command-extended {
-  include wasi:cli/command@0.2.0-rc-2023-10-18;
-  import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
+  include wasi:cli/command@0.2.0-rc-2023-11-05;
+  import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
 }
diff --git a/crates/wasi-http/wit/deps/cli/command.wit b/crates/wasi-http/wit/deps/cli/command.wit
index d7ea2d91f..07925c037 100644
--- a/crates/wasi-http/wit/deps/cli/command.wit
+++ b/crates/wasi-http/wit/deps/cli/command.wit
@@ -1,4 +1,4 @@
-package wasi:cli@0.2.0-rc-2023-10-18;
+package wasi:cli@0.2.0-rc-2023-11-05;
 
 world command {
   include reactor;
diff --git a/crates/wasi-http/wit/deps/cli/reactor.wit b/crates/wasi-http/wit/deps/cli/reactor.wit
index 904b99467..4b829834c 100644
--- a/crates/wasi-http/wit/deps/cli/reactor.wit
+++ b/crates/wasi-http/wit/deps/cli/reactor.wit
@@ -1,23 +1,23 @@
-package wasi:cli@0.2.0-rc-2023-10-18;
+package wasi:cli@0.2.0-rc-2023-11-05;
 
 world reactor {
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/types@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
-  import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
-  import wasi:sockets/network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
-  import wasi:io/poll@0.2.0-rc-2023-10-18;
-  import wasi:io/streams@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/types@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/preopens@0.2.0-rc-2023-11-05;
+  import wasi:sockets/instance-network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-05;
+  import wasi:sockets/network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure-seed@0.2.0-rc-2023-11-05;
+  import wasi:io/poll@0.2.0-rc-2023-11-05;
+  import wasi:io/streams@0.2.0-rc-2023-11-05;
 
   import environment;
   import exit;
diff --git a/crates/wasi-http/wit/deps/cli/stdio.wit b/crates/wasi-http/wit/deps/cli/stdio.wit
index 513ca92de..6058260cf 100644
--- a/crates/wasi-http/wit/deps/cli/stdio.wit
+++ b/crates/wasi-http/wit/deps/cli/stdio.wit
@@ -1,17 +1,17 @@
 interface stdin {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream};
 
   get-stdin: func() -> input-stream;
 }
 
 interface stdout {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   get-stdout: func() -> output-stream;
 }
 
 interface stderr {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   get-stderr: func() -> output-stream;
 }
diff --git a/crates/wasi-http/wit/deps/clocks/monotonic-clock.wit b/crates/wasi-http/wit/deps/clocks/monotonic-clock.wit
index c0ecb529b..a3f7fe25c 100644
--- a/crates/wasi-http/wit/deps/clocks/monotonic-clock.wit
+++ b/crates/wasi-http/wit/deps/clocks/monotonic-clock.wit
@@ -9,7 +9,7 @@
 ///
 /// It is intended for measuring elapsed time.
 interface monotonic-clock {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
 
     /// A timestamp in nanoseconds.
     type instant = u64;
diff --git a/crates/wasi-http/wit/deps/clocks/world.wit b/crates/wasi-http/wit/deps/clocks/world.wit
index cdfb51d9a..a53d025b8 100644
--- a/crates/wasi-http/wit/deps/clocks/world.wit
+++ b/crates/wasi-http/wit/deps/clocks/world.wit
@@ -1,4 +1,4 @@
-package wasi:clocks@0.2.0-rc-2023-10-18;
+package wasi:clocks@0.2.0-rc-2023-11-05;
 
 world imports {
     import monotonic-clock;
diff --git a/crates/wasi-http/wit/deps/filesystem/types.wit b/crates/wasi-http/wit/deps/filesystem/types.wit
index af3613543..81dcde908 100644
--- a/crates/wasi-http/wit/deps/filesystem/types.wit
+++ b/crates/wasi-http/wit/deps/filesystem/types.wit
@@ -23,8 +23,8 @@
 ///
 /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md
 interface types {
-    use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream, error};
-    use wasi:clocks/wall-clock@0.2.0-rc-2023-10-18.{datetime};
+    use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream, error};
+    use wasi:clocks/wall-clock@0.2.0-rc-2023-11-05.{datetime};
 
     /// File size or length of a region within a file.
     type filesize = u64;
diff --git a/crates/wasi-http/wit/deps/filesystem/world.wit b/crates/wasi-http/wit/deps/filesystem/world.wit
index 3f953f893..a4654e4cc 100644
--- a/crates/wasi-http/wit/deps/filesystem/world.wit
+++ b/crates/wasi-http/wit/deps/filesystem/world.wit
@@ -1,4 +1,4 @@
-package wasi:filesystem@0.2.0-rc-2023-10-18;
+package wasi:filesystem@0.2.0-rc-2023-11-05;
 
 world imports {
     import types;
diff --git a/crates/wasi-http/wit/deps/http/proxy.wit b/crates/wasi-http/wit/deps/http/proxy.wit
index dde0659d6..7d0e84eb2 100644
--- a/crates/wasi-http/wit/deps/http/proxy.wit
+++ b/crates/wasi-http/wit/deps/http/proxy.wit
@@ -1,4 +1,4 @@
-package wasi:http@0.2.0-rc-2023-10-18;
+package wasi:http@0.2.0-rc-2023-11-05;
 
 // The `wasi:http/proxy` world captures a widely-implementable intersection of
 // hosts that includes HTTP forward and reverse proxies. Components targeting
@@ -6,21 +6,21 @@ package wasi:http@0.2.0-rc-2023-10-18;
 // outgoing HTTP requests.
 world proxy {
   // HTTP proxies have access to time and randomness.
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
 
   // Proxies have standard output and error streams which are expected to
   // terminate in a developer-facing console provided by the host.
-  import wasi:cli/stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/stderr@0.2.0-rc-2023-10-18;
+  import wasi:cli/stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/stderr@0.2.0-rc-2023-11-05;
 
   // TODO: this is a temporary workaround until component tooling is able to
   // gracefully handle the absence of stdin. Hosts must return an eof stream
   // for this import, which is what wasi-libc + tooling will do automatically
   // when this import is properly removed.
-  import wasi:cli/stdin@0.2.0-rc-2023-10-18;
+  import wasi:cli/stdin@0.2.0-rc-2023-11-05;
 
   // This is the default handler to use when user code simply wants to make an
   // HTTP request (e.g., via `fetch()`).
diff --git a/crates/wasi-http/wit/deps/http/types.wit b/crates/wasi-http/wit/deps/http/types.wit
index 2cd2fe219..bca0d6528 100644
--- a/crates/wasi-http/wit/deps/http/types.wit
+++ b/crates/wasi-http/wit/deps/http/types.wit
@@ -2,8 +2,8 @@
 // define the HTTP resource types and operations used by the component's
 // imported and exported interfaces.
 interface types {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream};
-  use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream};
+  use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
 
   // This type corresponds to HTTP standard Methods.
   variant method {
diff --git a/crates/wasi-http/wit/deps/io/poll.wit b/crates/wasi-http/wit/deps/io/poll.wit
index 047389d21..52a4957dc 100644
--- a/crates/wasi-http/wit/deps/io/poll.wit
+++ b/crates/wasi-http/wit/deps/io/poll.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 /// A poll API intended to let users wait for I/O events on multiple handles
 /// at once.
diff --git a/crates/wasi-http/wit/deps/io/streams.wit b/crates/wasi-http/wit/deps/io/streams.wit
index 968795b2d..9442f60c0 100644
--- a/crates/wasi-http/wit/deps/io/streams.wit
+++ b/crates/wasi-http/wit/deps/io/streams.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 /// WASI I/O is an I/O abstraction API which is currently focused on providing
 /// stream types.
diff --git a/crates/wasi-http/wit/deps/io/world.wit b/crates/wasi-http/wit/deps/io/world.wit
index 3627c9d68..4b9b21da6 100644
--- a/crates/wasi-http/wit/deps/io/world.wit
+++ b/crates/wasi-http/wit/deps/io/world.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 world imports {
     import streams;
diff --git a/crates/wasi-http/wit/deps/random/world.wit b/crates/wasi-http/wit/deps/random/world.wit
index dcbff9384..9128dd68f 100644
--- a/crates/wasi-http/wit/deps/random/world.wit
+++ b/crates/wasi-http/wit/deps/random/world.wit
@@ -1,4 +1,4 @@
-package wasi:random@0.2.0-rc-2023-10-18;
+package wasi:random@0.2.0-rc-2023-11-05;
 
 world imports {
     import random;
diff --git a/crates/wasi-http/wit/deps/sockets/ip-name-lookup.wit b/crates/wasi-http/wit/deps/sockets/ip-name-lookup.wit
index 4f9432991..5ffe2a217 100644
--- a/crates/wasi-http/wit/deps/sockets/ip-name-lookup.wit
+++ b/crates/wasi-http/wit/deps/sockets/ip-name-lookup.wit
@@ -1,6 +1,6 @@
 
 interface ip-name-lookup {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-address, ip-address-family};
 
 
diff --git a/crates/wasi-http/wit/deps/sockets/tcp.wit b/crates/wasi-http/wit/deps/sockets/tcp.wit
index c316a7245..b9073b775 100644
--- a/crates/wasi-http/wit/deps/sockets/tcp.wit
+++ b/crates/wasi-http/wit/deps/sockets/tcp.wit
@@ -1,7 +1,7 @@
 
 interface tcp {
-    use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream};
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-socket-address, ip-address-family};
 
     enum shutdown-type {
diff --git a/crates/wasi-http/wit/deps/sockets/udp.wit b/crates/wasi-http/wit/deps/sockets/udp.wit
index a86226f01..8641cc2c5 100644
--- a/crates/wasi-http/wit/deps/sockets/udp.wit
+++ b/crates/wasi-http/wit/deps/sockets/udp.wit
@@ -1,6 +1,6 @@
 
 interface udp {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-socket-address, ip-address-family};
 
 
diff --git a/crates/wasi-http/wit/deps/sockets/world.wit b/crates/wasi-http/wit/deps/sockets/world.wit
index d16530c38..979703869 100644
--- a/crates/wasi-http/wit/deps/sockets/world.wit
+++ b/crates/wasi-http/wit/deps/sockets/world.wit
@@ -1,4 +1,4 @@
-package wasi:sockets@0.2.0-rc-2023-10-18;
+package wasi:sockets@0.2.0-rc-2023-11-05;
 
 world imports {
     import instance-network;
diff --git a/crates/wasi-http/wit/main.wit b/crates/wasi-http/wit/main.wit
index f3a4e60cc..90aa28ad3 100644
--- a/crates/wasi-http/wit/main.wit
+++ b/crates/wasi-http/wit/main.wit
@@ -3,31 +3,31 @@ package wasmtime:wasi;
 // All of the same imports available in the wasi:cli/command world, but no
 // export required:
 world preview1-adapter-reactor {
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/types@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
-  import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
-  import wasi:sockets/network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
-  import wasi:io/poll@0.2.0-rc-2023-10-18;
-  import wasi:io/streams@0.2.0-rc-2023-10-18;
-  import wasi:cli/environment@0.2.0-rc-2023-10-18;
-  import wasi:cli/exit@0.2.0-rc-2023-10-18;
-  import wasi:cli/stdin@0.2.0-rc-2023-10-18;
-  import wasi:cli/stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/stderr@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-input@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-output@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stdin@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stderr@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/types@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/preopens@0.2.0-rc-2023-11-05;
+  import wasi:sockets/instance-network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-05;
+  import wasi:sockets/network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure-seed@0.2.0-rc-2023-11-05;
+  import wasi:io/poll@0.2.0-rc-2023-11-05;
+  import wasi:io/streams@0.2.0-rc-2023-11-05;
+  import wasi:cli/environment@0.2.0-rc-2023-11-05;
+  import wasi:cli/exit@0.2.0-rc-2023-11-05;
+  import wasi:cli/stdin@0.2.0-rc-2023-11-05;
+  import wasi:cli/stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/stderr@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-input@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-output@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stdin@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stderr@0.2.0-rc-2023-11-05;
 }
diff --git a/crates/wasi-preview1-component-adapter/src/descriptors.rs b/crates/wasi-preview1-component-adapter/src/descriptors.rs
index 1c0ba4609..1eced19ab 100644
--- a/crates/wasi-preview1-component-adapter/src/descriptors.rs
+++ b/crates/wasi-preview1-component-adapter/src/descriptors.rs
@@ -181,7 +181,7 @@ impl Descriptors {
         }))
         .trapping_unwrap();
 
-        #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0-rc-2023-10-18")]
+        #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0-rc-2023-11-05")]
         #[allow(improper_ctypes)] // FIXME(bytecodealliance/wit-bindgen#684)
         extern "C" {
             #[link_name = "get-directories"]
diff --git a/crates/wasi-preview1-component-adapter/src/lib.rs b/crates/wasi-preview1-component-adapter/src/lib.rs
index ff09003d1..08978baa5 100644
--- a/crates/wasi-preview1-component-adapter/src/lib.rs
+++ b/crates/wasi-preview1-component-adapter/src/lib.rs
@@ -58,7 +58,7 @@ pub mod bindings {
     });
 }
 
-#[export_name = "wasi:cli/run@0.2.0-rc-2023-10-18#run"]
+#[export_name = "wasi:cli/run@0.2.0-rc-2023-11-05#run"]
 #[cfg(feature = "command")]
 pub unsafe extern "C" fn run() -> u32 {
     #[link(wasm_import_module = "__main_module__")]
@@ -1774,7 +1774,7 @@ pub unsafe extern "C" fn poll_oneoff(
             });
         }
 
-        #[link(wasm_import_module = "wasi:io/poll@0.2.0-rc-2023-10-18")]
+        #[link(wasm_import_module = "wasi:io/poll@0.2.0-rc-2023-11-05")]
         #[allow(improper_ctypes)] // FIXME(bytecodealliance/wit-bindgen#684)
         extern "C" {
             #[link_name = "poll-list"]
@@ -2495,7 +2495,7 @@ impl State {
 
     fn get_environment(&self) -> &[StrTuple] {
         if self.env_vars.get().is_none() {
-            #[link(wasm_import_module = "wasi:cli/environment@0.2.0-rc-2023-10-18")]
+            #[link(wasm_import_module = "wasi:cli/environment@0.2.0-rc-2023-11-05")]
             extern "C" {
                 #[link_name = "get-environment"]
                 fn get_environment_import(rval: *mut StrTupleList);
@@ -2519,7 +2519,7 @@ impl State {
 
     fn get_args(&self) -> &[WasmStr] {
         if self.args.get().is_none() {
-            #[link(wasm_import_module = "wasi:cli/environment@0.2.0-rc-2023-10-18")]
+            #[link(wasm_import_module = "wasi:cli/environment@0.2.0-rc-2023-11-05")]
             extern "C" {
                 #[link_name = "get-arguments"]
                 fn get_args_import(rval: *mut WasmStrList);
diff --git a/crates/wasi/src/preview2/mod.rs b/crates/wasi/src/preview2/mod.rs
index 6208cb112..abdfe4df5 100644
--- a/crates/wasi/src/preview2/mod.rs
+++ b/crates/wasi/src/preview2/mod.rs
@@ -68,9 +68,9 @@ pub mod bindings {
             wasmtime::component::bindgen!({
                 path: "wit",
                 interfaces: "
-                    import wasi:io/poll@0.2.0-rc-2023-10-18;
-                    import wasi:io/streams@0.2.0-rc-2023-10-18;
-                    import wasi:filesystem/types@0.2.0-rc-2023-10-18;
+                    import wasi:io/poll@0.2.0-rc-2023-11-05;
+                    import wasi:io/streams@0.2.0-rc-2023-11-05;
+                    import wasi:filesystem/types@0.2.0-rc-2023-11-05;
                 ",
                 tracing: true,
                 trappable_error_type: {
diff --git a/crates/wasi/wit/command-extended.wit b/crates/wasi/wit/command-extended.wit
index 310b736ba..00cee3aaf 100644
--- a/crates/wasi/wit/command-extended.wit
+++ b/crates/wasi/wit/command-extended.wit
@@ -1,6 +1,6 @@
 // All of the same imports and exports available in the wasi:cli/command world
 // with addition of HTTP proxy related imports:
 world command-extended {
-  include wasi:cli/command@0.2.0-rc-2023-10-18;
-  import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
+  include wasi:cli/command@0.2.0-rc-2023-11-05;
+  import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
 }
diff --git a/crates/wasi/wit/deps/cli/command.wit b/crates/wasi/wit/deps/cli/command.wit
index d7ea2d91f..07925c037 100644
--- a/crates/wasi/wit/deps/cli/command.wit
+++ b/crates/wasi/wit/deps/cli/command.wit
@@ -1,4 +1,4 @@
-package wasi:cli@0.2.0-rc-2023-10-18;
+package wasi:cli@0.2.0-rc-2023-11-05;
 
 world command {
   include reactor;
diff --git a/crates/wasi/wit/deps/cli/reactor.wit b/crates/wasi/wit/deps/cli/reactor.wit
index 904b99467..4b829834c 100644
--- a/crates/wasi/wit/deps/cli/reactor.wit
+++ b/crates/wasi/wit/deps/cli/reactor.wit
@@ -1,23 +1,23 @@
-package wasi:cli@0.2.0-rc-2023-10-18;
+package wasi:cli@0.2.0-rc-2023-11-05;
 
 world reactor {
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/types@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
-  import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
-  import wasi:sockets/network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
-  import wasi:io/poll@0.2.0-rc-2023-10-18;
-  import wasi:io/streams@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/types@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/preopens@0.2.0-rc-2023-11-05;
+  import wasi:sockets/instance-network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-05;
+  import wasi:sockets/network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure-seed@0.2.0-rc-2023-11-05;
+  import wasi:io/poll@0.2.0-rc-2023-11-05;
+  import wasi:io/streams@0.2.0-rc-2023-11-05;
 
   import environment;
   import exit;
diff --git a/crates/wasi/wit/deps/cli/stdio.wit b/crates/wasi/wit/deps/cli/stdio.wit
index 513ca92de..6058260cf 100644
--- a/crates/wasi/wit/deps/cli/stdio.wit
+++ b/crates/wasi/wit/deps/cli/stdio.wit
@@ -1,17 +1,17 @@
 interface stdin {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream};
 
   get-stdin: func() -> input-stream;
 }
 
 interface stdout {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   get-stdout: func() -> output-stream;
 }
 
 interface stderr {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   get-stderr: func() -> output-stream;
 }
diff --git a/crates/wasi/wit/deps/clocks/monotonic-clock.wit b/crates/wasi/wit/deps/clocks/monotonic-clock.wit
index c0ecb529b..a3f7fe25c 100644
--- a/crates/wasi/wit/deps/clocks/monotonic-clock.wit
+++ b/crates/wasi/wit/deps/clocks/monotonic-clock.wit
@@ -9,7 +9,7 @@
 ///
 /// It is intended for measuring elapsed time.
 interface monotonic-clock {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
 
     /// A timestamp in nanoseconds.
     type instant = u64;
diff --git a/crates/wasi/wit/deps/clocks/world.wit b/crates/wasi/wit/deps/clocks/world.wit
index cdfb51d9a..a53d025b8 100644
--- a/crates/wasi/wit/deps/clocks/world.wit
+++ b/crates/wasi/wit/deps/clocks/world.wit
@@ -1,4 +1,4 @@
-package wasi:clocks@0.2.0-rc-2023-10-18;
+package wasi:clocks@0.2.0-rc-2023-11-05;
 
 world imports {
     import monotonic-clock;
diff --git a/crates/wasi/wit/deps/filesystem/types.wit b/crates/wasi/wit/deps/filesystem/types.wit
index af3613543..81dcde908 100644
--- a/crates/wasi/wit/deps/filesystem/types.wit
+++ b/crates/wasi/wit/deps/filesystem/types.wit
@@ -23,8 +23,8 @@
 ///
 /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md
 interface types {
-    use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream, error};
-    use wasi:clocks/wall-clock@0.2.0-rc-2023-10-18.{datetime};
+    use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream, error};
+    use wasi:clocks/wall-clock@0.2.0-rc-2023-11-05.{datetime};
 
     /// File size or length of a region within a file.
     type filesize = u64;
diff --git a/crates/wasi/wit/deps/filesystem/world.wit b/crates/wasi/wit/deps/filesystem/world.wit
index 3f953f893..a4654e4cc 100644
--- a/crates/wasi/wit/deps/filesystem/world.wit
+++ b/crates/wasi/wit/deps/filesystem/world.wit
@@ -1,4 +1,4 @@
-package wasi:filesystem@0.2.0-rc-2023-10-18;
+package wasi:filesystem@0.2.0-rc-2023-11-05;
 
 world imports {
     import types;
diff --git a/crates/wasi/wit/deps/http/proxy.wit b/crates/wasi/wit/deps/http/proxy.wit
index dde0659d6..7d0e84eb2 100644
--- a/crates/wasi/wit/deps/http/proxy.wit
+++ b/crates/wasi/wit/deps/http/proxy.wit
@@ -1,4 +1,4 @@
-package wasi:http@0.2.0-rc-2023-10-18;
+package wasi:http@0.2.0-rc-2023-11-05;
 
 // The `wasi:http/proxy` world captures a widely-implementable intersection of
 // hosts that includes HTTP forward and reverse proxies. Components targeting
@@ -6,21 +6,21 @@ package wasi:http@0.2.0-rc-2023-10-18;
 // outgoing HTTP requests.
 world proxy {
   // HTTP proxies have access to time and randomness.
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
 
   // Proxies have standard output and error streams which are expected to
   // terminate in a developer-facing console provided by the host.
-  import wasi:cli/stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/stderr@0.2.0-rc-2023-10-18;
+  import wasi:cli/stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/stderr@0.2.0-rc-2023-11-05;
 
   // TODO: this is a temporary workaround until component tooling is able to
   // gracefully handle the absence of stdin. Hosts must return an eof stream
   // for this import, which is what wasi-libc + tooling will do automatically
   // when this import is properly removed.
-  import wasi:cli/stdin@0.2.0-rc-2023-10-18;
+  import wasi:cli/stdin@0.2.0-rc-2023-11-05;
 
   // This is the default handler to use when user code simply wants to make an
   // HTTP request (e.g., via `fetch()`).
diff --git a/crates/wasi/wit/deps/http/types.wit b/crates/wasi/wit/deps/http/types.wit
index 2cd2fe219..bca0d6528 100644
--- a/crates/wasi/wit/deps/http/types.wit
+++ b/crates/wasi/wit/deps/http/types.wit
@@ -2,8 +2,8 @@
 // define the HTTP resource types and operations used by the component's
 // imported and exported interfaces.
 interface types {
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream};
-  use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream};
+  use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
 
   // This type corresponds to HTTP standard Methods.
   variant method {
diff --git a/crates/wasi/wit/deps/io/poll.wit b/crates/wasi/wit/deps/io/poll.wit
index 047389d21..52a4957dc 100644
--- a/crates/wasi/wit/deps/io/poll.wit
+++ b/crates/wasi/wit/deps/io/poll.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 /// A poll API intended to let users wait for I/O events on multiple handles
 /// at once.
diff --git a/crates/wasi/wit/deps/io/streams.wit b/crates/wasi/wit/deps/io/streams.wit
index 968795b2d..9442f60c0 100644
--- a/crates/wasi/wit/deps/io/streams.wit
+++ b/crates/wasi/wit/deps/io/streams.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 /// WASI I/O is an I/O abstraction API which is currently focused on providing
 /// stream types.
diff --git a/crates/wasi/wit/deps/io/world.wit b/crates/wasi/wit/deps/io/world.wit
index 3627c9d68..4b9b21da6 100644
--- a/crates/wasi/wit/deps/io/world.wit
+++ b/crates/wasi/wit/deps/io/world.wit
@@ -1,4 +1,4 @@
-package wasi:io@0.2.0-rc-2023-10-18;
+package wasi:io@0.2.0-rc-2023-11-05;
 
 world imports {
     import streams;
diff --git a/crates/wasi/wit/deps/random/world.wit b/crates/wasi/wit/deps/random/world.wit
index dcbff9384..9128dd68f 100644
--- a/crates/wasi/wit/deps/random/world.wit
+++ b/crates/wasi/wit/deps/random/world.wit
@@ -1,4 +1,4 @@
-package wasi:random@0.2.0-rc-2023-10-18;
+package wasi:random@0.2.0-rc-2023-11-05;
 
 world imports {
     import random;
diff --git a/crates/wasi/wit/deps/sockets/ip-name-lookup.wit b/crates/wasi/wit/deps/sockets/ip-name-lookup.wit
index 4f9432991..5ffe2a217 100644
--- a/crates/wasi/wit/deps/sockets/ip-name-lookup.wit
+++ b/crates/wasi/wit/deps/sockets/ip-name-lookup.wit
@@ -1,6 +1,6 @@
 
 interface ip-name-lookup {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-address, ip-address-family};
 
 
diff --git a/crates/wasi/wit/deps/sockets/tcp.wit b/crates/wasi/wit/deps/sockets/tcp.wit
index c316a7245..b9073b775 100644
--- a/crates/wasi/wit/deps/sockets/tcp.wit
+++ b/crates/wasi/wit/deps/sockets/tcp.wit
@@ -1,7 +1,7 @@
 
 interface tcp {
-    use wasi:io/streams@0.2.0-rc-2023-10-18.{input-stream, output-stream};
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-socket-address, ip-address-family};
 
     enum shutdown-type {
diff --git a/crates/wasi/wit/deps/sockets/udp.wit b/crates/wasi/wit/deps/sockets/udp.wit
index a86226f01..8641cc2c5 100644
--- a/crates/wasi/wit/deps/sockets/udp.wit
+++ b/crates/wasi/wit/deps/sockets/udp.wit
@@ -1,6 +1,6 @@
 
 interface udp {
-    use wasi:io/poll@0.2.0-rc-2023-10-18.{pollable};
+    use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
     use network.{network, error-code, ip-socket-address, ip-address-family};
 
 
diff --git a/crates/wasi/wit/deps/sockets/world.wit b/crates/wasi/wit/deps/sockets/world.wit
index d16530c38..979703869 100644
--- a/crates/wasi/wit/deps/sockets/world.wit
+++ b/crates/wasi/wit/deps/sockets/world.wit
@@ -1,4 +1,4 @@
-package wasi:sockets@0.2.0-rc-2023-10-18;
+package wasi:sockets@0.2.0-rc-2023-11-05;
 
 world imports {
     import instance-network;
diff --git a/crates/wasi/wit/main.wit b/crates/wasi/wit/main.wit
index f3a4e60cc..90aa28ad3 100644
--- a/crates/wasi/wit/main.wit
+++ b/crates/wasi/wit/main.wit
@@ -3,31 +3,31 @@ package wasmtime:wasi;
 // All of the same imports available in the wasi:cli/command world, but no
 // export required:
 world preview1-adapter-reactor {
-  import wasi:clocks/wall-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-10-18;
-  import wasi:clocks/timezone@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/types@0.2.0-rc-2023-10-18;
-  import wasi:filesystem/preopens@0.2.0-rc-2023-10-18;
-  import wasi:sockets/instance-network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-10-18;
-  import wasi:sockets/network@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/tcp@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-10-18;
-  import wasi:sockets/udp@0.2.0-rc-2023-10-18;
-  import wasi:random/random@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure@0.2.0-rc-2023-10-18;
-  import wasi:random/insecure-seed@0.2.0-rc-2023-10-18;
-  import wasi:io/poll@0.2.0-rc-2023-10-18;
-  import wasi:io/streams@0.2.0-rc-2023-10-18;
-  import wasi:cli/environment@0.2.0-rc-2023-10-18;
-  import wasi:cli/exit@0.2.0-rc-2023-10-18;
-  import wasi:cli/stdin@0.2.0-rc-2023-10-18;
-  import wasi:cli/stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/stderr@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-input@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-output@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stdin@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stdout@0.2.0-rc-2023-10-18;
-  import wasi:cli/terminal-stderr@0.2.0-rc-2023-10-18;
+  import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
+  import wasi:clocks/timezone@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/types@0.2.0-rc-2023-11-05;
+  import wasi:filesystem/preopens@0.2.0-rc-2023-11-05;
+  import wasi:sockets/instance-network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-05;
+  import wasi:sockets/network@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/tcp@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-05;
+  import wasi:sockets/udp@0.2.0-rc-2023-11-05;
+  import wasi:random/random@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure@0.2.0-rc-2023-11-05;
+  import wasi:random/insecure-seed@0.2.0-rc-2023-11-05;
+  import wasi:io/poll@0.2.0-rc-2023-11-05;
+  import wasi:io/streams@0.2.0-rc-2023-11-05;
+  import wasi:cli/environment@0.2.0-rc-2023-11-05;
+  import wasi:cli/exit@0.2.0-rc-2023-11-05;
+  import wasi:cli/stdin@0.2.0-rc-2023-11-05;
+  import wasi:cli/stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/stderr@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-input@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-output@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stdin@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stdout@0.2.0-rc-2023-11-05;
+  import wasi:cli/terminal-stderr@0.2.0-rc-2023-11-05;
 }
diff --git a/docs/WASI-tutorial.md b/docs/WASI-tutorial.md
index e1e83faeb..1ca52be10 100644
--- a/docs/WASI-tutorial.md
+++ b/docs/WASI-tutorial.md
@@ -240,7 +240,7 @@ links as well.
 `wasmtime` also has the ability to remap directories:
 
 ```
-$ wasmtime --dir=. --dir=/tmp::/var/tmp demo.wasm test.txt /tmp/somewhere.txt
+$ wasmtime --dir=. --dir=/var/tmp::/tmp demo.wasm test.txt /tmp/somewhere.txt
 $ cat /var/tmp/somewhere.txt
 hello world
 ```
diff --git a/src/commands/run.rs b/src/commands/run.rs
index dc7c8ab05..dfd24a002 100644
--- a/src/commands/run.rs
+++ b/src/commands/run.rs
@@ -37,12 +37,12 @@ fn parse_env_var(s: &str) -> Result<(String, Option<String>)> {
 
 fn parse_dirs(s: &str) -> Result<(String, String)> {
     let mut parts = s.split("::");
-    let guest = parts.next().unwrap();
-    let host = match parts.next() {
-        Some(host) => host,
-        None => guest,
+    let host = parts.next().unwrap();
+    let guest = match parts.next() {
+        Some(guest) => guest,
+        None => host,
     };
-    Ok((guest.into(), host.into()))
+    Ok((host.into(), guest.into()))
 }
 
 fn parse_preloads(s: &str) -> Result<(String, PathBuf)> {
@@ -62,11 +62,11 @@ pub struct RunCommand {
 
     /// Grant access of a host directory to a guest.
     ///
-    /// If specified as just `GUEST_DIR` then the same directory name on the
-    /// host is made available within the guest. If specified as `GUEST::HOST`
+    /// If specified as just `HOST_DIR` then the same directory name on the
+    /// host is made available within the guest. If specified as `HOST::GUEST`
     /// then the `HOST` directory is opened and made available as the name
     /// `GUEST` in the guest.
-    #[clap(long = "dir", value_name = "GUEST_DIR[::HOST_DIR]", value_parser = parse_dirs)]
+    #[clap(long = "dir", value_name = "HOST_DIR[::GUEST_DIR]", value_parser = parse_dirs)]
     dirs: Vec<(String, String)>,
 
     /// Pass an environment variable to the program.
@@ -233,7 +233,7 @@ impl RunCommand {
     fn compute_preopen_dirs(&self) -> Result<Vec<(String, Dir)>> {
         let mut preopen_dirs = Vec::new();
 
-        for (guest, host) in self.dirs.iter() {
+        for (host, guest) in self.dirs.iter() {
             preopen_dirs.push((
                 guest.clone(),
                 Dir::open_ambient_dir(host, ambient_authority())


Test patch:
diff --git a/crates/wasi-http/wit/test.wit b/crates/wasi-http/wit/test.wit
index 472aeccd3..5e7557ed6 100644
--- a/crates/wasi-http/wit/test.wit
+++ b/crates/wasi-http/wit/test.wit
@@ -1,20 +1,20 @@
 // only used as part of `test-programs`
 world test-reactor {
-  include wasi:cli/reactor@0.2.0-rc-2023-10-18;
+  include wasi:cli/reactor@0.2.0-rc-2023-11-05;
 
   export add-strings: func(s: list<string>) -> u32;
   export get-strings: func() -> list<string>;
 
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   export write-strings-to: func(o: output-stream) -> result;
 
-  use wasi:filesystem/types@0.2.0-rc-2023-10-18.{descriptor-stat};
+  use wasi:filesystem/types@0.2.0-rc-2023-11-05.{descriptor-stat};
   export pass-an-imported-record: func(d: descriptor-stat) -> string;
 }
 
 world test-command {
-  include wasi:cli/reactor@0.2.0-rc-2023-10-18;
-  import wasi:http/types@0.2.0-rc-2023-10-18;
-  import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
+  include wasi:cli/reactor@0.2.0-rc-2023-11-05;
+  import wasi:http/types@0.2.0-rc-2023-11-05;
+  import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
 }
diff --git a/crates/wasi/wit/test.wit b/crates/wasi/wit/test.wit
index 472aeccd3..5e7557ed6 100644
--- a/crates/wasi/wit/test.wit
+++ b/crates/wasi/wit/test.wit
@@ -1,20 +1,20 @@
 // only used as part of `test-programs`
 world test-reactor {
-  include wasi:cli/reactor@0.2.0-rc-2023-10-18;
+  include wasi:cli/reactor@0.2.0-rc-2023-11-05;
 
   export add-strings: func(s: list<string>) -> u32;
   export get-strings: func() -> list<string>;
 
-  use wasi:io/streams@0.2.0-rc-2023-10-18.{output-stream};
+  use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
 
   export write-strings-to: func(o: output-stream) -> result;
 
-  use wasi:filesystem/types@0.2.0-rc-2023-10-18.{descriptor-stat};
+  use wasi:filesystem/types@0.2.0-rc-2023-11-05.{descriptor-stat};
   export pass-an-imported-record: func(d: descriptor-stat) -> string;
 }
 
 world test-command {
-  include wasi:cli/reactor@0.2.0-rc-2023-10-18;
-  import wasi:http/types@0.2.0-rc-2023-10-18;
-  import wasi:http/outgoing-handler@0.2.0-rc-2023-10-18;
+  include wasi:cli/reactor@0.2.0-rc-2023-11-05;
+  import wasi:http/types@0.2.0-rc-2023-11-05;
+  import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
 }
diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs
index b67ecb612..2c8aa8122 100644
--- a/tests/all/cli_tests.rs
+++ b/tests/all/cli_tests.rs
@@ -1116,7 +1116,7 @@ mod test_programs {
         run_wasmtime(&[
             "run",
             "-Wcomponent-model",
-            &format!("--dir=/::{}", dir.path().to_str().unwrap()),
+            &format!("--dir={}::/", dir.path().to_str().unwrap()),
             CLI_FILE_READ_COMPONENT,
         ])?;
         Ok(())
@@ -1132,7 +1132,7 @@ mod test_programs {
         run_wasmtime(&[
             "run",
             "-Wcomponent-model",
-            &format!("--dir=/::{}", dir.path().to_str().unwrap()),
+            &format!("--dir={}::/", dir.path().to_str().unwrap()),
             CLI_FILE_APPEND_COMPONENT,
         ])?;
 
@@ -1157,7 +1157,7 @@ mod test_programs {
         run_wasmtime(&[
             "run",
             "-Wcomponent-model",
-            &format!("--dir=/::{}", dir.path().to_str().unwrap()),
+            &format!("--dir={}::/", dir.path().to_str().unwrap()),
             CLI_FILE_DIR_SYNC_COMPONENT,
         ])?;
 
@@ -1211,7 +1211,7 @@ mod test_programs {
         run_wasmtime(&[
             "run",
             "-Wcomponent-model",
-            &format!("--dir=/::{}", dir.path().to_str().unwrap()),
+            &format!("--dir={}::/", dir.path().to_str().unwrap()),
             CLI_DIRECTORY_LIST_COMPONENT,
         ])?;
         Ok(())
diff --git a/tests/all/cli_tests/component-basic.wat b/tests/all/cli_tests/component-basic.wat
index 55ce9ed26..fbbaffcb6 100644
--- a/tests/all/cli_tests/component-basic.wat
+++ b/tests/all/cli_tests/component-basic.wat
@@ -7,6 +7,6 @@
   (func $run (result (result))
     (canon lift (core func $i "run")))
 
-  (instance (export (interface "wasi:cli/run@0.2.0-rc-2023-10-18"))
+  (instance (export (interface "wasi:cli/run@0.2.0-rc-2023-11-05"))
     (export "run" (func $run)))
 )
diff --git a/tests/all/wasi_testsuite.rs b/tests/all/wasi_testsuite.rs
index 093a633c9..9928182b0 100644
--- a/tests/all/wasi_testsuite.rs
+++ b/tests/all/wasi_testsuite.rs
@@ -110,7 +110,7 @@ fn build_command<P: AsRef<Path>>(module: P, extra_flags: &[&str], spec: &Spec) -
     if let Some(dirs) = &spec.dirs {
         for dir in dirs {
             cmd.arg("--dir");
-            cmd.arg(format!("{}::{}", dir, parent_dir.join(dir).display()));
+            cmd.arg(format!("{}::{}", parent_dir.join(dir).display(), dir));
         }
     }
     // Add environment variables as CLI arguments.