Fix mac builds by removing the -lrt and -lgcc_s flags from darwin
rust compiles.
Bug: 293349612
Test: builds
Change-Id: I99a9fea963761730efc4d3236135ee6d83dbca57
This reverts commit e7c71c344d.
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
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
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
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
Adds support for host-based Rust fuzzers.
Bug: 282897366
Test: SANITZE_HOST="address" m <host_fuzzer>
Test: run fuzzer
Change-Id: Ibb951f651ef12e763778ebbf12e66769a7113920
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
This is equivalent to Binary() -- reduce the interface and improve
clarity.
Test: go test soong tests
Change-Id: I770f5ce79fd4d888586d31ec5e67be88153626b6
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
Custom_bindgen is handled by adding a relevant dependency tag.
Flags and Ld_flags are not paths/references to other modules.
Test: go test soong tests
Change-Id: Ic6a69521102318b3b9f29b59560bcefbc9aff8fa
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
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
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
Rust configuration options ("--cfg") are currently defined using the
"flags" property. Adds a specific property to be able to forward these
to the rust-analyzer configuration (rust-project.json).
Bug: 183727250
Test: m libstd
Change-Id: Ida89097814bcd1a45c02a8a79ec5a8e9e59701bd
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
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
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
Pass an "android_vndk" cfg flag that indicates this code
targets the vndk. This can be useful in instances where code
might need to behave differently.
This also includes a fix to make sure our vendor Soong tests
are correctly configured.
Bug: 179907868
Test: Soong tests pass.
Test: Example module emits new cfg flags.
Change-Id: I01cdf91f6f9d42cd8a759266d5170479664bf4bc
Use prebuilts for x86 host targets to make both x86 and x86_64 builds
more consistent with one another. This fixes building x86 binaries.
Bug: 162063992
Bug: 169347277
Test: Build 32-bit host module.
Change-Id: Id11eb0f3b949439cec090060a33b755af94b5883
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