Skip to content

Commit 99396b1

Browse files
committed
fix(component): resolve comprehensive compilation error cascade in wrt-component
This commit systematically resolves a cascade of 1984 compilation errors in the wrt-component crate that were preventing the WebAssembly Component Model implementation from building successfully. Key fixes implemented: - Add missing wrt-platform dependency to resolve 1984 initial compilation errors - Fix Result<T, Error> patterns throughout async modules, replacing with Result<T> to align with wrt-error crate conventions - Resolve ComponentValue import conflicts in async_types.rs by removing duplicates - Fix sync module import paths from wrt_foundation::sync to wrt_sync - Add placeholder types for missing dependencies: LiftingContext, LoweringContext, TimeBoundedConfig, Instance, Runtime, PostReturnRegistry - Resolve circular import in cross_component_communication by correcting component_communication module path - Fix memory allocation issues in safe_managed_alloc\! macro calls by using constant values instead of runtime-computed buffer sizes - Add missing Error imports in resource_lifecycle modules - Correct import paths for ResourceOperation from wrt_format to wrt_foundation - Fix conditional compilation directives for instance_no_std vs instance - Resolve BoundedBufferPool import path issues - Fix alloc:: prefix usage for std vs no_std feature flag combinations The fixes restore the entire compilation pipeline for the WebAssembly Component Model implementation, enabling proper async operation handling, canonical ABI processing, resource lifecycle management, and cross-component communication. All changes maintain compatibility with both std and no_std environments while preserving ASIL safety compliance requirements.
1 parent 9ce368c commit 99396b1

34 files changed

+331
-236
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wrt-component/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ wrt-host = { workspace = true, default-features = false }
1919
wrt-foundation = { workspace = true, default-features = false }
2020
wrt-intercept = { workspace = true, default-features = false }
2121
wrt-decoder = { workspace = true, default-features = false, optional = true }
22+
wrt-platform = { workspace = true, default-features = false }
2223
wrt-runtime = { workspace = true, default-features = false }
2324
wrt-sync = { workspace = true, default-features = false }
2425

