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
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
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
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
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
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
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
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
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
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
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
* "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
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
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
* 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
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
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
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