Commit Graph

240 Commits

Author SHA1 Message Date
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
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
Thiébaud Weksteen 4318e1c650 rust: fully disable all lints when no_lint is set
If the no_lint attribute is set, we now explicitly disable any warning
or error.

Bug: 162897623
Test: cd external/selinux; mma; check the build log for warnings
Change-Id: I5338bda77ab25ded7cc43cc3afd29419fcbd9808
2020-08-07 13:56:35 +02:00
Thiébaud Weksteen 9bf3042493 Merge changes I329d0fe3,I8af9115b
* changes:
  rust: validate existence of library source
  rust: handle modules with same crate_name
2020-08-07 06:43:44 +00:00
Andrei Homescu c7767922e0 Export Rust SourceProvider types and methods
The AIDL compiler now uses SourceProvider to compiler the generated Rust
code from system/tools/aidl/build/aidl_interface.go using its own
SourceProvider object, which needs access to baseSourceProvider and all
methods of SourceProvider.

Test: mmma system/tools/aidl with 1357705 applied
Change-Id: I226609a7fccca2e7e1bfbad5d69d1821d37e43a1
2020-08-06 15:50:27 -07:00
Matthew Maurer 217a1e406e Merge "[rust] Escape flags for bindgen" 2020-08-06 21:33:49 +00:00
Thiébaud Weksteen 83ee52f4cd rust: validate existence of library source
While rust_bindgen modules may be interpreted as libraries, they do not
have a reference to the generated source until bindgen has been
executed. For now, ignore these modules.

Update the unit tests to cover the rust_bindgen case.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162881856
Change-Id: I329d0fe3d94b77d395c3684f55ab01544ff7c18f
2020-08-06 15:17:46 +02:00
Thiébaud Weksteen 2f628baeae rust: handle modules with same crate_name
crate_name do not need to be unique. A library may depend on two
different versions of the same crate. Use the module name instead of the
crate name when indexing the modules for rust-project.json.

Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Bug: 162896400
Change-Id: I8af9115b106fda2bed5b9fe96059cc29a33ac247
2020-08-06 15:17:42 +02:00
Thiébaud Weksteen c810510898 Revert "rust: validate existence of library source"
Revert submission 1391076

Reason for revert: Broken downstream Darwin build (b/162975597)
Reverted Changes:
I275f04639:rust: handle modules with same crate_name
Ie736d7ebb:rust: validate existence of library source

Change-Id: I1732d50a08546864f17cd826c8af574c1064c670
2020-08-06 12:28:08 +00:00
Thiébaud Weksteen 246e69c586 Revert "rust: handle modules with same crate_name"
Revert submission 1391076

Reason for revert: Broken downstream Darwin build (b/162975597)
Reverted Changes:
I275f04639:rust: handle modules with same crate_name
Ie736d7ebb:rust: validate existence of library source

Change-Id: I995923153c11db26b4af985f2eabe94912fb04d3
2020-08-06 12:27:56 +00:00
Colin Cross 2eddd06879 Merge "Add libraryDependencyTag to track dependencies on static and shared libraries" 2020-08-06 00:06:28 +00:00
Matthew Maurer 53bba5de8a Merge "Make Rust test harness optional for test binaries" 2020-08-05 21:26:45 +00:00
Ivan Lozano d13b308960 Merge "Make source_stem required for Rust SourceProviders" 2020-08-05 19:38:19 +00:00