Repository: bytecodealliance/wasmtime
Pull request #9151 (2024-08-20 09:02:25)

Copy skeleton unit attributes for split DWARF
The skeleton unit may contain attributes that don't appear in the split unit. In particular, this includes DW_AT_ranges and DW_AT_comp_dir.

Also, set the correct form for the default directory in the line program. Previously, the different form meant that we emitted the directory again when a file used it. Copying the DW_AT_comp_dir attribute is required for use of the default directory to work successfully.


Patch:
diff --git a/ci/vendor-wit.sh b/ci/vendor-wit.sh
index cbb9948fe..55ffdf2a4 100755
--- a/ci/vendor-wit.sh
+++ b/ci/vendor-wit.sh
@@ -64,6 +64,6 @@ rm -rf $cache_dir
 # Separately (for now), vendor the `wasi-nn` WIT files since their retrieval is
 # slightly different than above.
 repo=https://raw.githubusercontent.com/WebAssembly/wasi-nn
-revision=0.2.0-rc-2024-06-25
+revision=0.2.0-rc-2024-08-19
 curl -L $repo/$revision/wasi-nn.witx -o crates/wasi-nn/witx/wasi-nn.witx
 curl -L $repo/$revision/wit/wasi-nn.wit -o crates/wasi-nn/wit/wasi-nn.wit
diff --git a/crates/cranelift/src/debug/transform/line_program.rs b/crates/cranelift/src/debug/transform/line_program.rs
index e9bea8be4..56835d6fe 100644
--- a/crates/cranelift/src/debug/transform/line_program.rs
+++ b/crates/cranelift/src/debug/transform/line_program.rs
@@ -61,7 +61,7 @@ where
         let out_comp_dir = match header.directory(0) {
             Some(comp_dir) => clone_line_string(
                 dwarf.attr_string(unit, comp_dir)?,
-                gimli::DW_FORM_strp,
+                gimli::DW_FORM_string,
                 out_strings,
             )?,
             None => write::LineString::String(Vec::new()),
diff --git a/crates/cranelift/src/debug/transform/unit.rs b/crates/cranelift/src/debug/transform/unit.rs
index 8689566db..1a2292b90 100644
--- a/crates/cranelift/src/debug/transform/unit.rs
+++ b/crates/cranelift/src/debug/transform/unit.rs
@@ -305,6 +305,26 @@ pub(crate) fn clone_unit(
                     FileAttributeContext::Root(Some(debug_line_offset)),
                     isa,
                 )?;
+                if split_unit.is_some() {
+                    if let Some((_, skeleton_entry)) = skeleton_unit.entries().next_dfs()? {
+                        clone_die_attributes(
+                            skeleton_dwarf,
+                            skeleton_unit,
+                            skeleton_entry,
+                            addr_tr,
+                            None,
+                            comp_unit,
+                            root_id,
+                            None,
+                            None,
+                            out_strings,
+                            &mut pending_die_refs,
+                            &mut pending_di_refs,
+                            FileAttributeContext::Root(Some(debug_line_offset)),
+                            isa,
+                        )?;
+                    }
+                }
 
                 let (wp_die_id, vmctx_die_id) =
                     add_internal_types(comp_unit, root_id, out_strings, memory_offset);
diff --git a/crates/wasi-nn/src/wit.rs b/crates/wasi-nn/src/wit.rs
index e0c740232..adc9ca462 100644
--- a/crates/wasi-nn/src/wit.rs
+++ b/crates/wasi-nn/src/wit.rs
@@ -329,14 +329,6 @@ impl gen::tensor::HostTensor for WasiNnView<'_> {
 }
 
 impl gen::errors::HostError for WasiNnView<'_> {
-    fn new(
-        &mut self,
-        _code: gen::errors::ErrorCode,
-        _data: String,
-    ) -> wasmtime::Result<Resource<Error>> {
-        unimplemented!("this should be removed; see https://github.com/WebAssembly/wasi-nn/pull/76")
-    }
-
     fn code(&mut self, error: Resource<Error>) -> wasmtime::Result<gen::errors::ErrorCode> {
         let error = self.table.get(&error)?;
         match error.code {
diff --git a/crates/wasi-nn/wit/wasi-nn.wit b/crates/wasi-nn/wit/wasi-nn.wit
index 872e8cd7d..2ae501510 100644
--- a/crates/wasi-nn/wit/wasi-nn.wit
+++ b/crates/wasi-nn/wit/wasi-nn.wit
@@ -1,4 +1,4 @@
-package wasi:nn@0.2.0-rc-2024-06-25;
+package wasi:nn@0.2.0-rc-2024-08-19;
 
 /// `wasi-nn` is a WASI API for performing machine learning (ML) inference. The API is not (yet)
 /// capable of performing ML training. WebAssembly programs that want to use a host's ML
@@ -157,8 +157,6 @@ interface errors {
     }
 
     resource error {
-        constructor(code: error-code, data: string);
-
         /// Return the error code.
         code: func() -> error-code;
 


Test patch:
diff --git a/tests/all/debug/translate.rs b/tests/all/debug/translate.rs
index 9c2fe7023..15c314ea2 100644
--- a/tests/all/debug/translate.rs
+++ b/tests/all/debug/translate.rs
@@ -203,6 +203,9 @@ check: DW_TAG_compile_unit
 check:   DW_AT_producer	("clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)")
 check:   DW_AT_language	(DW_LANG_C11)
 check:   DW_AT_name	("dwarf_fission.c")
+check:   DW_AT_ranges	(0x00000000
+check:   DW_AT_stmt_list	(0x00000000)
+check:   DW_AT_comp_dir	("C:\\tmp\\dwarfc")
     "##,
     )
 }