Commit Graph

251 Commits

Author SHA1 Message Date
Matthew Maurer ad64c39442 Switch to armv7 for Rust ARM
In the previous mode, building Rust code using certain intrinsics would
fail on arm32 since our runtime is armv7, but our codegen was arm.

Test: cd external/rust; mma
Bug: 169245712
Change-Id: Ie800486b39325486f5ff319e46632df2a6987391
2020-09-24 14:28:47 -07:00
Colin Cross 2d53a608ae Merge changes from topic "return-new-deps"
* changes:
  Remove global state from version mutator
  Return new dependencies from BottomUpMutatorContext.Add*
2020-09-22 23:30:03 +00:00
Ivan Lozano 4de88a62c1 Merge "rust: Add libstd linkage mutator for rlibs." 2020-09-21 19:38:28 +00:00
Roland Levillain dba548af83 Merge "Introduce new Arm64 arch variant with dot product features" 2020-09-21 17:54:04 +00:00
Jeffrey Vander Stoep 4b524bac10 Merge "Use Rust 1.46.0 prebuilts" 2020-09-21 13:04:33 +00:00
Ivan Lozano 2b0811310e rust: Add libstd linkage mutator for rlibs.
The current state of linkage is that device targets always link
libstd dynamically except for rust_ffi_static which requires a static
libstd linkage. However this prevents producing rust_ffi_static
modules which depend on other Rust libraries as those dependencies
will link libstd dynamically and cause a collision. We also want our
rust_test modules to statically link in libstd as well.

This adds a linkage mutator for rlibs that creates a variant for each
libstd linkage. Dependent modules can then select the variant that
matches their linkage of libstd.

Also fixes an issue where installation paths were being generated for
rlibs and static libs even though they weren't being installed. This broke
when adding the linkage mutator as Make would complain about multiple
targets producing the same output.

Bug: 168729404
Test: rust_ffi_static module with other rustlib dependency can be built.
Change-Id: I955b484bf5809e8fc5517750c7f8df82d3ca8895
2020-09-18 16:35:14 -04:00
Jeff Vander Stoep 8cc38b800a Use Rust 1.46.0 prebuilts
Change-Id: I798082bb2bc5a0a40cdf470891aff9d9f0db7a07
2020-09-18 14:24:02 +02:00
Colin Cross d1f898e70a Remove global state from version mutator
A per-context variable is used to store the list of modules that
contain stubs and their available versions.  Stores the list of the
stubs versions on the implementation module, and then use the new
return values from AddVariationDependencies to expand dependencies
on implementation libraries to also depend on the stubs libraries.
Adds a new mutator pass to propagate list of stub versions to llndk
libraries.

Also creates an alias version variation called "latest" to allow
depending on the latest version without having to know what it is.

Test: all Soong tests
Test: no change to build.ninja, Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: If19659e2e5828c860fd4d679ef79a414b7ea2efc
2020-09-17 18:56:59 -07:00
Treehugger Robot 0c16fdf7a1 Merge "Don't disable rust modules for linux_bionic" 2020-09-15 04:06:37 +00:00
Jiyong Park b5d2dd210b Don't disable rust modules for linux_bionic
With If4300583edfb6d75bd4d984b38f73b6a406b4447, linux_bionic supports
arm64 and rust toolchain was configured to support the new target.
However, rust module types still have been disabled for linux_bionic
targets which forces many rust modules to be annotated with
target.linux_bionic_arm64.enabled: true, which will be very cumbersome.
Therefore, stop disabling the rust modules for linux_bionic.

Bug: 159685774
Test: HOST_CROSS_OS=linux_bionic m nothing
Change-Id: I68b97a43e8252fb82da6e87b3481fa237e1f2691
2020-09-15 12:56:13 +09:00
Treehugger Robot 5a1a88ee93 Merge "LinuxBionic supports arm64" 2020-09-14 15:59:16 +00:00
Ivan Lozano 74fe471e7a Merge "rust: Fix rust_bindgen implicits" 2020-09-09 22:04:38 +00:00
Ivan Lozano 0eef27a556 Merge "rust: Pass lld flags from cc to rust linker args." 2020-09-09 22:03:23 +00:00
Ivan Lozano 6d45a9863a rust: Pass lld flags from cc to rust linker args.
Rust is not passing the sysroot flag to Clang when invoking it as the
linker. This means files from the host may leak in, and host targets
may fail if sysroot files are not available from the host.

This patch prepends the lld flags from cc into rust linkargs. This
pulls in the sysroots flag, and also ensures that we remain in sync
with linkage flags used in cc.

The '-Wl,--no-undefined-version' from cc is overridden to avoid
missing version assignment errors for rust's generated alloc
functions.

Bug: 167690054
Test: cd external/rust; mma
Test: strace -f -e %file <host libstd.dylib.so build command> pulls
      from correct sysroots.
Change-Id: Ic40597f546f3b112012155614056afed487c6ca1
2020-09-09 14:20:00 -04:00
Jiyong Park 4afa2e2682 LinuxBionic supports arm64
LinuxBionic now supports arm64 architecture in addition to the existing
x86_64 arch. This is to make it possible to build host tools like adb,
fastboot, crosvm, etc. for Linux/ARM on regular Linux/x86 machines.

