Is there a way to tell, at compile-time, if a target supports heap-allocated memory? In general, not testing for a specific allocator.
Conditional compilation options I've considered:
#[cfg(any(target_family = "windows", target_family = "unix"))]- assume that a mainstream OS implies heap allocator.
- Will have false negatives, ex. Cortex-M with no OS but using an allocator.
#[cfg(any(target_env = "gnu", target_env = "msvc", target_env = "musl", target_env = "uclibc"))]- assume userspace standard library support implies heap allocator.
- Same false negative as before.
- Per the docs linked above: "...on many GNU platforms, this value will be empty". So not reliable for this purpose.
There doesn't seem to be a
target_feature for heap allocators? Not sure where to find a comprehensive list of possible values.