summaryrefslogtreecommitdiff
path: root/rust/binary.go
AgeCommit message (Collapse)Author
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-03-23rust: Drop libgcc dependencyThiƩbaud Weksteen
Rustc unstable option "link-native-libraries" is used to prevent the linkage of other libraries via the #[link] directive. Add a dependency to libclang_rt.builtins, similarly to cc. Bug: 141331117 Test: lunch aosp_crosshatch-userdebug; m Change-Id: I5c232291a5dd08a99e6a12a1295e30bb8e4fcaf1
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
2021-02-04bp2build: convert paths/module refs to Bazel labelLiz Kammer
This currently expands all globs, still need to support converting glob syntax. Test: go build_conversion_test Test: GENERATE_BAZEL_FILES=true m nothing Test: m nothing Bug: 165114590 Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
2021-01-15Migrate Rust to LLVM coverage.Joel Galenson
Bug: 177675913 Test: Manually compile, run, and see output with llvm-cov. Change-Id: I66729cff87a848782e9fa1b95cbbc06318c5761a
2021-01-08Refactor CC to prep for Rust sanitizable modules.Ivan Lozano
Adds a PlatformSanitizable interface which both CC and Rust can implement so that the sanitizer mutators in CC can sanitize Rust shared/static libraries appropriately. Bug: 147140513 Test: m nothing Change-Id: Ib31103b6c4902a4d5df2565c0d7c981298d100a3
2020-12-09Move prefer_rlib from binary to base compiler.Ivan Lozano
Moves the prefer_rlib property out from being exclusively a binary property to one thats part of the base compiler properties. This provides a little more control over the libstd linkage in our libraries. Specifically, this enables a usecase where rust_ffi_shared needs to link against libstd statically rather than dynamically. Bug: 175121262 Test: New Soong tests pass. Change-Id: If68014c684a75ba70e9d7dacbb01c7d360dc25a1
2020-10-02rust: Add static binary supportIvan Lozano
Adds the "static_executable" property to rust_binary modules which allows for building fully static executables. This only impacts bionic targets. Bug: 169434439 Test: rust_binary module with static_executable true builds, runs on device. Change-Id: I83c19fddd070859b7e56d248237cfd73e1768519
2020-09-28rust: Refactor staticStd to stdLinkageIvan Lozano
Instead of returning a boolean, return an enum value to improve readability and provide greater flexibility for future modifications. Bug: 168729404 Test: Soong tests pass Change-Id: Iddcdae8c34be09e476404382e43d1ea5935bae65
2020-09-28rust: Add prefer_rlib property for static libstd.Ivan Lozano
Adds the prefer_rlib property to allow linking libstd statically for device rust binaries. This also changes the default behavior of rustlibs to also prefer rlib linkage. This is because dylibs do not provide rlib-libstd variants and always link in libstd dynamically. Thus a binary requesting libstd rlib linkage should not attempt to link against dylibs that link libstd dynamically. Bug: 168729404 Test: New Soong test passes. Change-Id: Idf8dfbbce8fd936f55a3fb323b17a1a7f0ee954e
2020-08-28rust: strip libraries and binariesThiƩbaud Weksteen
Reuses the cc.Stripper logic. Abstracts Stripper to avoid the spreading of references to the cc package. rustc requires unstripped libraries (precisely, with the `.rustc` section) when building dependent targets. Contrary to cc, the output of a compiler module will remain unstripped and only an extra build rule will be added. This rule will be referenced at install time (in baseCompiler.install or androidmk). This change drastically reduces the size of the installed libraries: (unstripped, from out/target/product/crosshatch/system) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 149996 total (stripped, with this change) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 42380 total Bug: 153430439 Test: cd external/rust; mma Change-Id: I94fd8bbcec97e0610aa325d3db4460be84d01734
2020-08-27Merge "[rust] Pass cc dependencies as linker flags."Ivan Lozano
2020-08-26[rust] Pass cc dependencies as linker flags.Ivan Lozano
In order to support cc dependencies which do not start with the 'lib' prefix, we can't pass them through the -l flag. Instead, we can pass them directly to linker flags. Bug: 166151658 Test: cd external/rust/; mma Test: cd external/crosvm/; mma Test: Test linking to a cc dep that does not begin with 'lib' Change-Id: I5acbf3d3405e66446f3eae600b35683c4eb3d8a5
2020-08-25Link device binaries dynamically by default.Ivan Lozano
Device binaries currently are linked statically by default. Instead we should be linking these dynamic by default. To avoid conflicts when manually specifying rlib dependencies on modules, we always link libstd dynamically for all device modules except static libraries. This removes the "prefer_dynamic" property entirely to avoid confusion. Bug: 165161105 Test: m profcollectd is built dynamically. Test: cd external/rust/; mma Test: cd external/crosvm/; mma Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
2020-07-29Merge changes I4efdf333,I4abaf8e7Ivan Lozano
* changes: Ensure hermetic device rust_bindgen. Generate deps file for rust_bindgen modules.
2020-07-28Ensure hermetic device rust_bindgen.Ivan Lozano
rust_bindgen was not hermetic previously as it would pull in host headers for device targets. This fixes that by using the same flags we use when compiling with Clang. This also makes sure our rust_bindgen headers are built as similar as possible to their respective cc_libraries. This also pulls in the bionic dependencies as well, which provide the headers required for device targets. Bug: 162007475 Test: device rust_bindgen deps file does not reference host headers. Change-Id: I4efdf333e011a6c6d73a0345e5485823f166d17a
2020-07-22Enforce correct variant usage for rust_bindgen.Ivan Lozano
Modules defined in the srcs property are automatically added as dependencies with AddDependency(), which will use any variant available. This can cause incorrect architecture bindings to be silently pulled in, such as when a host module uses a rust_bindgen module that doesn't create a host variant. This moves populating depPaths.SrcDeps over to depsToPaths and adds a check for SourceProviders to make sure the correct OS and architecture is being used. Bug: 161826371 Test: Soong no longer silently pulls in bindings for the wrong target. Test: New Soong test to catch this case passes. Change-Id: I2b3651cf6fc7dabf4081434df1c455e637f5b3a4
2020-07-20Allow rust module dependency on SourceProviders.Ivan Lozano
Allow rust modules to depend on and use generated source code provided by SourceProvider modules and genrule modules without resorting to hardcoded output paths. All generated sources are now copied to a dependent module's intermediates directory, then OUT_DIR is set to point to that path when calling rustc. This matches the common convention used in most rust crates to include generated source code from the path defined in the OUT_DIR environment variable. A couple other small notable changes are included in this CL: * prebuiltLibraries can no longer include generated source files as they should be prebuilt. * srcPathFromModuleSrcs now excludes the main source file from the second return value so its a list of only the generated sources. Bug: 159064919 Test: Local example rust_library compiles with rust_bindgen dependency. Test: Local example rust_library compiles with genrule dependency. Test: Collision detected when multiple providers produce similar output. Test: New Soong tests pass. Change-Id: I59f54a25368c680b9086420c47ec24ab8cd1de6b
2020-07-08Specify module dependency in the srcs listChih-Hung Hsieh
* "srcs" list contains one main Rust source file, followed by optional dependent modules. * A dependent module included in the "srcs" list is the module name prefixed with ":". * Add a simple test. Bug: 160331255 Test: make and manual test build dependencies on genrule modules Change-Id: I4f079138c2599158810b6412fce81b612a3f64a4
2020-07-01rust: Add rustlibs auto dependency selectionMatthew Maurer
Adds the rustlibs dependency type which will automatically select between rlib and dylib based on the type of the library. Bug: 143217452 Test: cd external/rust; mma Change-Id: I97faadae98bf957090a32939cfb2d3a10f74a057
2020-06-16[Rust] Remove unused variables and deduplicate.Ivan Lozano
Bug: 158731826 Test: cd external/rust/crates; mma Change-Id: I8c9e5cfeaf941b9676b92451b227c15db9a41bbc
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
2019-12-13Install rust tests under nativetest(64)Chih-Hung Hsieh
* Now the installation directories match those for C/C++ tests: * The relative_install_path refers to path under nativetest(64). * Device test files are installed in data/nativetest(64). * Automatically generated configuration files and copied test binaries are still in the "testcases" directory. * Change host test configuration to run test binary files in testcases/<mutated_module_name>/<arch_type>/<stem_name> Bug: 140938178 Test: atest --include-subdirs under external/rust/crates Change-Id: I4b29afb897f4ba8749e87f79857c5b1a959bb2b0
2019-11-14Merge changes from topic "rust-sysroot"Jeffrey Vander Stoep
* changes: Enable x86_64 device support Build Rust Device Sysroots in Soong
2019-11-13Build Rust Device Sysroots in SoongMatthew Maurer
In order to ensure we are using current platform Bionic for any platform Rust binaries, we need to build the sysroot in Soong. This will also enable us too hook the "test" crate if necessary. While both a dynamic and static sysroot are available, on device only a dynamic sysroot will be injected. On host, we continue using the sysroot used to build the compiler as before. Bug: 139486496 Change-Id: I127377e5b056610ceb5015a34d266250320fbc31
2019-11-05Soong Rust source clean up.Ivan Lozano
Break up some of the longer lines in the Rust source and refactor the TransformSrcto* functions to take fewer arguments. Bug: N/A Test: m -j crosvm.experimental Change-Id: Ia0deb8bfe3e1bfd07ef35633e9a7e6f5e799b3a3
2019-09-24Add AArch64 device Rust toolchain.Ivan Lozano
Bug: 141207434 Test: build example rust device module. Change-Id: I0932a614942bf4a4d4b6c153fcc4fc79c7f202bd
2019-08-28Add Rust support to Soong.Ivan Lozano
Adds support to Soong for building rust modules. This currently only supports x86_64 device and x86 linux host targets. The functionality is sufficient to build crosvm. Bug: 136189233 Test: Test module builds. Test: crosvm builds. Change-Id: I6ea04615834a6d673578ab10ea1a2eb04259fe09