summaryrefslogtreecommitdiff
path: root/rust/compiler.go
AgeCommit message (Collapse)Author
2024-10-07Make rust rustlibs property configurable Jihoon Kang
Test: CI Bug: 371871285 Change-Id: I203355d51b9f26edf296f36d1c86b5d2c0277c47
2024-10-03Make the rust features property configurable Jihoon Kang
Test: m nothing --no-skip-soong-tests Bug: 364533958 Change-Id: I2aa5b7e1cf5e8c94448e4562e8b9aebe6edacfe5
2024-05-22Convert some properties to Configurable properties Cole Faust
Focusing on the properties needed to remove soong config modules from packages/modules/Virtualization. - prebuilt_etc's src and srcs - filegroup's srcs and exclude_srcs - rust's cfgs Bug: 342006386 Test: m nothing --no-skip-soong-tests Change-Id: I6971da744a17955f98104948e6f9614776955782
2024-05-17rust: Add an option to disable LTO for Rust Ivan Lozano
This adds an option to disable LTO when building a Rust module. This is mostly intended to speedu p local prototyping, and LTO should not normally be disabled for production builds. Bug: 339628497 Test: m blueprint_tests && m rust Change-Id: I21d5d4513a259a56f101ce8906e2bef7404e4efb
2024-05-16rust: refactored transformSrctoCrate Ivan Lozano
Refactor transformSrctoCrate and the functions it calls to not rely on rust.ModuleContext, preparing it to be callable from soong-cc context to build a Rust staticlib. This also refactors out common default flags used when building libraries, again to prepare for building a Rust staticlib from a soong-cc context. Bug: 254469782 Test: m blueprint_tests && m Change-Id: I678f6fee989c61bb15c340b9887e4d1934991907
2024-03-19Add `aliases` property for renaming Rust dependencies. Andrew Walbran
This is equivalent to specifying a dependency name different to the package name in cargo, which some external crates do. Bug: 308790322 Test: Built libgrpcio with aliases for protobuf Change-Id: I2801222051fdd962460cc7f4900cec357f63b974
2024-01-09Split usage of UseVndk Kiyoung Kim
UseVndk is a function to check if the module can use VNDK libraries, but this function was also used to check if the module is installed in the treblelized partition (vendor or product). As of VNDK deprecation, UseVndk funtion will return false even when the module is installed in vendor / product partition, so we need a separated function to check this. This change introduces a new function 'InVendorOrProduct' which replaces UseVndk based on its usage. Bug: 316829758 Test: m nothing --no-skip-soong-tests passed Change-Id: Ic61fcd16c4554c355f6005894a4519b044b27fe5
2023-11-30Move test data installation to Soong Colin Cross
To generate module-info.json in Soong for b/309006256 Soong needs to know the test data paths. Moving test data installation into Soong will also help later for test suite packaging. Add ModuleContext.InstallTestData that installs the files listed in a []DataPath alongside the test. The files will also be passed to Make to allow it to continue packaging them into the test suites for now. Update the module types that are producing LOCAL_TEST_DATA entries in their Android.mk files to go through InstallTestData instead. Bug: 311428265 Test: atest --host toybox-gtests --test-timeout=120000 Change-Id: Ia8b964f86e584ea464667fd86a48d754d118bead
2023-11-22Merge changes I0caddbf6,Iee20b060,I6c92580b,I45028945,Ia7dd5220, ... into main Matthew Maurer
* changes: rust: Resolve crate roots outside rust-project rust: Cache crateRootPath to avoid ctx rust: internalize srcPathFromModuleSrcs rust: move crateRootPath to compiler rust: Privatize Cargo* methods on compiler rust: Move compiler interface to compiler.go
2023-11-22rust: Resolve crate roots outside rust-project Matthew Maurer
Previously, we manually re-computed crate roots inside project_json for rendering rust-project.json. In addition to added complexity, this meant that generated sources and glob sources would not render correctly - it would select e.g. `src/**.rs` or `:foo` as a crate root. Use a centralized computation of crate roots instead. Bug: 309943184 Test: SOONG_GEN_RUST_PROJECT=1 m nothing, compare rust-project.json Change-Id: I0caddbf600d025a0041f45e69812cdd6f1761234
2023-11-22rust: Cache crateRootPath to avoid ctx Matthew Maurer
This makes it possible to call crateRootPath in situations where a ModuleContext is unavailable. Test: m nothing Bug: 309943184 Change-Id: Iee20b0606954a18ca516cdac40917d0016f94a05
2023-11-22rust: internalize srcPathFromModuleSrcs Matthew Maurer
This was frequently misused (for example, in the prebuilts module, it was used as a complex "assert(len(srcs))==1"), and can be superceded by getCrateRoot anywhere it was used. It's now only called from compiler.go, and can drop the second return parameter, as it was only actually used by the prebuilt assert misuse. Bug: 309943184 Test: m nothing Change-Id: I6c92580bc8f0ecb7586c544056b5409e6dd280e7
2023-11-20rust: move crateRootPath to compiler Matthew Maurer
Test: m nothing Bug: 309943184 Change-Id: I45028945357c394301d93ca7995a4f9adf281931
2023-11-20rust: Privatize Cargo* methods on compiler Matthew Maurer
These methods aren't used outside, and probably shouldn't be. Bug: 309943184 Test: m nothing Change-Id: Ia7dd5220ccd10c0136aa16f5e21149eaf7a03ea1
2023-11-20rust: Move compiler interface to compiler.go Matthew Maurer
Refactor cleanup Bug: 309943184 Test: m nothing Change-Id: I7dcb0af64a4db71fdc46c0876b22e5015c02438e
2023-11-14rust: Allow no_stdlibs per-target variants. Ivan Lozano
stdlibs can be set per-target, it makes to sense to allow no_stdlibs to be set per-target as well. Bug: 310924208 Test: Android.bp with per-target no_stdlibs builds. Change-Id: I1c3a458a849367d2c363bd5f65af77b8cce8c0e0
2023-10-04Export rust flags to bazel Vinh Tran
Bug: 290790800 Test: Inspect out/soong/soong_inspection folder after running `m bp2build` Change-Id: Iffc43a540f67e5f07d109a0a87f3248fae035267
2023-10-03Don't pass -lrt or -lgcc_s to darwin rust compiles Colin Cross
Fix mac builds by removing the -lrt and -lgcc_s flags from darwin rust compiles. Bug: 293349612 Test: builds Change-Id: I99a9fea963761730efc4d3236135ee6d83dbca57
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-25Revert^4 "add crate_root property to rust modules" Sam Delmerico
9c64274b275a00d7753bbe1a15945652521b2044 Change-Id: I1c4dad76842cebf18cd82e04e435910f09038d07
2023-09-22Revert^3 "add crate_root property to rust modules" Wen-yi Chu
60375c4adf0753d0e2519ebf1b908d424dd2d466 Change-Id: I356e936139592893a47d4c6b9e747f24470b11f9
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-09-15Revert^2 "add crate_root property to rust modules" Sam Delmerico
5162ff14fc91db500e008a18840c3dfd4edc695a Change-Id: I9a76df938639676ee4aa7bdd2b2902e0e6df08d5
2023-09-08Revert "add crate_root property to rust modules" Sam Delmerico
Revert submission 2605644-rulebuilder-ninja-vars Reason for revert: b/299568218 Reverted changes: /q/submissionid:2605644-rulebuilder-ninja-vars Change-Id: I17645fcff117909c09a016157235805f0974340b
2023-08-31add crate_root property to rust modules Sam Delmerico
The crate_root property will be used to specify the entry point for a rustc compilation. This will allow the srcs property to be used to collect all src inputs to rustc rather than just the entry point. Bug: 286077158 Test: m libnum_traits Change-Id: I1a167182305dcc11cc927d562ceed622153111d3
2023-08-16Merge "rust: Add support for host fuzzers." into main Ivan Lozano
2023-08-14Remove dylibs prop from rust module types Vinh Tran
For device build, rust defaults to dylib linkage for rustlibs deps. `dylibs` prop was provided for flexibility. By removing it, we're enforcing users to either use the default linkage (dylibs for device and rlibs for host) or rlibs prop explicitly. This means no dylibs for host modules. This makes sense because host modules always uses rlib linkage against libstd. The flexibility with dylibs prop opened room for linkage collisions because the dependencies don't link against libstd the same way. Test: go test Change-Id: I2fc221daa8a9bb42bdcf6d9823c723a4ddabe7b5
2023-08-10rust: Add support for host fuzzers. Ivan Lozano
Adds support for host-based Rust fuzzers. Bug: 282897366 Test: SANITZE_HOST="address" m <host_fuzzer> Test: run fuzzer Change-Id: Ibb951f651ef12e763778ebbf12e66769a7113920
2023-02-24rust: Set android_vendor and android_product cfg Matthew Maurer
Add `android_vendor` and `android_product` cfgs, similar to __ANDROID_VENDOR__ and __ANDROID_PRODUCT__ defines for C++ Bug: 270718001 Test: m nothing with added test Change-Id: Ibeabe2983d1454e5a2ec0bb2f43e793b8f32a5c2
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
2023-01-11Use the same rpaths for tests and binaries and cc and rust Colin Cross
Rust and cc binaries currently use $ORIGIN/lib64:$ORIGIN/../lib64 as the rpath, and cc tests add $ORIGIN/../../lib64:$ORIGIN/../../../$ORIGIN:$ORIGIN. This causes problems when a binary is included as test data in out/host/linux-x86/testcases/<test dir>/<CPU>/<test>, as the binaries can't find the libraries in out/host/linux-x86/lib64. Use the same rpath for test and binaries, and for cc and rust. Bug: 264604160 Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib && out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/gen_sdk_test/x86_64/gen_sdk_test && out/host/linux-x86/testcases/gen_sdk_test/x86_64/toybox Change-Id: I10fe5dc0de01d1f3c6aea8dbabbf60edab5989c3
2022-09-29Remove spurious trailing backslash in prefer_rlib docstring Martin Geisler
Change-Id: I851306c73cb86df4bc4c82c3471ce3b6eaad9ded
2022-07-01Don't use prebuilt rust stdlibs for linux bionic Colin Cross
Linux bionic doesn't have rust stdlib prebuilts, don't use the prebuilts when it is configured as the host os. Bug: 216192129 Test: builds Change-Id: I03425dee4b2e3659bf90c0a0c808cc286daa4b7f
2022-07-01Use musl rust prebuilts for USE_HOST_MUSL=true Colin Cross
Building rust code with musl enabled can load proc macro crates built against musl into rustc, so we have to use a version of rustc also built against musl. Bug: 216192129 Test: m USE_HOST_MUSL=true host-native Change-Id: Icd23b542a4b64a975850a8a4bb4b69183cc6c2c6
2022-04-20Add cross-referencing support for Rust Sasha Smundak
Bug: 222044478 Test: run TARGET_BUILD_VARIANT=userdebug TARGET_PRODUCT=cf_x86_64_phone XREF_CORPUS=googleplex-android.googlesource.com/codesearch/android build/soong/build_kzip.bash Change-Id: Ia12eed53fafd0cbbbf2cc499fa20a0f5a40031de
2022-03-07Add stdlibs property for Rust build rules. Andrew Walbran
This lets no_std crates depend on system crates like core and alloc. Bug: 223152204 Test: built pVM firmware skeleton with rust_ffi_static rule Change-Id: I0f9b0ab3f5e3289fb8ce66f28d779bcf62a7181f
2022-01-24Support building rust modules against musl libc Colin Cross
Add a rust toolchain for musl libc, use std library built from source, and add default dependencies on musl libc. Bug: 216192129 Test: m USE_HOST_MUSL=true host-native Change-Id: Ic5ff4487db9693aeb08a13405f4d18465eecdc4b
2021-11-12rust: Support new rust_stdlib_prebuilt_host type Ivan Lozano
Refactor Rust prebuilts to support the new rust_stdlib_prebuilt_host module type, and change the format for depending on the prebuilt host stdlibs. Bug: 140642453 Test: m Change-Id: Ifbc4741818777934e917631c788b20911856c44a
2021-11-09rust: Refactor stripped output file path Ivan Lozano
Rust installed files reside in "$MODULE_OUT/stripped/" when they are stripped, otherwise they reside in "$MODULE_OUT". However, other parts of Soong assume that installed files are always in $MODULE_OUT (cc_modules place *unstripped* files in $MODULE_OUT/unstripped). This notably causes problems when adding Rust modules as test data in AndroidMkDataPaths. When Rust modules are parsed by AndroidMkDataPaths, if they are stripped then they incorrectly get installed as test data with the path: <install_root>/<relative_install_path>/stripped/file. This CL refactors how we handle Rust stripped output such that the installed file always resides in $MODULE_OUT. Bug: 171710847 Test: Installed files now always reside in $MODULE_OUT Change-Id: I53a6ff57a0a5a55cd95ea78ae592ce22abfa20c9
2021-10-14Flag an error on empty rust module srcs Seth Moore
It's an error if a rust module's srcs is empty. Prior to this change the output was a panic that complains loudly about a slice error and nothing else. This change doesn't stop the panic, but at least adds a bit of context so devs who make a simple mistake can more easily fix it. Test: SOONG_GEN_RUST_PROJECT=1 m nothing Change-Id: Id7d8465d533413c3000699661222a53a7c8678f3
2021-09-23rust: Refactor cfg and feature flag calculation Ivan Lozano
Move the cfg and feature flag calculation out of compilerFlags so that it's a separate step. The previous arrangement resulted in overridden compilerFlags which must to set any additional cfgs/features before calling the base. This is a bit confusing and undocumented behavior, so instead break it out into a separate call that can itself be overriden. Bug: N/A Test: Soong tests pass Change-Id: I28e4f707b3b3ca6eb621b7613c3737817f877bb8
2021-08-20rust: Hook up InstallIn functions + Product Matthew Maurer
InstallIn functions must be hooked up not only to install to special images, but also to receive special handling by android/arch.go such that some images are implicitly multilib: first. Also hook up more product details. Bug: 178565008 Bug: 165791368 Test: lunch aosp_arm64; m Change-Id: I1980d5aa9d55f78c222b98d60a404cd6ea5abbfb
2021-08-13Merge "rust: Allow modules to use only generated sources" Ivan Lozano
2021-08-13rust: Allow modules to use only generated sources Ivan Lozano
Removes the need for rust_test modules that test generated source to define a source file that simply calls include()! to pull in the generated source. Bug: 196076408 Test: m libselinux_bindgen_test Change-Id: I600301ab74f6ece861916fa2545b061c81b0d92d
2021-08-13rust: Link libunwind into Rust static executables. Ivan Lozano
Rust static executables fail to build due to missing unwind symbols. Make sure we link libunwind when building these. Bug: 194386505 Test: rust_binary with static_executable: true builds. Change-Id: I74bab25e186e181bc1ac8fdd608687707c662e4d
2021-08-12rust: Add support to emit certain Cargo env vars. Ivan Lozano
Some crates expect Cargo to provide certain environment variables. This CL adds a compatability flag that emulates the behavior of Cargo by setting these environment variables when building. Bug: 171011485 Test: New soong tests pass Test: quiche no longer requires patch removing CARGO_PKG_VERSION Change-Id: I4c95c284846f6075428c6f61fe8c260f2e35fbd9
2021-07-27rust: Prevent manually defined lib link flags. Ivan Lozano
Adds a filter to prevent modules from manually defining certain linkage flags. These flags should only be automatically generated based on listed dependencies. Bug: 161942165 Test: Soong tests pass Change-Id: Ibc014391ef1de10188c2d139d41d0241d6c68b5f
2021-07-20Replace android.BuildOs with Config.BuildOS Colin Cross
Replace the android.BuildOs constant with Config.BuildOS so that it can vary based on the product config. Bug: 190084016 Test: all Soong tests Change-Id: Ia67f872d8b2ab788747a22e3a9659dc21c9775cd
2021-07-07Remove IsDependencyRoot from interface Liz Kammer
This is equivalent to Binary() -- reduce the interface and improve clarity. Test: go test soong tests Change-Id: I770f5ce79fd4d888586d31ec5e67be88153626b6