@@ -41,6 +42,7 @@ std = [
4142
"wrt-host/std",
4243
"wrt-intercept/std",
4344
"wrt-decoder/std",
45+
"wrt-platform/std",
4446
"wrt-runtime/std",
4547
"wrt-sync/std",
4648
"wrt-error/std",
@@ -77,11 +79,11 @@ iso-25119 = ["wrt-foundation/iso-25119"]
7779

7880
# Layer 4: Safety Integrity Levels (dependent on standard)
7981
# ISO 26262 - Automotive
80-
qm = ["wrt-foundation/qm", "wrt-format/qm", "wrt-host/qm", "wrt-decoder/qm", "wrt-runtime/qm", "wrt-intercept/qm"]
81-
asil-a = ["wrt-foundation/asil-a", "wrt-format/asil-a", "wrt-host/asil-a", "wrt-decoder/asil-a", "wrt-runtime/asil-a", "wrt-intercept/asil-a"]
82-
asil-b = ["wrt-foundation/asil-b", "wrt-format/asil-b", "wrt-host/asil-b", "wrt-decoder/asil-b", "wrt-runtime/asil-b", "wrt-intercept/asil-b"]
83-
asil-c = ["wrt-foundation/asil-c", "wrt-format/asil-c", "wrt-host/asil-c", "wrt-decoder/asil-c", "wrt-runtime/asil-c", "wrt-intercept/asil-c"]
84-
asil-d = ["wrt-foundation/asil-d", "wrt-format/asil-d", "wrt-host/asil-d", "wrt-decoder/asil-d", "wrt-runtime/asil-d", "wrt-intercept/asil-d"]
82+
qm = ["wrt-foundation/qm", "wrt-format/qm", "wrt-host/qm", "wrt-decoder/qm", "wrt-platform/qm", "wrt-runtime/qm", "wrt-intercept/qm"]
83+
asil-a = ["wrt-foundation/asil-a", "wrt-format/asil-a", "wrt-host/asil-a", "wrt-decoder/asil-a", "wrt-platform/asil-a", "wrt-runtime/asil-a", "wrt-intercept/asil-a"]
84+
asil-b = ["wrt-foundation/asil-b", "wrt-format/asil-b", "wrt-host/asil-b", "wrt-decoder/asil-b", "wrt-platform/asil-b", "wrt-runtime/asil-b", "wrt-intercept/asil-b"]
85+
asil-c = ["wrt-foundation/asil-c", "wrt-format/asil-c", "wrt-host/asil-c", "wrt-decoder/asil-c", "wrt-platform/asil-c", "wrt-runtime/asil-c", "wrt-intercept/asil-c"]
86+
asil-d = ["wrt-foundation/asil-d", "wrt-format/asil-d", "wrt-host/asil-d", "wrt-decoder/asil-d", "wrt-platform/asil-d", "wrt-runtime/asil-d", "wrt-intercept/asil-d"]
8587

8688
# DO-178C - Aerospace
8789
dal-e = ["wrt-foundation/dal-e"]

wrt-component/src/async_/async_canonical.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ use wrt_error::{
3535
ErrorCategory,
3636
Result,
3737
};
38+
#[cfg(feature = "std")]
39+
use wrt_foundation::component_value::ComponentValue;
3840
use wrt_foundation::{
3941
bounded::BoundedVec,
4042
prelude::*,
@@ -47,11 +49,6 @@ use wrt_foundation::{
4749
BoundedMap as BTreeMap,
4850
BoundedVec as Vec,
4951
};
50-
#[cfg(feature = "std")]
51-
use wrt_foundation::{
52-
component_value::ComponentValue,
53-
resource::ResourceHandle,
54-
};
5552

5653
use crate::{
5754
async_::async_types::{
@@ -67,6 +64,7 @@ use crate::{
6764
Waitable,
6865
WaitableSet,
6966
},
67+
prelude::ResourceHandle,
7068
types::{
7169
ValType,
7270
Value,

wrt-component/src/async_/async_canonical_abi_support.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ pub type FuelTrackedThreadManager = ();
3636

3737
use crate::{
3838
async_::{
39+
async_types::{
40+
Future,
41+
FutureHandle,
42+
Stream,
43+
StreamHandle,
44+
Waitable,
45+
WaitableSet,
46+
},
3947
fuel_async_executor::AsyncTaskState,
4048
task_manager_async_bridge::{
4149
ComponentAsyncTaskType,
4250
TaskManagerAsyncBridge,
4351
},
4452
},
45-
async_types::{
46-
Future,
47-
FutureHandle,
48-
Stream,
49-
StreamHandle,
50-
Waitable,
51-
WaitableSet,
52-
},
5353
canonical_abi::{
5454
CanonicalOptions,
5555
LiftingContext,
@@ -769,11 +769,9 @@ mod tests {
769769
use crate::threading::thread_spawn_fuel::FuelTrackedThreadManager;
770770

771771
fn create_test_bridge() -> TaskManagerAsyncBridge {
772-
let task_manager =
773-
wrt_foundation::Arc::new(wrt_foundation::sync::Mutex::new(TaskManager::new()));
774-
let thread_manager = wrt_foundation::Arc::new(wrt_foundation::sync::Mutex::new(
775-
FuelTrackedThreadManager::new(),
776-
));
772+
let task_manager = wrt_foundation::Arc::new(wrt_sync::Mutex::new(TaskManager::new()));
773+
let thread_manager =
774+
wrt_foundation::Arc::new(wrt_sync::Mutex::new(FuelTrackedThreadManager::new()));
777775
let config = crate::async_::task_manager_async_bridge::BridgeConfiguration::default();
778776
TaskManagerAsyncBridge::new(task_manager, thread_manager, config).unwrap()
779777
}

wrt-component/src/async_/async_types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use std::{
2222

2323
use wrt_error::Result as WrtResult;
2424
#[cfg(feature = "std")]
25-
use wrt_foundation::component_value::ComponentValue;
26-
#[cfg(feature = "std")]
2725
use wrt_foundation::{
2826
bounded::BoundedVec,
2927
component_value::ComponentValue,

wrt-component/src/async_/component_model_async_ops.rs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ use wrt_foundation::{
1717
bounded::BoundedVec,
1818
bounded_collections::BoundedMap,
1919
safe_managed_alloc,
20-
sync::Mutex,
2120
Arc,
2221
CrateId,
23-
Weak,
2422
};
23+
use wrt_sync::Mutex;
2524

2625
#[cfg(feature = "component-model-threading")]
2726
use crate::threading::task_manager::{
@@ -127,7 +126,7 @@ impl ComponentModelAsyncOps {
127126
pub fn new(
128127
executor: Arc<Mutex<FuelAsyncExecutor>>,
129128
task_manager: Arc<Mutex<TaskManager>>,
130-
) -> Result<Self, Error> {
129+
) -> Result<Self> {
131130
let provider = safe_managed_alloc!(4096, CrateId::Component)?;
132131

133132
Ok(Self {
@@ -145,7 +144,7 @@ impl ComponentModelAsyncOps {
145144
current_task: TaskId,
146145
waitables: WaitableSet,
147146
timeout_ms: Option<u64>,
148-
) -> Result<TaskWaitResult, Error> {
147+
) -> Result<TaskWaitResult> {
149148
self.stats.total_waits.fetch_add(1, Ordering::Relaxed);
150149

151150
// Validate waitables
@@ -191,7 +190,7 @@ impl ComponentModelAsyncOps {
191190
}
192191

193192
/// Implement task.yield - yield execution to other tasks
194-
pub fn task_yield(&mut self, current_task: TaskId) -> Result<(), Error> {
193+
pub fn task_yield(&mut self, current_task: TaskId) -> Result<()> {
195194
self.stats.total_yields.fetch_add(1, Ordering::Relaxed);
196195

197196
// Consume fuel for yielding
@@ -235,7 +234,7 @@ impl ComponentModelAsyncOps {
235234
&mut self,
236235
current_task: TaskId,
237236
waitables: &WaitableSet,
238-
) -> Result<TaskPollResult, Error> {
237+
) -> Result<TaskPollResult> {
239238
self.stats.total_polls.fetch_add(1, Ordering::Relaxed);
240239

241240
// Consume fuel for polling
@@ -250,7 +249,7 @@ impl ComponentModelAsyncOps {
250249
}
251250

252251
/// Process wait operations and wake tasks when waitables are ready
253-
pub fn process_wait_operations(&mut self) -> Result<usize, Error> {
252+
pub fn process_wait_operations(&mut self) -> Result<usize> {
254253
let mut woken_count = 0;
255254
let current_time = self.get_current_time();
256255

@@ -298,28 +297,28 @@ impl ComponentModelAsyncOps {
298297
}
299298

300299
/// Register a future as ready
301-
pub fn mark_future_ready(&mut self, handle: FutureHandle) -> Result<(), Error> {
300+
pub fn mark_future_ready(&mut self, handle: FutureHandle) -> Result<()> {
302301
self.waitable_registry.mark_future_ready(handle)
303302
}
304303

305304
/// Register a stream as having data
306-
pub fn mark_stream_ready(&mut self, handle: StreamHandle) -> Result<(), Error> {
305+
pub fn mark_stream_ready(&mut self, handle: StreamHandle) -> Result<()> {
307306
self.waitable_registry.mark_stream_ready(handle)
308307
}
309308

310309
/// Register a stream as writable
311-
pub fn mark_stream_writable(&mut self, handle: StreamHandle) -> Result<(), Error> {
310+
pub fn mark_stream_writable(&mut self, handle: StreamHandle) -> Result<()> {
312311
self.waitable_registry.mark_stream_writable(handle)
313312
}
314313

315314
/// Register a future as writable
316-
pub fn mark_future_writable(&mut self, handle: FutureHandle) -> Result<(), Error> {
315+
pub fn mark_future_writable(&mut self, handle: FutureHandle) -> Result<()> {
317316
self.waitable_registry.mark_future_writable(handle)
318317
}
319318

320319
// Private helper methods
321320

322-
fn check_waitables_ready(&self, waitables: &WaitableSet) -> Result<Option<u32>, Error> {
321+
fn check_waitables_ready(&self, waitables: &WaitableSet) -> Result<Option<u32>> {
323322
for (index, waitable) in waitables.waitables.iter().enumerate() {
324323
match waitable {
325324
Waitable::FutureReadable(handle) => {
@@ -349,33 +348,33 @@ impl ComponentModelAsyncOps {
349348
Ok(None)
350349
}
351350

352-
fn consume_fuel_for_task(&self, task_id: TaskId, fuel: u64) -> Result<(), Error> {
351+
fn consume_fuel_for_task(&self, task_id: TaskId, fuel: u64) -> Result<()> {
353352
let executor = self.executor.lock()?;
354353
if let Some(task) = executor.tasks.get(&task_id) {
355354
executor.consume_task_fuel(task, fuel)?;
356355
}
357356
Ok(())
358357
}
359358

360-
fn mark_task_waiting(&self, task_id: TaskId) -> Result<(), Error> {
359+
fn mark_task_waiting(&self, task_id: TaskId) -> Result<()> {
361360
let mut executor = self.executor.lock()?;
362361
if let Some(task) = executor.tasks.get_mut(&task_id) {
363362
task.state = AsyncTaskState::Waiting;
364363
}
365364
Ok(())
366365
}
367366

368-
fn wake_task(&self, task_id: TaskId) -> Result<(), Error> {
367+
fn wake_task(&self, task_id: TaskId) -> Result<()> {
369368
let mut executor = self.executor.lock()?;
370369
executor.wake_task(task_id)
371370
}
372371

373-
fn set_task_wait_result(&self, task_id: TaskId, ready_index: u32) -> Result<(), Error> {
372+
fn set_task_wait_result(&self, task_id: TaskId, ready_index: u32) -> Result<()> {
374373
// In real implementation, would store result in task context
375374
Ok(())
376375
}
377376

378-
fn set_task_timeout_result(&self, task_id: TaskId) -> Result<(), Error> {
377+
fn set_task_timeout_result(&self, task_id: TaskId) -> Result<()> {
379378
// In real implementation, would store timeout result in task context
380379
Ok(())
381380
}
@@ -387,7 +386,7 @@ impl ComponentModelAsyncOps {
387386
}
388387

389388
impl WaitableRegistry {
390-
fn new() -> Result<Self, Error> {
389+
fn new() -> Result<Self> {
391390
let provider = safe_managed_alloc!(2048, CrateId::Component)?;
392391
Ok(Self {
393392
futures_readable: BoundedMap::new(provider.clone())?,
@@ -397,50 +396,50 @@ impl WaitableRegistry {
397396
})
398397
}
399398

400-
fn is_future_ready(&self, handle: FutureHandle) -> Result<bool, Error> {
399+
fn is_future_ready(&self, handle: FutureHandle) -> Result<bool> {
401400
Ok(matches!(
402401
self.futures_readable.get(&handle),
403402
Some(WaitableState::Ready)
404403
))
405404
}
406405

407-
fn is_future_writable(&self, handle: FutureHandle) -> Result<bool, Error> {
406+
fn is_future_writable(&self, handle: FutureHandle) -> Result<bool> {
408407
Ok(matches!(
409408
self.futures_writable.get(&handle),
410409
Some(WaitableState::Ready)
411410
))
412411
}
413412

414-
fn is_stream_ready(&self, handle: StreamHandle) -> Result<bool, Error> {
413+
fn is_stream_ready(&self, handle: StreamHandle) -> Result<bool> {
415414
Ok(matches!(
416415
self.streams_readable.get(&handle),
417416
Some(WaitableState::Ready)
418417
))
419418
}
420419

421-
fn is_stream_writable(&self, handle: StreamHandle) -> Result<bool, Error> {
420+
fn is_stream_writable(&self, handle: StreamHandle) -> Result<bool> {
422421
Ok(matches!(
423422
self.streams_writable.get(&handle),
424423
Some(WaitableState::Ready)
425424
))
426425
}
427426

428-
fn mark_future_ready(&mut self, handle: FutureHandle) -> Result<(), Error> {
427+
fn mark_future_ready(&mut self, handle: FutureHandle) -> Result<()> {
429428
self.futures_readable.insert(handle, WaitableState::Ready).ok();
430429
Ok(())
431430
}
432431

433-
fn mark_future_writable(&mut self, handle: FutureHandle) -> Result<(), Error> {
432+
fn mark_future_writable(&mut self, handle: FutureHandle) -> Result<()> {
434433
self.futures_writable.insert(handle, WaitableState::Ready).ok();
435434
Ok(())
436435
}
437436

438-
fn mark_stream_ready(&mut self, handle: StreamHandle) -> Result<(), Error> {
437+
fn mark_stream_ready(&mut self, handle: StreamHandle) -> Result<()> {
439438
self.streams_readable.insert(handle, WaitableState::Ready).ok();
440439
Ok(())
441440
}
442441

443-
fn mark_stream_writable(&mut self, handle: StreamHandle) -> Result<(), Error> {
442+
fn mark_stream_writable(&mut self, handle: StreamHandle) -> Result<()> {
444443
self.streams_writable.insert(handle, WaitableState::Ready).ok();
445444
Ok(())
446445
}

0 commit comments

Comments
 (0)