summaryrefslogtreecommitdiff
path: root/rust/coverage.go
AgeCommit message (Collapse)Author
2025-02-06rust: Use libprofile-clang-extras_ndk for SDK cov Ivan Lozano
Bug: 203478530 Test: m & m rust Change-Id: I902cfb761794debf52e6443c44c409593c389292
2025-01-23Convert rust to use ModuleProxy. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I2eb0134bb727f5875d579dae1fff5b70658bd2bb
2024-09-14Enable Rust host coverage. Yifeng Zeng
Bug: 297082598 Bug: 330591720 Test: atest logger_host_unit_tests --experimental-coverage Change-Id: Iec6db35b88e2812d3af69863e74b0acf138b04df
2024-07-17Convert rust_libraries and rust_stdlinkage mutators to TransitionMutators Colin Cross
Replace rust.LibraryMutator and rust.LibstdMutator with TransitionMutators. Bug: 319288033 Flag: EXEMPT refactor Test: all soong tests pass Test: no change to build.ninja Change-Id: Ia24a582119d39889279d7b93bac9259685153619
2024-05-16rust: made-to-order rust staticlibs Ivan Lozano
Whenever any two Rust static libraries are included as static libraries anywhere in a CC dependency tree, we sometimes get duplicate symbol errors. To avoid this, we no longer directly link multiple rust static libs to CC modules. Instead, we build rust_ffi_rlib modules and produce the actual static library that gets linked against the CC module based on that CC module's full list of Rust rlib dependencies. This introduces a new static_rlibs property for cc modules to define the rust_ffi_rlib dependencies, which are then used to generate the module above. This CL is intended to deprecate rust_ffi_static. It leaves rust_ffi_static and rust_ffi static variants in place until the remaining rust_ffi_static declarations and uses can be removed. In the meantime, rust_ffi_static produces rust_ffi_rlib variants as well to make the transition easier. Bug: 254469782 Test: m # with no changes Test: m libapexsupport # with static_rlibs Test: m libunwindstack # with static_rlibs Test: m netsimd # with static_rlibs, no duplicate symbols Test: m blueprint_tests # New Soong tests Change-Id: I47e27ac967ef0cad46d398ebf59d8275929ae28a
2024-04-18Only link the profile extras lib for device variant for rust. Yu Liu
Bug: 297082598 Test: CI Change-Id: Id66ce88d8c8a757c53ecb7ba0d101511d81eb911
2023-10-02Revert "Split Rust crate builds into compile and link phases." Colin Cross
This reverts commit e7c71c344d462cac998b37d551bd78baa892082d. The intermediates created by the separated rust compile steps are very large, on the order of 60GB. This is more than CI can support for now, revert the split into compile and link phases. This comes at the expense of incremental build time, especially when modifying C/C++ sources that are dependencies of rust modules. Bug: 293349612 Test: builds Change-Id: I81169e7d0727330c8de5e7688dcdc87fe7b8d3b5
2023-09-22Revert "support sandboxed rust rules" Wen-yi Chu
Revert submission 2629131-sandbox-rust-inputs Reason for revert: Fail on android build. Reverted changes: /q/submissionid:2629131-sandbox-rust-inputs Change-Id: Ifd9aa46e80a12d8f4ffa0a2daa74b96727cbb7e6
2023-09-15support sandboxed rust rules Sam Delmerico
This commit adds support for compiling rust rules inside the sbox sandbox. To compile a rust module with sandboxing enabled, the entry point to the crate must be specified via the `crate_root` property, and all input sources and compile-time data must be specified via the `srcs` and `compile_data` properties. Bug: 286077158 Change-Id: I8c9dc5cf7578037a583b4be2e2f73cf20ffd4408
2023-04-12Split Rust crate builds into compile and link phases. Peter Collingbourne
Teach rustc to generate object files instead of a linked executable for binary and shared library crates. This lets us skip the lengthy Rust compilation phase when only the C++ dependencies of these crates have changed. This works using a Python script that replaces the linker invoked by rustc and converts the linker command line into a rspfile that can be used during the link phase. The script makes certain assumptions about how rustc invokes the linker, but since we control the version of Rust we use, we can update the script if those assumptions ever break. I've asked the Rust developers about adding an official way to do this so hopefully we won't need to rely on this hack in the future. The rustc rule for Kythe has been altered to pass linker=true, somewhat consistent with the main rustc rule, which now doesn't invoke the actual linker either. `m xref_rust` still succeeds, but hopefully we can find someone who knows more about the rest of the Kythe pipeline who can let us know whether it should still work. Otherwise, let's use this CL as an opportunity to find out whether the rest of the pipeline is happy with linker=true, since otherwise we will find it hard to maintain the Kythe rule in the future. Change-Id: Ifb9c8689c1bd78c0afcf6fdfd111140d20377536
2023-02-14rust: Fix coverage in no-std crates Ivan Lozano
Coverage builds for no_std crates currently fail because profiler_builtins are part of libstd and therefore do not get included. When calculating the dependencies for coverage enabled targets, check if the stdlib is being included, and if it is not then pull the profiler_builtins sysroot. Bug: 249551848 Test: CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS='*' make libtinyvec_nostd.rlib-std Change-Id: I73f89bddcb2d4d9c704cb3962ee39b73888c7f3f
2022-06-07[rust/coverage] Use new flag for coverage instrumentation Pirama Arumuga Nainar
> warning: `-Z instrument-coverage` is deprecated; use `-C instrument-coverage` Test: above warning is absent when running: $ m CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS=* rust Change-Id: I8687c04534db3c8a67f209b93ed13d54c2f86dc8
2022-03-04Memory mapped coverage (take 2) Pirama Arumuga Nainar
Add a build variable, CLANG_COVERAGE_CONTINUOUS_MODE, instead of selecting based on paths. Test: CLANG_COVERAGE_CONTINUOUS_MODE=true m and verify continuous mode works Change-Id: I731172fc1f00e1cabff8efcf8b99f9a48210b446
2022-01-26[rust/coverage] Remove obsolete WAR to pass -z,start-stop-gc Pirama Arumuga Nainar
Bug: http://b/199203503 Rust's llvm-project source now includes https://reviews.llvm.org/D97448 and we no longer need this workaround. Test: m unicode-xid_test_src_lib and verify __llvm_prf_data section is present. Change-Id: I0387bd3af8bfc765f3aba3b309bfbc7ef49d565d
2022-01-18Revert memory mapped coverage Pirama Arumuga Nainar
Bug: http://b/194128476 Bug: http://b/210012154 Reverts: e6840726bd255f141ae3dba614c9286528d71281 "[coverage] Override -Wframe-larger-than" 71d697c5cbaa6ad0b2d92ab70f3dd5b91d039582 "Enable memory-mapped coverage instrumentation" Coverage metrics dropped for ~10 of the 40 modules. There are also regressions in mainline when running tests on older platform builds. Test: presubmit Change-Id: I4a2b005d3b54764b762b5422e03b7a9ec8727227
2021-12-13Enable memory-mapped coverage instrumentation Pirama Arumuga Nainar
Bug: http://b/194128476 Bug: http://b/210012154 - pass -runtime-counter-relocation flag, which is needed to enable memory-mapped coverage on Linux/Android. - Include '%c' specifier in -fprofile-instr-generate compiler flag to default to memory-mapped coverage. - Disable continuous coverage if instrumentation is on for bionic/libc (http://b/210012154). Test: Run few coverage tests on Forrest. Change-Id: Ie3a912f66470fcd3ffc2ffd73371a4e1d2b15df3
2021-09-10[rust/coverage] Pass -z,nostart-stop-gc to the linker Pirama Arumuga Nainar
Bug: http://b/199203503 Upstream LLVM change 6d2d3bd0a6 made -z,start-stop-gc the default. It drops metadata sections like __llvm_prf_data unless they are marked SHF_GNU_RETAIN. https://reviews.llvm.org/D97448 marks generated sections, including __llvm_prf_data as SHF_GNU_RETAIN. However this change is not in the Rust toolchain. Since we link Rust libs with new lld, we should use nostart-stop-gc until the Rust toolchain updates past D97448. Test: m unicode-xid_device_test_src_lib and verify that they have the __llvm_prf_data section. Change-Id: I55eb3622dae9bd789fbacfe708600316102c365f
2021-08-04[rust] [coverage] Don't pass -C link-dead-code Pirama Arumuga Nainar
Bug: http://b/186873963 Per jgalenson@, this was added for GCOV and is not needed for clang coverage. Test: http://go/abtd/run/L71000000950546158 Change-Id: I352669687cbe764d938acb94d9d4fe0c24a31a56
2021-01-15Migrate Rust to LLVM coverage. Joel Galenson
Bug: 177675913 Test: Manually compile, run, and see output with llvm-cov. Change-Id: I66729cff87a848782e9fa1b95cbbc06318c5761a
2020-08-25Migrate away from removed option Joel Galenson
Upstream removed the -Z no-landing-pads option in https://github.com/rust-lang/rust/pull/70175, which we picked up in our latest toolchain update. Fixes: 166317885 Test: Build and TreeHugger Change-Id: I51c0ef671bf6a334b2b7223da42cab547e4407d3
2020-06-24Remove moduleContextImpl struct ThiƩbaud Weksteen
The moduleContextImpl structure contains duplicate information on the contexts. BaseModuleContext, ModuleContext and DepsContext can already surface which Module is being processed via Module(). Because most of the Rust-specific methods on the *Context structures simply forward to the Module methods, expose a RustModule() method. Test: cd external/rust/crates; mma Change-Id: Ifee90825d54081fc5e9a8df0b7c4580412e9158c
2020-06-22Make native_coverage clause work with ClangCoverage Colin Cross
Make uses NATIVE_COVERAGE to enable gcov coverage and CLANG_COVERAGE to enable clang coverage. NATIVE_COVERAGE is translated to the Soong Native_coverage product variable which triggers the native_coverage clause in Android.bp files. The clause also needs to be triggered for CLANG_COVERAGE. Rename the existing Native_coverage product variable to GcovCoverage, and regenerate Native_coverage when either GcovCoverage or ClangCoverage are set. Also remove NativeLineCoverage, it wasn't doing anything differently than Native_coverage. Bug: 159059537 Test: m checkbuild Change-Id: I215124a9b35a2ad50ad562079d392e3d33da11f4
2020-05-05Add gcov coverage support to Rust modules. Ivan Lozano
This adds gcov coverage support for Rust device library and binary modules (including test modules). Support is provided to pass Rust static library gcno files to CC modules and visa versa. Additional changes: * Begin mutator added for Rust modules. * SuffixInList added to android package. * CoverageEnabled added to Coverage interface. * CoverageFiles added to LinkableLibrary interface. * Fix in coverage mutator for non-CC modules which marked the wrong variant as the coverage variant. * Added coverage libraries to the cc.GatherRequiredDepsForTest. Bug: 146448203 Test: NATIVE_COVERAGE=true COVERAGE_PATHS='*' m -j <rust_module> Change-Id: If20728bdde42a1dd544a35a40f0d981b80a5835f