The arm64 target can be selected in various ways in Android.bp files:

   - target.host (because this is still considered as a host target)
   - target.linux (provided that the module is also enabled for host)
   - target.linux_bionic (use the OS name directly)
   - target.linux_bionic_arm64 (OS name + arch combo)
   - target.linux_arm64 (provided that the module is also for host)
   - target.not_windows
   - arch.arm64

The toolchain for the new target is almost the same as the toolchain
config for Android/ARM64. One notable difference is that the clang
triple is aarch64-linux instead of aarch64-linux-android, so that
__ANDROID__ is not defined for the new OS type.

Bug: 134795810
Test: HOST_CROSS_OS=linux_bionic HOST_CROSS_ARCH=arm64 m nothing

Change-Id: If4300583edfb6d75bd4d984b38f73b6a406b4447
2020-09-09 21:57:10 +09:00
Ivan Lozano 29139f9c02 Merge "[rust] Fix missing libclang for bindgen on darwin." 2020-09-09 12:27:34 +00:00
Ivan Lozano 54a8ee12fe [rust] Fix missing libclang for bindgen on darwin.
The LIBCLANG_PATH provided to bindgen should point to the directory
containing libclang, not the file itself.

Bug: 167977778
Test: m profcollectd
Change-Id: Iabd9970a763c192249b401a618a2d6990b02eab0
2020-09-08 13:13:07 -04:00
Chih-hung Hsieh 21928dbbdd Merge "Keep only out file dependency rule in output .d files" 2020-09-02 05:39:36 +00:00
Treehugger Robot 588aae727b Add rust_protobuf module.
This adds a new SourceProvider module type to handle protobuf code
generation. See the new test for an example of how to call this.

Bug: 143953733
Test: New soong tests pass.
Test: Replacing genrules in crosvm with rust_protobuf modules.
Change-Id: Ie3117129cde37b8736bc18ee09bf5cde27c01c34
2020-08-31 14:05:39 -04:00
Ivan Lozano ddd0bdb372 rust: Fix rust_bindgen implicits
rust_bindgen implicits currently include dependency-exported include
directories. This is incorrect, and causes issues when the include
directory is a generated directory.

Instead, remove the dependency-exported include directories from the
implicits list, and also add dependency-exported headers to the
implicits to handle these correctly.

Bug: 166779501
Test: Rust projects continue to build, test-case no longer failing.
Change-Id: Ia2da25de9e712b7306f19603dc9d14de6bac3fb3
2020-08-31 10:58:35 -04:00
Thiébaud Weksteen 682c9d7b25 Rename ccConfig to cc_config
Follow up from aosp/1413495 to set a consistent name throughout the
package.

Test: m
Change-Id: Idafcd973e7d874cd97599ac419c2972a8a5cd0b4
2020-08-31 10:06:16 +02:00
Thiébaud Weksteen fabaff6bd7 rust: strip libraries and binaries
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-28 10:50:17 +02:00
Thiébaud Weksteen 31f1bb80ef rust: add ccToolchain to Module
The cc toolchain information is required when using cc.Stripper.
Move to a Module method to avoid importing the cc package everywhere.

Test: m nothing
Bug: 153430439
Change-Id: I497dcdff4e767ecb8b8688c73cf88850c302683d
2020-08-28 10:47:11 +02:00
Thiébaud Weksteen 19e1c6c8e7 rust: enable use-android-relr-tags
Bug: 153430439
Test: m
Change-Id: I1873a180f0646cd1dba9e1756fd68bd788d4f725
2020-08-28 10:47:11 +02:00
Ivan Lozano b0e99edab1 Merge "[rust] Pass cc dependencies as linker flags." 2020-08-27 20:50:16 +00:00
Ivan Lozano 2093af23c0 [rust] Pass cc dependencies as linker flags.
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-26 17:07:29 -04:00
Ivan Lozano 4d947f0ea8 Merge "Link device binaries dynamically by default." 2020-08-26 20:32:32 +00:00
Raphael Gault 70b96b0d64 Introduce new Arm64 arch variant with dot product features
In order to rely on `-march`/`-mcpu` compiler flags for feature
detection, we introduce a new arch variant based on armv8.2 with the
addition of dot product features.

Test: test-art-target on Pixel 4.

Change-Id: I4d97db6129e2cd718a2b21008d36ec767739f925
2020-08-26 15:52:22 +00:00
Joel Galenson 6945e9b650 Migrate away from removed option
Upstream removed the -Z no-landing-pads option in
https://github.com/rust-lang/rust/pull/70175, which we picked up in
our latest toolchain update.

