backtrace-rs icon indicating copy to clipboard operation
backtrace-rs copied to clipboard

Allow the library consumer to specify the Android API level

Open danakj opened this issue 2 years ago • 8 comments

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.

danakj avatar Oct 13 '23 20:10 danakj

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

github-actions[bot] avatar Mar 08 '24 18:03 github-actions[bot]

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

workingjubilee avatar Mar 08 '24 18:03 workingjubilee

@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 avatar Mar 11 '24 18:03 danakj

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

workingjubilee avatar Mar 12 '24 19:03 workingjubilee

Oh excellent. Thanks!

danakj avatar Mar 12 '24 23:03 danakj

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

danakj avatar Jul 26 '24 19:07 danakj

yeah I am surprised it took this long lmao.

workingjubilee avatar Jul 27 '24 03:07 workingjubilee