Skip to content

Commit f89f342

Browse files
CDRussellribafish
andauthored
build(native): make NDK outputs path-stable (#7746)
Task/Issue URL: https://app.asana.com/1/137249556945/task/1213227245294013 ### Description NDK Debug C/C++ builds were producing location-dependent .so files. Absolute source/build paths were embedded in debug metadata and linker-generated GNU build IDs varied by build location, which changed JNI artifacts between equivalent checkouts. Apply target-specific reproducibility flags in both native modules: add -fdebug-prefix-map for CMAKE_SOURCE_DIR/CMAKE_BINARY_DIR and set -Wl,--build-id=none. Updated targets: crash-ndk (anrs-impl) and https-bloom-lib (httpsupgrade-impl). This stabilizes stripped native library bytes across checkout paths and prevents downstream lint/local AAR input drift that triggers cache misses. Thanks for the contribution, @ribafish ! ### Steps to test this PR - QA optional <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Build-system-only changes limited to native CMake flags; main risk is unexpected toolchain/linker incompatibility or debugging metadata differences. > > **Overview** > Ensures Android NDK shared libraries are *path-stable/reproducible* across different checkout locations. > > Updates both native modules (`crash-ndk` and `https-bloom-lib`) to normalize source/build paths embedded in debug metadata via `-fdebug-prefix-map`, and disables linker-generated build IDs with `-Wl,--build-id=none` to prevent location-dependent `.so` byte differences. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 09e85f8. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Gasper Kojek <gkojek@gradle.com>
1 parent cae5f14 commit f89f342

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

anrs/anrs-impl/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ find_library( # Sets the name of the path variable.
2020
# you want CMake to locate.
2121
log)
2222

23+
# Normalize source/build paths in debug metadata so native outputs are reproducible
24+
# across different checkout locations.
25+
target_compile_options(
26+
crash-ndk
27+
PRIVATE
28+
"-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=."
29+
"-fdebug-prefix-map=${CMAKE_BINARY_DIR}=.")
30+
2331
target_link_libraries(
2432
# Specifies the target library.
2533
crash-ndk
@@ -31,5 +39,6 @@ target_link_libraries(
3139
target_link_options(
3240
crash-ndk
3341
PRIVATE
42+
"-Wl,--build-id=none"
3443
"-Wl,-z,common-page-size=16384"
35-
"-Wl,-z,max-page-size=16384")
44+
"-Wl,-z,max-page-size=16384")

httpsupgrade/httpsupgrade-impl/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,17 @@ find_library( # Sets the name of the path variable.
3737
# you want CMake to locate.
3838
log)
3939

40+
# Normalize source/build paths in debug metadata so native outputs are reproducible
41+
# across different checkout locations.
42+
target_compile_options(
43+
https-bloom-lib
44+
PRIVATE
45+
"-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=."
46+
"-fdebug-prefix-map=${CMAKE_BINARY_DIR}=.")
47+
4048
target_link_options(
4149
https-bloom-lib
4250
PRIVATE
51+
"-Wl,--build-id=none"
4352
"-Wl,-z,common-page-size=16384"
44-
"-Wl,-z,max-page-size=16384")
53+
"-Wl,-z,max-page-size=16384")

0 commit comments

Comments
 (0)