cmake-rs tries to translate cargo settings to cmake settings, but there are two cases where the debuginfio settings are ignored. The first is opt-level=0 + debug=false. This picks the CMake Debug profile, which always has debuginfo on.
The second is opt-level=s + debug=true. This picks MinSizeRel, which always has debuginfo off.
Solving this in the general case looks hard. I have begun trying to do it by running the cmake configure step once with the -LA flags, to list the configured values of CMAKE_C_FLAGS_DEBUG (etc); modify those flags, then run the actual configuration.
I think it's a viable solution, but I haven't quite gotten there: https://github.com/brson/cmake-rs/tree/dev-nodebug
This is a problem in TiKV where we are turning off debuginfo to improve compile times, but RocksDB makes up a huge chunk of that debuginfo. cc tikv/tikv#4711
We could probably solve this one-off in librocksdb_sys, but it would seem better to solve it for everybody.