Fixes: 166317885
Test: Build and TreeHugger
Change-Id: I51c0ef671bf6a334b2b7223da42cab547e4407d3
2020-08-25 15:27:15 -07:00
Ivan Lozano 042504f7d6 Link device binaries dynamically by default.
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-08-25 13:32:53 -04:00
Jeffrey Vander Stoep 2e8a617bca Merge "Rust: use 1.45.2 prebuilts" 2020-08-20 17:14:19 +00:00
Treehugger Robot 2d815963ba Merge "Add AIDL compiler to allowed Rust paths" 2020-08-18 22:00:42 +00:00
Thiébaud Weksteen 2346b014eb Merge "rust: modify linting properties" 2020-08-17 07:01:14 +00:00
Chih-Hung Hsieh 29aa9fde5d Keep only out file dependency rule in output .d files
Bug: 163408818
Test: mm in external/rust/crates
Change-Id: I7ace46ca985813f292ce3429196defc5f234cf6b
2020-08-14 10:15:17 -07:00
Jeff Vander Stoep 3a9d80a60c Rust: use 1.45.2 prebuilts
Test: TH
Change-Id: I2eab5af0a822673ca1f5bb2f63c88edc2c7830ff
2020-08-14 13:53:38 +02:00
Matthew Maurer 61ca6a39cc Merge "Add Rust Binder crate to allowed list" 2020-08-13 21:13:57 +00:00
Thiébaud Weksteen 9e8451e524 rust: modify linting properties
Move the linting properties to an enum with 4 possible options:
"default", "android", "vendor" or "none". The previous logic for
default, based on the module's location, is kept. It is now possible to
force the upgrade to a certain lint level for some modules (e.g.
external/[...]/android). Update the unit tests and documentation.

Bug: 163400111
Test: m
Change-Id: I8e464b04401158ed2d3c518a9b72f145a9835c99
2020-08-13 15:58:09 +02:00
Treehugger Robot 50a58067e6 Merge "Stop using prebuilt NDK CRT objects." 2020-08-12 22:01:27 +00:00
Ivan Lozano 4c698f3ff2 Merge "Only return the source files of a Rust module with a SourceProvider if the internal compiler has been disabled" 2020-08-12 13:11:50 +00:00
Treehugger Robot 65c74d9f89 Merge "HostToolPath should return install path" 2020-08-12 02:45:40 +00:00
Chih-Hung Hsieh a756270ec2 HostToolPath should return install path
Bug: 163154468
Test: make; find dependencies of 'Module:  sqlite3_bindgen_x86_64'
Change-Id: Id9fc4f1937983bdf7eb1732ed6a8afd5aa3eb24c
2020-08-11 16:38:52 -07:00
Dan Albert 92fe740677 Stop using prebuilt NDK CRT objects.
We don't need the prebuilt versions. The NDK CRT objects are (now)
built from the platform sources and the only difference is that the
NDK CRT objects also include an ELF note that identifies the NDK
version, which isn't helpful for anything built by the platform.

Add a `crt` property to cc_object that allows CRT objects to identify
themselves. CRT objects, unlike other modules, will have a variant
built per-API level they support, rather than just an SDK variant and
a platform variant. This is needed because new CRT objects will rely
on APIs not available in old libcs and old CRT objects will not
support all the features of a modern one.

Test: treehugger
Bug: http://b/159925977
Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
2020-08-11 15:06:55 -07:00
Andrei Homescu 5db69cc896 Only return the source files of a Rust module with a SourceProvider if the internal compiler has been disabled
Test: mmma system/tools/aidl with assertOutput FIXMEs re-enabled
Change-Id: I84598ae2d1181656b7d68088f86ab016563e5d80
2020-08-11 13:25:25 -07:00
Stephen Crane fb67ab5152 Add Rust Binder crate to allowed list
Test: m libbinder_rs
Change-Id: I5c6b6216376a8b68c4fc7a30490c035c4fae54ff
2020-08-10 19:41:24 +00:00
Ivan Lozano a57e56a684 Merge "Export Rust SourceProvider types and methods" 2020-08-10 12:11:16 +00:00
Thiébaud Weksteen 95647739aa Merge "rust: fully disable all lints when no_lint is set" 2020-08-10 07:56:19 +00:00
Yi Kong 91c3e4ec1a [rust] Add profcollectd to allowed list
Test: none
Change-Id: I9c9b4ce10d5349d9a0e0759aeb6d8941b0d9fa65
2020-08-08 01:30:17 +00:00
Andrei Homescu 834152c033 Add AIDL compiler to allowed Rust paths
Change-Id: I10864f72ff5099ccd522ff31636ee61981dcdc4b
2020-08-07 22:07:43 +00:00
Treehugger Robot 2a73c2d060 Merge "Don't export link dirs from proc-macros." 2020-08-07 18:20:21 +00:00
Ivan Lozano 2bbcacf0c9 Don't export link dirs from proc-macros.
We shouldn't use exported link dirs from proc-macros as these may be
libraries for the wrong architecture or OS.

This doesn't cause a problem unless both the proc-macro and the
dependent library share a dependency. If that's the case, in some
circumstances it will cause the depdent library to fail compilation
when using a library with incorrect architecture.

Bug: 163088025
Test: Test case no longer colliding.
Test: cd external/rust/; mma
Change-Id: I46cbd850c3a89d10aa844b5c1b383e1070452d00
2020-08-07 09:00:50 -04:00