summaryrefslogtreecommitdiff
path: root/rust/rust.go
AgeCommit message (Collapse)Author
2021-10-14rust: Package shared libraries with fuzzer zips Ivan Lozano
Rust fuzzers were not packaging up their CC shared dependencies. This would lead to fuzzers using the shared libraries included on system, which may not be sanitized, leading to incorrect behavior. This refactors the relevant code from CC and calls it from the Rust build logic. Bug: 202282599 Test: output rust fuzzer zip file includes shared dependencies. Change-Id: I92196eb0141733797a67eae24f8e9aedea94c3bc
2021-10-05Installation routine for rust is similar to that of cc Jiyong Park
This change makes the installation routine for rust be similar to that of cc. Previously, rust.baseCompiler.install() (which internally calls android.ModuleContext.InstallFile()) was not called when the module is not installable. Although this may sound right at first glance, it is a behavior different from that of cc and prevents an uninstallable rust module from being packaged into a packaging module like android_filesystem. This is because the packaging happens inside InstallFile(). Fixing the issue by following the behavior of cc modules; Call HideFromMake() or SkipInstall() when a rust module is not installable, but call InstallFile() as long as the output file is valid. InstallFile() internally skips the installation (but the packaging) when HideFromMake() or SkipInstall() was called. Bug: N/A Test: atest MicrodroidHostTestCases Change-Id: I15f4adc8544dac53647647d8bc4273f9f4acbeb2
2021-09-30rust modules respects the installable property Jiyong Park
So far, the property wasn't respected. Bug: N/A Test: m Change-Id: Ie3b011250595f02c3ab315efbac6694df3e181e7
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-17Support Rust in Ramdisk Matthew Maurer
Bug: 178565008 Bug: 165791368 Test: Build and link a Rust library into a ramdisk binary Change-Id: I9682b978936624133e5a62e94caace0e8958fd0f
2021-08-17Support Rust in native-bridge Matthew Maurer
Bug: 178565008 Bug: 165791368 Test: Build and link a Rust library into a native-bridge binary Change-Id: I3546571530529203d9dbfd62777f20de18c6bd51
2021-08-17Support Rust in Product Matthew Maurer
Bug: 178565008 Bug: 165791368 Test: Build and link a Rust library into a product binary Change-Id: I9c5aa5f3a1f323af9aa2aee804635045f1b91bd4
2021-08-17Support Rust in Recovery Matthew Maurer
Bug: 178565008 Bug: 165791368 Test: Build and link a Rust library into a recovery binary Change-Id: I1c76e6204019443c567082730a4cf680f4a2a74a
2021-08-12Merge "rust: Add support to emit certain Cargo env vars." Ivan Lozano
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-08-11Moving common fuzzing code to fuzz package hamzeh
Test: make haiku and make haiku-rust Change-Id: Ife80cc10672f51bd6afbae7061cc9373a2a15e7d
2021-07-23Merge "Add a phony target for all Rust targets" Treehugger Robot
2021-07-23Add a phony target for all Rust targets Chris Wailes
Test: m rust Change-Id: Id347edf9998f6714622c9f173420477a9e534723
2021-07-22rust: Add support for bootstrap linker. Ivan Lozano
Adds the 'bootstrap' property to Rust modules to set the linker to the bootstrap linker. Bug: 194276829 Test: set bootstrap: true on module, checked .interp section on output. Test: bootstrapped binary runs. Change-Id: I459c8194902cfea3c44b060e70d28a43fcba3ade
2021-07-16Refactoring fuzz packaging code hamzeh
Rust and cc fuzz packaging have common. This change is to put this common methods and fields into fuzz_common. Test: make haiku and make haiku-rust ran locally and verify corpus, dict and config are packaged along with the executable. Change-Id: I04bf535cd2597ed8b2bd3d8e6ea8c28f38bdc18b
2021-07-09Support customizing behavior around sourceOrOutputDependencyTag Paul Duffin
Previously, modules customized behavior around the handling of sourceOrOutputDependencyTag by comparing them to android.SourceDepTag and retrieving the module using something like this: ctx.GetDirectDepWithTag(m, android.SourceDepTag) The problem with that is it does not allow an output tag to be specified and does not handle fully qualified names properly. This adds the following: * IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter also checks that it has the correct output tag. * GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for ctx.GetDirectDepWithTag(m, android.SourceDepTag). Replaces usages of: * t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "") * ctx.GetDirectDepWithTag(m, android.SourceDepTag) with GetModuleFromPathDep(ctx, m, "") It also deprecates the following: * android.SourcDepTag - as a follow up change needs to modify the sourceOrOutputDependencyTag will make this useless. * ExpandSources, ExpandsSources - copies existing deprecated messages from the implementation to the interface so that they can be seen by users of that interface. Bug: 193228441 Test: m nothing Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
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
2021-07-01Include static lib information for the snapshot modules Justin Yun
snapshot modules require the list of static libs to find the NOTICE files for the snapshot modules. snapshot binaries must include static_executable property to check if non static binaries have libc as a static lib. Bug: 190690041 Test: Check NOTICE for libaudiopreprocessing.so built from snapshots. Change-Id: I53f7549a158ab27ada87833a3f4d58620aa7c3cf
2021-06-28Merge "rust: Add missing Rust allow path modules." Ivan Lozano
2021-06-28rust: Add missing Rust allow path modules. Ivan Lozano
Adds rust_benchmark and rust_fuzz to the list of Rust module types which need to be in the allowed paths, and a comment about rust_bindgen and rust_protobuf. This also adds a downstream allow path list which helps prevent merge conflicts if downstream wants to extend the list of allowed paths. Bug: 191507775 Test: Paths are checked for the newly added module types. Test: Paths in DownstreamRustAllowedPaths allow Rust modules. Change-Id: Ida80c33a815d47ffdfb1f648125d71316a2a9d8a
2021-06-24Rust module in APEX uses stub libraries across APEX boundaries Jiyong Park
This change fixes a bug that rust module in APEX has access to private symbols of a native library even when the native library is outside of the APEX. To fix this, the stub selection logic in the cc package is exctacted as a function ChooseStubOrImpl and is used also in the rust package. Bug: 190767845 Test: m Merged-In: I5c4cbdd5d27f257ab329d9dadbcd87d41a87f46a Change-Id: I5c4cbdd5d27f257ab329d9dadbcd87d41a87f46a (cherry picked from commit 3b5f88e0913f3df579f4dc0c87daac88665b1073)
2021-06-03Rust rlib vendor snapshot support. Ivan Lozano
Adds support for snapshotting Rust rlibs. This allows us vendor-specific code that uses rlib-only linkage until dylib snapshot support is added. Bug: 184042776 Test: m nothing # new Soong tests pass Test: Example test Rust vendor module builds Test: m dist vendor-snapshot # includes rlibs Change-Id: I4976d3e1efec0ee778cc97730d45be471dffb678
2021-06-03Rust cdylib/statliclib support for vendor snapshot. Ivan Lozano
Adds support for platform vendor_available Rust FFI libraries and binaries to be included in the vendor snapshot. Because rlib and dylibs are not yet in snapshots, libstd cannot be included in a vendor snapshot. As a result, vendor-specific Rust code can't be guaranteed to work with the platform-provided vendor_available modules built with a newer toolchain. For now, a check is added indicating vendor-specific Rust code is unsupported. This changes the linkage for vendor variants of these modules to default to rlib linkage since dylibs cannot be included in the snapshot yet. Bug: 184042776 Test: m nothing # new Soong tests pass Change-Id: I502eaa4bb962eb87ff868fcf49b435f0d2f982e6
2021-05-17Don't install rust modules that are never installable Jiyong Park
rust modules that return false on EverInstallable don't get installed. Currently, proc_macro modules are such ones. Bug: 187810017 Test: m microdroid on aosp_arm64 and inspect that *.dylib.so files from host x86_64 are not there. Change-Id: Ia57289a04dbff6e4f2ce2733c60de5338305904c
2021-05-12Refactor vendor snapshot to use LinkableInterface. Ivan Lozano
Refactors the vendor snapshot support to use the LinkableInterface so that support can be extended to Rust. This CL does not add vendor snapshot support for Rust; that is left for a follow-on CL. Bug: 184042776 Test: m nothing Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
2021-04-27Remove global state from vendor public libraries Colin Cross
Remove the global list of vendor public library modules used to rewrite dependencies from the vendor module to the stubs for system modules, and replace it with building the stubs directly in the system variant of the vendor module. Bug: 178231622 Test: vendor_public_library_test.go Change-Id: I826e69ffd507d7e85fa3d4d85b5157428c642143
2021-04-26Remove obsolete llndk_library Colin Cross
Remove llndk_library in favor of cc_library with llndk.symbol_file. Bug: 170784825 Test: m checkbuild Test: TestLlndkLibrary Change-Id: I43580976589a7a2a176d7442be53fa043c0c8324
2021-04-26Remove llndk_headers Colin Cross
Replace llndk_headers with cc_library_headers with llndk.llndk_headers: true. Bug: 170784825 Test: m checkbuild Test: compare out/soong/build.ninja Test: TestLlndkHeaders Change-Id: I33b411cd4d474318796c2073375176b82dd8c216
2021-04-26Add support for cc_library_headers to replace llndk_headers Colin Cross
Set llndk.llndk_headers: true to allow a cc_library_headers module to be used by a cc_library module with llndk.symbol_file set. Bug: 170784825 Test: TestLlndkHeaders Change-Id: Ib65a4b70717dc9a54ae30f2991485bb1bb9b8409
2021-04-16Rustdoc support. Dan Albert
Adds `m rustdoc` which generates documentation for all Rust libraries to $OUT_DIR/soong/rustdoc. Follow up work: * Generate an index page that lists all modules. * Preserve the artifacts so we can have an always-up-to-date go link. Test: m rustdoc Bug: None Change-Id: Id2d6b9cbab5b02e36b575567563d7cc7606b9401
2021-04-15Merge changes I59439b77,I7dbaf8be Thiébaud Weksteen
* changes: bloaty: measure stripped Rust binaries rust: do not strip static library
2021-04-15bloaty: measure stripped Rust binaries Thiébaud Weksteen
Modify bloaty's MeasureSizeForPath to allow a module to provide multiple paths. This is used to measure both unstripped and stripped libraries/binaries. Add unit test to ensure correct measurements are generated for Rust. Test: m out/soong/binary_sizes.pb.gz Change-Id: I59439b77dbf1cf5ad71e1c02996a6a90938536b4
2021-04-14Merge changes from topic "rust_vendor_support" Ivan Lozano
* changes: Add more Rust vendor image support. rust: Use new common image mutator interface.
2021-04-14Merge "cc: Create a common image mutator interface" Ivan Lozano
2021-04-14Merge changes from topic "rust_benchmark" Jeffrey Vander Stoep
* changes: Attach rust_benchmark to atest and tradefed. Add rust_benchmark module to soong.
2021-04-13Add more Rust vendor image support. Ivan Lozano
This adds Rust vendor image support for all module types except Rust prebuilts. Bug: 184042776 Test: New Soong tests. Test: Example cc_library vendor module can depend on rust_ffi_shared. Test: Example rust_library vendor-only module compiles. Change-Id: Iaa30ad51fdaedcbf14687da5472581f6af62ff59
2021-04-13cc: Create a common image mutator interface Ivan Lozano
As part of adding Vendor support to Rust, refactor the image mutator in CC to a new common image mutator interface so this logic can be reused across both CC and Rust. Bug: 184042776 Test: m nothing Change-Id: Ia55d5ad840db7cf1a64d6c65ed86487230cb8742
2021-04-08Shared lib dependencies from rlib are included in APEX Jiyong Park
This change fixes a bug that shared lib dependencies of an rlib is not installed to the APEX even when the rlib is part of the APEX. Bug: N/A Test: m Change-Id: I88fe461584499839d8018d6b4292374592e7562b
2021-04-07Stripped rust bin/libs are included in APEX Jiyong Park
Previously, when a rust bin or library is selected for an APEX, OutputFile() was used to get the file to be used. However, OutputFile() always returns the unstripped output file even when the stripped output file is available. As a result, APEX having a rust module was very big due to the debugging information that exists in the unstripped file. When a rust module is directly installed to the built-in partitions, we use the stripped one whenever it's available. To make the same happen when the rust module is placed in an APEX, OutputFile() is modified to return the unstripped output if it's available. Bug: 181751814 Test: TARGET_BUILD_APPS=com.android.virt m The size is reduced from 180MB to 43MB Change-Id: I6f8479e6a4794aac8bf94a84afdf65d417c75db0
2021-04-06Add rust_benchmark module to soong. Jakub Kotur
This commit adds rust_benchmark and rust_benchmark_host commands to soong. Respectively running rust benchmarks on device and host. Currently only criterion based benchmarks are supported and criterion library is automatically linked. Test: atest <module with rust_benchmark defined> Bug: 155309706 Change-Id: I6edfc2b4bf30b1163fe59b8c2ecdcd4e7125e7b9
2021-03-26Merge "rust: Add whole_static_libs, revert static_lib" Ivan Lozano
2021-03-25rust: Add whole_static_libs, revert static_lib Ivan Lozano
Revert the static_lib behavior to the previous behavior (pass static libs to the linker rather than via to rustc using `-lstatic=<lib>`). To bundle static libraries into libraries, provide the whole_static_libs property which retains the current static_libs behavior. Passing all static libraries via -lstatic was resulting in odd bloat where in some cases static symbols were duplicated in binaries and libraries. This split makes it possible to be explicit about when static libraries should be bundled. Bug: 183182230 Test: mma system/bt; mma system/security/keystore2; mma external/rust Change-Id: Ic2dde5d1542dca5ce145aa3a3fbd9ea54440d991
2021-03-23Versioned CRT objects are built with correct __ANDROID_API__ Jiyong Park
Background: `min_sdk_version` of a crt object is the oldest SDK version that the crt object supports. When it's set to for example 16, Soong creates a number of versioned variants of the crt object starting from 16 to the latest version. The variant for version X is provided to NDK clients having `min_sdk_version` set to X. Problem: all versioned variants of a crt object were built with `-target <arch>-linux-android16`. Therefore they all have been with `#define __ANDROID_API__ 16`. This is because the mutated variants still have the same min_sdk_version property and the clang triple follows min_sdk_version, not sdk_version. This is too conservative and against our intention to provide the latest crt object that matches with the min_sdk_version of the client. In the other hand, the platform(non-sdk) variant of the crt object doesn't have such a problem. min_sdk_version is completely ignored. However, this is a bug and will be fixed by aosp/1640364. As a side effect of the fixing, the platform variant will begin to built with a very old __ANDROID_API__ which unnecessarily turns off the new platform features like the TLS segment over-alignment. This change fixes the problems: * For the versioned variants of crt objects, we set both `min_sdk_version` and `sdk_versio` to the version that the variant is created for. * For the platform variant of crt objects, `min_sdk_version` is force reset to "current". Bug: 183191008 Test: m Change-Id: I8c9d0fcea816de8cd1532dac4a47eee4f726c037
2021-03-15Export OUT_DIR variable to rust-project.json Thiébaud Weksteen
This variable is required by rust-analyzer to correctly process crates that uses the include!(concat!(env!("OUT_DIR"), ...)) pattern. Adds an initialize method to baseCompiler to save the computed path for this directory. It is not possible to use the BeginMutator as the BaseModuleContext does not contain enough information to use PathForModuleOut. Bug: 175004835 Test: SOONG_GEN_RUST_PROJECT=1 m nothing; inspect rust-project.json Change-Id: If47b3832d3cca5712ae87773c174a61f5ee27bf8
2021-02-09Merge "rust: Add rust_ffi_static vendor ramdisk Support" Ivan Lozano
2021-02-08rust: Add rust_ffi_static vendor ramdisk Support Ivan Lozano
Similar to our vendor support, this adds support for linking rust static libraries to vendor ramdisk cc modules. A bug fix is also included where a restriction against setting rust_ffi vendor-specific was not being enforced. Bug: 179397942 Test: Example modules link, Soong tests pass. Change-Id: I737cdf0c2f49ab349bcea2a0429e6298ebc1313e
2021-02-05rust: Only pass "-lstatic" for rlibs. Ivan Lozano
Passing '-lstatic' for dylib static dependencies results in some unexpected bloat as the static libraries are included as whole-archives. For now, limit this to rlibs while we investigate. Bug: 175886967 Bug: 179122837 Test: cd system/bt/; mma Test: Checked size of dylibs. Change-Id: Id8328e95771e2ca8503bc8df35248b1c39cabc8e
2021-02-05Merge "rust: Pass cc static libs to rustc." Ivan Lozano
2021-02-04rust: Pass cc static libs to rustc. Ivan Lozano
Pass static libraries to rustc via the "-lstatic" flag so that rustc can reason how to handle these libraries. This means that these static libraries get bundled into rlibs, reducing the need to redeclare these dependencies in dependent modules. Additionally, exported depFlags were never used anywhere, so remove this from flagExporter. Bug: 175886967 Bug: 179122837 Test: m Test: Checked that static symbols aren't duplicated in a resulting binary when it appears in a dependency graph more than once. Change-Id: Ifeb3c384e4fad8704206997242a0156ddcb87d2c