backtrace-rs
backtrace-rs copied to clipboard
Allow the library consumer to specify the Android API level
The build.rs script will use the C preprocessor to pull the API level out of C headers by default. But for build systems that wish to control each build step, and rely on remote compilation, this presents problems.
If --cfg=no_cc is specified, the the C compiler will not be used. Instead the __ANDROID_API__ environment variable
is used to specify the API level.
Code size changes for a hello-world Rust program linked with libstd with backtrace:
On platform windows-latest:
- Original binary size: 140,800 B
- Updated binary size: 138,752 B
- Difference: -2,048 B (-1.45%)
@danakj Sorry for not getting around to this for a bit. I'm feeling a bit thick and now rust-lang/rust is using cc-rs 1.0.90, so where are we in wanting this?
@danakj Sorry for not getting around to this for a bit. I'm feeling a bit thick and now rust-lang/rust is using cc-rs 1.0.90, so where are we in wanting this?
No problem. In https://github.com/rust-lang/rust/pull/116318#issuecomment-1762186566 you noted that the NDK R26 supports API L21 as its minimum, at which point the build-time check here can go away entirely, and we just always do the dl_iterate_phdr thing.
We saw that Rust was still on NDK R25, and it looks to still be.
So if we want to leave Rust on R25 but use the backtrace-rs build script in std, then we would still want to put cc behind a no_cc cfg flag. I can update this PR as it has merge conflicts if you think that's the right direction to go still.
@danakj It looks like https://github.com/rust-lang/rust/pull/120593 will advance, and when that does, you can simply make this the PR that removes the build check.
Oh excellent. Thanks!
Wow it finally merged! I am about to go on vacation though, unlucky. If there's no rush I will address this after I am back. (Feel free to steal the work if someone would like to.)
yeah I am surprised it took this long lmao.