This old issue seems to indicate that cfg(crate_type) is desired but not implemented. I don't know whether there's a good workaround, I though about whether you could do it with build.rs to emit a custom cargo:rustc-cfg, but couldn't figure out how you would extract the crate_type from the available environment variables.
according to your link, I think it may not implemented for a reason, maybe because crate-type = ["rlib","cdylib"] is passed together to rustc once, not separately to build two lib one by one, so the checking may apply both for rlib and cdylib...
I'm considering adding a custom feature instead of checking crate-type now...