From b99b3219ca393771425e7237c15d45de8cdcfcba Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Fri, 1 Nov 2024 15:44:05 -0700 Subject: [PATCH] respect conditional cfg --- src/bindgen/ir/cfg.rs | 10 +-- src/bindgen/ir/enumeration.rs | 10 +-- src/bindgen/ir/function.rs | 4 +- src/bindgen/ir/structure.rs | 8 ++- src/bindgen/ir/typedef.rs | 6 +- src/bindgen/ir/union.rs | 8 ++- src/bindgen/monomorph.rs | 64 +++++++++++++------ tests/expectations/return_value_monomorphs.c | 28 ++++++++ .../return_value_monomorphs.compat.c | 28 ++++++++ .../expectations/return_value_monomorphs.cpp | 38 +++++++++-- .../expectations/return_value_monomorphs.pyx | 23 +++++++ .../return_value_monomorphs_both.c | 28 ++++++++ .../return_value_monomorphs_both.compat.c | 28 ++++++++ .../return_value_monomorphs_tag.c | 28 ++++++++ .../return_value_monomorphs_tag.compat.c | 28 ++++++++ .../return_value_monomorphs_tag.pyx | 23 +++++++ tests/rust/return_value_monomorphs.rs | 30 +++++++-- tests/rust/return_value_monomorphs.toml | 11 ++++ 18 files changed, 356 insertions(+), 47 deletions(-) diff --git a/src/bindgen/ir/cfg.rs b/src/bindgen/ir/cfg.rs index 65de1a2f..83ea284f 100644 --- a/src/bindgen/ir/cfg.rs +++ b/src/bindgen/ir/cfg.rs @@ -42,7 +42,7 @@ impl<'a> DefineKey<'a> { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum Cfg { Boolean(String), Named(String, String), @@ -129,10 +129,10 @@ impl syn::parse::Parse for Cfg { impl Cfg { pub fn join(cfgs: &[Cfg]) -> Option { - if cfgs.is_empty() { - None - } else { - Some(Cfg::All(cfgs.to_owned())) + match cfgs { + [] => None, + [cfg] => Some(cfg.clone()), + _ => Some(Cfg::All(cfgs.to_owned())), } } diff --git a/src/bindgen/ir/enumeration.rs b/src/bindgen/ir/enumeration.rs index 0dba6eae..f7a58ac5 100644 --- a/src/bindgen/ir/enumeration.rs +++ b/src/bindgen/ir/enumeration.rs @@ -318,11 +318,13 @@ impl Enum { } pub fn find_return_value_monomorphs(&self, monomorphs: &mut ReturnValueMonomorphs<'_>) { - for v in &self.variants { - if let VariantBody::Body { ref body, .. } = v.body { - body.find_return_value_monomorphs(monomorphs); + monomorphs.with_active_cfg(self.cfg.clone(), |m| { + for v in &self.variants { + if let VariantBody::Body { ref body, .. } = v.body { + body.find_return_value_monomorphs(m); + } } - } + }); } pub fn add_monomorphs(&self, library: &Library, out: &mut Monomorphs) { diff --git a/src/bindgen/ir/function.rs b/src/bindgen/ir/function.rs index 96cd6d8e..de91f6e2 100644 --- a/src/bindgen/ir/function.rs +++ b/src/bindgen/ir/function.rs @@ -137,7 +137,9 @@ impl Function { } pub fn find_return_value_monomorphs(&self, monomorphs: &mut ReturnValueMonomorphs<'_>) { - monomorphs.handle_function(&self.ret, self.args.iter().map(|arg| &arg.ty)); + monomorphs.with_active_cfg(self.cfg.clone(), |m| { + m.handle_function(&self.ret, self.args.iter().map(|arg| &arg.ty)); + }); } pub fn add_monomorphs(&self, library: &Library, out: &mut Monomorphs) { self.ret.add_monomorphs(library, out); diff --git a/src/bindgen/ir/structure.rs b/src/bindgen/ir/structure.rs index 96b9ed23..d6fa7a68 100644 --- a/src/bindgen/ir/structure.rs +++ b/src/bindgen/ir/structure.rs @@ -174,9 +174,11 @@ impl Struct { } pub fn find_return_value_monomorphs(&self, monomorphs: &mut ReturnValueMonomorphs<'_>) { - for field in &self.fields { - field.ty.find_return_value_monomorphs(monomorphs, false); - } + monomorphs.with_active_cfg(self.cfg.clone(), |m| { + for field in &self.fields { + field.ty.find_return_value_monomorphs(m, false); + } + }); } pub fn add_monomorphs(&self, library: &Library, out: &mut Monomorphs) { diff --git a/src/bindgen/ir/typedef.rs b/src/bindgen/ir/typedef.rs index ce61a8ba..9c030441 100644 --- a/src/bindgen/ir/typedef.rs +++ b/src/bindgen/ir/typedef.rs @@ -107,8 +107,10 @@ impl Typedef { monomorphs: &mut ReturnValueMonomorphs<'_>, is_return_value: bool, ) { - self.aliased - .find_return_value_monomorphs(monomorphs, is_return_value); + monomorphs.with_active_cfg(self.cfg.clone(), |m| { + self.aliased + .find_return_value_monomorphs(m, is_return_value); + }); } pub fn add_monomorphs(&self, library: &Library, out: &mut Monomorphs) { diff --git a/src/bindgen/ir/union.rs b/src/bindgen/ir/union.rs index 9ae8b923..9779afbf 100644 --- a/src/bindgen/ir/union.rs +++ b/src/bindgen/ir/union.rs @@ -101,9 +101,11 @@ impl Union { } pub fn find_return_value_monomorphs(&self, monomorphs: &mut ReturnValueMonomorphs<'_>) { - for field in &self.fields { - field.ty.find_return_value_monomorphs(monomorphs, false); - } + monomorphs.with_active_cfg(self.cfg.clone(), |m| { + for field in &self.fields { + field.ty.find_return_value_monomorphs(m, false); + } + }); } pub fn add_monomorphs(&self, library: &Library, out: &mut Monomorphs) { diff --git a/src/bindgen/monomorph.rs b/src/bindgen/monomorph.rs index a6986512..6c858455 100644 --- a/src/bindgen/monomorph.rs +++ b/src/bindgen/monomorph.rs @@ -7,7 +7,7 @@ use std::iter::FromIterator as _; use std::mem; use crate::bindgen::ir::{ - Documentation, Enum, Field, GenericArgument, GenericPath, Item, ItemContainer, OpaqueItem, + Cfg, Documentation, Enum, Field, GenericArgument, GenericPath, Item, ItemContainer, OpaqueItem, Path, Struct, Type, Typedef, Union, }; use crate::bindgen::library::Library; @@ -152,7 +152,8 @@ impl Monomorphs { /// functions that can lead to compilation warnings/errors if not explicitly instantiated. pub struct ReturnValueMonomorphs<'a> { library: &'a Library, - monomorphs: HashSet, + monomorphs: HashSet<(GenericPath, Option)>, + active_cfgs: Vec, } impl<'a> ReturnValueMonomorphs<'a> { @@ -160,22 +161,44 @@ impl<'a> ReturnValueMonomorphs<'a> { Self { library, monomorphs: HashSet::new(), + active_cfgs: Vec::new(), } } - /// Resolve a typedef that is a function return value, specializing it first if needed. - fn handle_return_value_typedef(&mut self, typedef: Typedef, generic: &GenericPath) { - if typedef.is_generic() { - let args = generic.generics(); - let aliased = &typedef.aliased; - let mappings = typedef.generic_params.call(typedef.path.name(), args); - let aliased = aliased.specialize(&mappings); - aliased.find_return_value_monomorphs(self, true); + fn insert(&mut self, generic: &GenericPath, cfg: Option) { + if !generic.generics().is_empty() { + self.with_active_cfg(cfg, |m| { + let cfg = Cfg::join(&m.active_cfgs); + m.monomorphs.insert((generic.clone(), cfg)); + }); + } + } + + pub fn with_active_cfg(&mut self, cfg: Option, thunk: impl FnOnce(&mut Self)) { + if let Some(cfg) = cfg { + self.active_cfgs.push(cfg); + thunk(self); + self.active_cfgs.pop(); } else { - typedef.find_return_value_monomorphs(self, true); + thunk(self); } } + /// Resolve a typedef that is a function return value, specializing it first if needed. + fn handle_return_value_typedef(&mut self, typedef: Typedef, generic: &GenericPath) { + self.with_active_cfg(typedef.cfg.clone(), |m| { + if typedef.is_generic() { + let args = generic.generics(); + let aliased = &typedef.aliased; + let mappings = typedef.generic_params.call(typedef.path.name(), args); + let aliased = aliased.specialize(&mappings); + aliased.find_return_value_monomorphs(m, true); + } else { + typedef.find_return_value_monomorphs(m, true); + } + }); + } + /// Once we find a function return type, what we do with it depends on the type of item it /// resolves to. Typedefs need to be resolved recursively, while generic structs, unions, and /// enums are captured in the set of return value monomorphs. @@ -191,16 +214,13 @@ impl<'a> ReturnValueMonomorphs<'a> { // Opaque items cannot be instantiated (doomed to compilation failure) ItemContainer::OpaqueItem(_) => {} ItemContainer::Typedef(t) => self.handle_return_value_typedef(t, generic), - ItemContainer::Union(_) | ItemContainer::Enum(_) => { - if !generic.generics().is_empty() { - self.monomorphs.insert(generic.clone()); - } - } + ItemContainer::Union(u) => self.insert(generic, u.cfg), + ItemContainer::Enum(e) => self.insert(generic, e.cfg), ItemContainer::Struct(s) => { if let Some(t) = s.as_typedef() { self.handle_return_value_typedef(t, generic); - } else if !generic.generics().is_empty() { - self.monomorphs.insert(generic.clone()); + } else { + self.insert(generic, s.cfg); } } } @@ -225,11 +245,15 @@ impl<'a> ReturnValueMonomorphs<'a> { // Sort the output so that the struct remains stable across runs (tests want that). let mut monomorphs = Vec::from_iter(self.monomorphs); - monomorphs.sort(); + monomorphs.sort_by(|(k1, _), (k2, _)| k1.cmp(k2)); let fields = monomorphs .into_iter() .enumerate() - .map(|(i, path)| Field::from_name_and_type(format!("field{}", i), Type::Path(path))) + .map(|(i, (path, cfg))| { + let mut f = Field::from_name_and_type(format!("field{}", i), Type::Path(path)); + f.cfg = cfg; + f + }) .collect(); let doc_comment = vec![ " Dummy struct emitted by cbindgen to avoid compiler warnings/errors about", diff --git a/tests/expectations/return_value_monomorphs.c b/tests/expectations/return_value_monomorphs.c index 7a93dd04..e6fe3b9c 100644 --- a/tests/expectations/return_value_monomorphs.c +++ b/tests/expectations/return_value_monomorphs.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +typedef struct { + uint16_t x; +} Foo_u16; + +#if defined(DEFINE_FEATURE_1) +typedef Foo_u16 FooConditional_u16; +#endif + typedef struct { int16_t x; } Foo_i16; @@ -68,6 +82,14 @@ typedef struct { typedef Foo_i64 Transparent; +typedef struct { + uint8_t x; +} Foo_u8; + +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -91,3 +113,9 @@ Foo_bool fnL(void); WrapNonZeroInt fnM(void); Transparent fnN(void); + +#if defined(DEFINE_FEATURE_1) +Foo_u8 fnO(void); +#endif + +Foo_u8 fnP(void); diff --git a/tests/expectations/return_value_monomorphs.compat.c b/tests/expectations/return_value_monomorphs.compat.c index 42ed3728..96687ec8 100644 --- a/tests/expectations/return_value_monomorphs.compat.c +++ b/tests/expectations/return_value_monomorphs.compat.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +typedef struct { + uint16_t x; +} Foo_u16; + +#if defined(DEFINE_FEATURE_1) +typedef Foo_u16 FooConditional_u16; +#endif + typedef struct { int16_t x; } Foo_i16; @@ -68,10 +82,18 @@ typedef struct { typedef Foo_i64 Transparent; +typedef struct { + uint8_t x; +} Foo_u8; + #ifdef __cplusplus extern "C" { #endif // __cplusplus +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -96,6 +118,12 @@ WrapNonZeroInt fnM(void); Transparent fnN(void); +#if defined(DEFINE_FEATURE_1) +Foo_u8 fnO(void); +#endif + +Foo_u8 fnP(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/return_value_monomorphs.cpp b/tests/expectations/return_value_monomorphs.cpp index 04e2b343..0bf7a1aa 100644 --- a/tests/expectations/return_value_monomorphs.cpp +++ b/tests/expectations/return_value_monomorphs.cpp @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include @@ -23,12 +29,26 @@ struct __cbindgen_return_value_monomorphs { Bar field2; Bar field3; Foo field4; - Foo field5; - Foo field6; - Foo field7; - Foo field8; +#if defined(DEFINE_FEATURE_1) + Foo field5 +#endif + ; + Foo field6; +#if (defined(DEFINE_FEATURE_2) && defined(DEFINE_FEATURE_1)) + Foo field7 +#endif + ; + Foo field8; + Foo field9; + Foo field10; + Foo field11; }; +#if defined(DEFINE_FEATURE_1) +template +using FooConditional = Foo; +#endif + template struct NotReturnValue { T x; @@ -57,6 +77,10 @@ using Transparent = Foo; extern "C" { +#if defined(DEFINE_FEATURE_2) +FooConditional double_feature(); +#endif + int32_t fnA(); int16_t fnB(); @@ -81,4 +105,10 @@ WrapNonZeroInt fnM(); Transparent fnN(); +#if defined(DEFINE_FEATURE_1) +Foo fnO(); +#endif + +Foo fnP(); + } // extern "C" diff --git a/tests/expectations/return_value_monomorphs.pyx b/tests/expectations/return_value_monomorphs.pyx index e2923874..09cb8ce9 100644 --- a/tests/expectations/return_value_monomorphs.pyx +++ b/tests/expectations/return_value_monomorphs.pyx @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -6,6 +12,12 @@ cdef extern from *: cdef extern from *: + ctypedef struct Foo_u16: + uint16_t x; + + IF DEFINE_FEATURE_1: + ctypedef Foo_u16 FooConditional_u16; + ctypedef struct Foo_i16: int16_t x; @@ -60,6 +72,12 @@ cdef extern from *: ctypedef Foo_i64 Transparent; + ctypedef struct Foo_u8: + uint8_t x; + + IF DEFINE_FEATURE_2: + FooConditional_u16 double_feature(); + int32_t fnA(); int16_t fnB(); @@ -83,3 +101,8 @@ cdef extern from *: WrapNonZeroInt fnM(); Transparent fnN(); + + IF DEFINE_FEATURE_1: + Foo_u8 fnO(); + + Foo_u8 fnP(); diff --git a/tests/expectations/return_value_monomorphs_both.c b/tests/expectations/return_value_monomorphs_both.c index 3356df7d..629f71f2 100644 --- a/tests/expectations/return_value_monomorphs_both.c +++ b/tests/expectations/return_value_monomorphs_both.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +typedef struct Foo_u16 { + uint16_t x; +} Foo_u16; + +#if defined(DEFINE_FEATURE_1) +typedef struct Foo_u16 FooConditional_u16; +#endif + typedef struct Foo_i16 { int16_t x; } Foo_i16; @@ -68,6 +82,14 @@ typedef struct Foo_i64 { typedef struct Foo_i64 Transparent; +typedef struct Foo_u8 { + uint8_t x; +} Foo_u8; + +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -91,3 +113,9 @@ struct Foo_bool fnL(void); WrapNonZeroInt fnM(void); Transparent fnN(void); + +#if defined(DEFINE_FEATURE_1) +struct Foo_u8 fnO(void); +#endif + +struct Foo_u8 fnP(void); diff --git a/tests/expectations/return_value_monomorphs_both.compat.c b/tests/expectations/return_value_monomorphs_both.compat.c index d8a52b97..8ef152d5 100644 --- a/tests/expectations/return_value_monomorphs_both.compat.c +++ b/tests/expectations/return_value_monomorphs_both.compat.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +typedef struct Foo_u16 { + uint16_t x; +} Foo_u16; + +#if defined(DEFINE_FEATURE_1) +typedef struct Foo_u16 FooConditional_u16; +#endif + typedef struct Foo_i16 { int16_t x; } Foo_i16; @@ -68,10 +82,18 @@ typedef struct Foo_i64 { typedef struct Foo_i64 Transparent; +typedef struct Foo_u8 { + uint8_t x; +} Foo_u8; + #ifdef __cplusplus extern "C" { #endif // __cplusplus +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -96,6 +118,12 @@ WrapNonZeroInt fnM(void); Transparent fnN(void); +#if defined(DEFINE_FEATURE_1) +struct Foo_u8 fnO(void); +#endif + +struct Foo_u8 fnP(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/return_value_monomorphs_tag.c b/tests/expectations/return_value_monomorphs_tag.c index 539f5732..2bdaf00a 100644 --- a/tests/expectations/return_value_monomorphs_tag.c +++ b/tests/expectations/return_value_monomorphs_tag.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +struct Foo_u16 { + uint16_t x; +}; + +#if defined(DEFINE_FEATURE_1) +typedef struct Foo_u16 FooConditional_u16; +#endif + struct Foo_i16 { int16_t x; }; @@ -68,6 +82,14 @@ struct Foo_i64 { typedef struct Foo_i64 Transparent; +struct Foo_u8 { + uint8_t x; +}; + +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -91,3 +113,9 @@ struct Foo_bool fnL(void); WrapNonZeroInt fnM(void); Transparent fnN(void); + +#if defined(DEFINE_FEATURE_1) +struct Foo_u8 fnO(void); +#endif + +struct Foo_u8 fnP(void); diff --git a/tests/expectations/return_value_monomorphs_tag.compat.c b/tests/expectations/return_value_monomorphs_tag.compat.c index d1656750..54ff29b2 100644 --- a/tests/expectations/return_value_monomorphs_tag.compat.c +++ b/tests/expectations/return_value_monomorphs_tag.compat.c @@ -1,8 +1,22 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + #include #include #include #include +struct Foo_u16 { + uint16_t x; +}; + +#if defined(DEFINE_FEATURE_1) +typedef struct Foo_u16 FooConditional_u16; +#endif + struct Foo_i16 { int16_t x; }; @@ -68,10 +82,18 @@ struct Foo_i64 { typedef struct Foo_i64 Transparent; +struct Foo_u8 { + uint8_t x; +}; + #ifdef __cplusplus extern "C" { #endif // __cplusplus +#if defined(DEFINE_FEATURE_2) +FooConditional_u16 double_feature(void); +#endif + int32_t fnA(void); int16_t fnB(void); @@ -96,6 +118,12 @@ WrapNonZeroInt fnM(void); Transparent fnN(void); +#if defined(DEFINE_FEATURE_1) +struct Foo_u8 fnO(void); +#endif + +struct Foo_u8 fnP(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/return_value_monomorphs_tag.pyx b/tests/expectations/return_value_monomorphs_tag.pyx index e2147e6e..66509a46 100644 --- a/tests/expectations/return_value_monomorphs_tag.pyx +++ b/tests/expectations/return_value_monomorphs_tag.pyx @@ -1,3 +1,9 @@ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif + + from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t cdef extern from *: @@ -6,6 +12,12 @@ cdef extern from *: cdef extern from *: + cdef struct Foo_u16: + uint16_t x; + + IF DEFINE_FEATURE_1: + ctypedef Foo_u16 FooConditional_u16; + cdef struct Foo_i16: int16_t x; @@ -60,6 +72,12 @@ cdef extern from *: ctypedef Foo_i64 Transparent; + cdef struct Foo_u8: + uint8_t x; + + IF DEFINE_FEATURE_2: + FooConditional_u16 double_feature(); + int32_t fnA(); int16_t fnB(); @@ -83,3 +101,8 @@ cdef extern from *: WrapNonZeroInt fnM(); Transparent fnN(); + + IF DEFINE_FEATURE_1: + Foo_u8 fnO(); + + Foo_u8 fnP(); diff --git a/tests/rust/return_value_monomorphs.rs b/tests/rust/return_value_monomorphs.rs index 44ae0cf9..1e800b63 100644 --- a/tests/rust/return_value_monomorphs.rs +++ b/tests/rust/return_value_monomorphs.rs @@ -1,30 +1,42 @@ #[repr(C)] -struct Foo { +pub struct Foo { x: T, } #[repr(C)] -struct NotReturnValue { +pub struct NotReturnValue { x: T, } #[repr(C)] -struct FooField { +pub struct FooField { f: extern "C" fn() -> Foo, g: extern "C" fn(NotReturnValue), } #[repr(C)] -struct Bar { +pub struct Bar { p: P, q: Q, } #[repr(transparent)] -struct Transparent { +pub struct Transparent { x: Foo, } +#[cfg(feature = "feature1")] +pub type FooConditional = Foo; + +pub struct Conditional; + +#[cfg(feature = "feature1")] +impl Conditional { + #[no_mangle] + #[cfg(feature = "feature2")] + pub extern "C" fn double_feature() -> FooConditional { todo!() } +} + pub type IntBar = Bar; pub type IntBoolBar = IntBar; @@ -84,3 +96,11 @@ pub extern "C" fn fnM() -> WrapNonZeroInt { todo!() } #[no_mangle] pub extern "C" fn fnN() -> Transparent { todo!() } + +#[no_mangle] +#[cfg(feature = "feature1")] +pub extern "C" fn fnO() -> Foo { todo!() } + +// This one should cause Foo to appear a second time, because the cfg differs +#[no_mangle] +pub extern "C" fn fnP() -> Foo { todo!() } diff --git a/tests/rust/return_value_monomorphs.toml b/tests/rust/return_value_monomorphs.toml index 135e56c3..282d4cfe 100644 --- a/tests/rust/return_value_monomorphs.toml +++ b/tests/rust/return_value_monomorphs.toml @@ -1,2 +1,13 @@ +header = """ +#if 0 +DEF DEFINE_FEATURE_1 = 0 +DEF DEFINE_FEATURE_2 = 0 +#endif +""" + [export] instantiate_return_value_monomorphs = true + +[defines] +"feature = feature1" = "DEFINE_FEATURE_1" +"feature = feature2" = "DEFINE_FEATURE_2"