@@ -239,6 +239,7 @@ pub(crate) struct CanonicalOptions {
239
239
pub ( crate ) post_return : Option < u32 > ,
240
240
pub ( crate ) concurrency : Concurrency ,
241
241
pub ( crate ) core_type : Option < CoreTypeId > ,
242
+ pub ( crate ) gc : bool ,
242
243
}
243
244
244
245
impl CanonicalOptions {
@@ -304,6 +305,13 @@ impl CanonicalOptions {
304
305
) ;
305
306
}
306
307
308
+ if self . gc && self . core_type . is_none ( ) {
309
+ bail ! (
310
+ offset,
311
+ "cannot specify `gc` without also specifying a `core-type` for lowerings"
312
+ )
313
+ }
314
+
307
315
Ok ( self )
308
316
}
309
317
@@ -2334,7 +2342,8 @@ impl ComponentState {
2334
2342
CanonicalOption :: PostReturn ( _) => "post-return" ,
2335
2343
CanonicalOption :: Async => "async" ,
2336
2344
CanonicalOption :: Callback ( _) => "callback" ,
2337
- CanonicalOption :: CoreType ( _) => "core type" ,
2345
+ CanonicalOption :: CoreType ( _) => "core-type" ,
2346
+ CanonicalOption :: Gc => "gc" ,
2338
2347
}
2339
2348
}
2340
2349
@@ -2345,6 +2354,7 @@ impl ComponentState {
2345
2354
let mut is_async = false ;
2346
2355
let mut callback = None ;
2347
2356
let mut core_type = None ;
2357
+ let mut gc = false ;
2348
2358
2349
2359
for option in options {
2350
2360
match option {
@@ -2475,6 +2485,21 @@ impl ComponentState {
2475
2485
}
2476
2486
} ;
2477
2487
}
2488
+ CanonicalOption :: Gc => {
2489
+ if gc {
2490
+ return Err ( BinaryReaderError :: new (
2491
+ "canonical option `gc` is specified more than once" ,
2492
+ offset,
2493
+ ) ) ;
2494
+ }
2495
+ if !self . features . cm_gc ( ) {
2496
+ return Err ( BinaryReaderError :: new (
2497
+ "canonical option `gc` requires the `cm-gc` feature" ,
2498
+ offset,
2499
+ ) ) ;
2500
+ }
2501
+ gc = true ;
2502
+ }
2478
2503
}
2479
2504
}
2480
2505
@@ -2489,12 +2514,17 @@ impl ComponentState {
2489
2514
( true , callback, false ) => Concurrency :: Async { callback } ,
2490
2515
} ;
2491
2516
2517
+ if !gc && core_type. is_some ( ) {
2518
+ bail ! ( offset, "cannot specify `core-type` without `gc`" )
2519
+ }
2520
+
2492
2521
Ok ( CanonicalOptions {
2493
2522
memory,
2494
2523
realloc,
2495
2524
post_return,
2496
2525
concurrency,
2497
2526
core_type,
2527
+ gc,
2498
2528
} )
2499
2529
}
2500
2530
0 commit comments