I want to log information about the compilation settings used for my app. Specifically, I want to determine whether LTO was enabled, whether panic=unwind or panic=abort was used, and possibly other relevant flags. Is there a way to embed this information into the binary?
I'm not sure about the LTO setting, but you can read the environment variable CARGO_CFG_PANIC in a build script, and write it to a generated rust file in OUT_DIR.
Inside the main source files you can use cfg!(panic = "abort"). As for LTO you need to use a build script and check if the CARGO_ENCODED_RUSTFLAGS env var contains -Clto.