rust-lang / backtrace-rs

Backtraces in Rust
https://docs.rs/backtrace
Other
524 stars 240 forks source link

Allow the library consumer to specify the Android API level #570

Open danakj opened 10 months ago

danakj commented 10 months ago

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.

github-actions[bot] commented 5 months ago

Code size changes for a hello-world Rust program linked with libstd with backtrace:

On platform windows-latest:

workingjubilee commented 5 months ago

@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 commented 5 months ago

@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.

workingjubilee commented 5 months ago

@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.

danakj commented 5 months ago

Oh excellent. Thanks!

danakj commented 3 weeks ago

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.)

workingjubilee commented 3 weeks ago

yeah I am surprised it took this long lmao.