Commit graph

594 commits

Author SHA1 Message Date
Treehugger Robot
4af0d002a5 Merge "Installation routine for rust is similar to that of cc" 2021-10-12 00:05:37 +00:00
Seth Moore
af96f99d83 Include proc macro crates in rust-project.json
These crates were skipped before, leaving dependencies missing in
rust-project.json. Include them and mark them as `"is_proc_macro": true`
so that rust-analyzer can process them.

Fixes: 202290038
Test: SOONG_GEN_RUST_PROJECT=1 m nothing
Change-Id: Ia80e6f5e2f56a76608ba057075600e6b4424281b
2021-10-06 19:39:06 +00:00
Jiyong Park
d1e366a072 Installation routine for rust is similar to that of cc
This change makes the installation routine for rust be similar to that
of cc. Previously, rust.baseCompiler.install() (which internally calls
android.ModuleContext.InstallFile()) was not called when the module is
not installable. Although this may sound right at first glance, it is a
behavior different from that of cc and prevents an uninstallable rust
module from being packaged into a packaging module like
android_filesystem. This is because the packaging happens inside
InstallFile().

Fixing the issue by following the behavior of cc modules; Call
HideFromMake() or SkipInstall() when a rust module is not installable,
but call InstallFile() as long as the output file is valid.
InstallFile() internally skips the installation (but the packaging) when
HideFromMake() or SkipInstall() was called.

Bug: N/A
Test: atest MicrodroidHostTestCases
Change-Id: I15f4adc8544dac53647647d8bc4273f9f4acbeb2
2021-10-05 09:12:41 +09:00
Jiyong Park
2811e07868 rust modules respects the installable property
So far, the property wasn't respected.

Bug: N/A
Test: m
Change-Id: Ie3b011250595f02c3ab315efbac6694df3e181e7
2021-09-30 17:25:21 +09:00
Ivan Lozano
eabde18653 Merge "rust: Add require_root and vendor install base" 2021-09-24 18:39:47 +00:00
Joel Galenson
33e32f3ce5 Merge "Pass "--extern proc_macro" to rust_proc_macros." 2021-09-23 21:26:22 +00:00
Joel Galenson
ce7bbdc38a Pass "--extern proc_macro" to rust_proc_macros.
This is actually required for some code.

Test: Modify the new test so it fails and see it fail.
Test: Build crates that fail without it.
Change-Id: I527752b765e5552aa2de7e201f056955e053e1f3
2021-09-23 10:34:24 -07:00
Ivan Lozano
67eada34db rust: Refactor cfg and feature flag calculation
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
2021-09-23 12:21:04 -04:00
Ivan Lozano
ba2226164c rust: Add require_root and vendor install base
Adds the require_root property to rust_test modules so that tests can
run as root. Also adds an install base to allow vendor tests to install
to a different path, otherwise installs to 'unrestricted' like cc_test.

Bug: 200602232
Test: test with require_root: true runs as root
Test: test installed to new base directory
Change-Id: Ifa716871ff87471f0c0caff7af558d47db85ccd1
2021-09-21 11:01:11 -04:00
Zach Johnson
5145e9d917 Add NFC to the Rust allowlist
rustfmt & preupload checks are being checked in shortly

Bug: 197333653
Test: compile
Change-Id: I91f14dc9a58d04fda6ae77de2ea5d85f481d0563
2021-09-17 12:08:44 -07:00
Treehugger Robot
6e09abdf5c Merge "Update clang version used for bindgen to r433403" 2021-09-13 18:07:44 +00:00
Christian Wailes
c3cb99e61b Merge "Update the Rust prebuilt version number to 1.55.0" 2021-09-13 16:39:37 +00:00
Chris Wailes
d23f0d07e1 Update the Rust prebuilt version number to 1.55.0
Bug: 199547393
Test: m rust
Change-Id: I05831a107b46019205c0a7d530b6f2a3b1beba75
2021-09-13 16:38:27 +00:00
Yi Kong
ef99688cff Update clang version used for bindgen to r433403
Bug: 197230471
Test: presubmit
Change-Id: If8885beb979492c0a0c6cc4e310a9e09fd86da7b
2021-09-12 15:22:28 +08:00
Colin Cross
65e8f6d765 Merge "Make rust builds hermetic" 2021-09-10 19:51:20 +00:00
Pirama Arumuga Nainar
1799f9d7b4 [rust/coverage] Pass -z,nostart-stop-gc to the linker
Bug: http://b/199203503

Upstream LLVM change 6d2d3bd0a6 made -z,start-stop-gc the default.  It
drops metadata sections like __llvm_prf_data unless they are marked
SHF_GNU_RETAIN.  https://reviews.llvm.org/D97448 marks generated
sections, including __llvm_prf_data as SHF_GNU_RETAIN.  However this
change is not in the Rust toolchain.  Since we link Rust libs with new
lld, we should use nostart-stop-gc until the Rust toolchain updates past
D97448.

Test: m unicode-xid_device_test_src_lib and verify that they have the
__llvm_prf_data section.

Change-Id: I55eb3622dae9bd789fbacfe708600316102c365f
2021-09-10 10:33:30 -07:00
Colin Cross
748c8c7e09 Make rust builds hermetic
Rust builds were picking up the crt objects and system libraries like
libc.so from /usr/lib/x86_64-linux-gnu/Scrt1.o and
/lib/x86_64-linux-gnu/libc.so.6.  Pass --sysroot to the linker to
point it to the glibc prebuilts.

Test: manual
Change-Id: I6540df8aef0e5c2258de77456d18a6052db627d4
2021-09-10 09:55:54 -07:00
Lukacs T. Berki
9f6c24a887 Rename BuildDir and NinjaBuildDir.
These are just out/ and out/soong/ and the old names were quite
confusing.

Test: Presubmits.
Merged-In: I999ca62162062f27e449f83ffb00fa580d4065b8
Merged-In: I2fcd80a9e376a6842a06aa104a9f6f5c5e16f8c7
Change-Id: Ib481d2aac40df8da1b74174dc8ec576c1cb48be0
2021-08-27 10:08:49 +02:00
Matthew Maurer
80f0eb1e01 rust: Add UWB to allowlist
Change-Id: Ic89e274412c97631f615e6e9ccd711e9300397d1
Test: None
2021-08-26 20:38:16 +00:00
Joel Galenson
a7614dd626 Add system/logging/liblog.
This is needed so it can run bindgen tests.

Test: Build
Change-Id: Iefcd1077e3b572c662474c4bb461b04dc66c6204
2021-08-23 14:02:49 -07:00
Treehugger Robot
899b98d508 Merge "rust: doc: Zip up docs when done" 2021-08-20 22:11:17 +00:00
Matthew Maurer
ca68c49621 rust: doc: Zip up docs when done
Fetching artifacts from the build server doesn't go well with large
numbers of files in nested directories.

Produce an additional rustdoc.zip artifact to make this easier.

This change also prevents ${DIST} from receiving the unpacked rustdoc
site. This can be changed if b/188822051 is fixed.

Bug: 162741284
Test: m rustdoc; check resulting zip contents manually
Change-Id: I80b6a8fa6e274d2d8c3419d8734251afd4d7dba7
2021-08-20 13:08:16 -07:00
Matthew Maurer
9f59e8db27 rust: Hook up InstallIn functions + Product
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
2021-08-20 12:14:54 -07:00
Matthew Maurer
c6868383f4 Support Rust in Ramdisk
Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a ramdisk binary
Change-Id: I9682b978936624133e5a62e94caace0e8958fd0f
2021-08-17 15:08:49 -07:00
Matthew Maurer
a61e31f66a Support Rust in native-bridge
Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a native-bridge binary
Change-Id: I3546571530529203d9dbfd62777f20de18c6bd51
2021-08-17 15:08:49 -07:00
Matthew Maurer
52af5b052b Support Rust in Product
Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a product binary
Change-Id: I9c5aa5f3a1f323af9aa2aee804635045f1b91bd4
2021-08-17 15:08:49 -07:00
Matthew Maurer
460ee9429e Support Rust in Recovery
Bug: 178565008
Bug: 165791368
Test: Build and link a Rust library into a recovery binary
Change-Id: I1c76e6204019443c567082730a4cf680f4a2a74a
2021-08-17 15:08:49 -07:00
Ivan Lozano
0ad64f50fd Merge "rust: Allow modules to use only generated sources" 2021-08-13 19:37:04 +00:00
Ivan Lozano
e4db0036d7 rust: Allow modules to use only generated sources
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
2021-08-13 13:37:19 -04:00
Ivan Lozano
8711c5cf8c rust: Link libunwind into Rust static executables.
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
2021-08-13 13:15:31 -04:00
Ivan Lozano
dd7107c84b Merge "rust: Add support to emit certain Cargo env vars." 2021-08-12 17:05:39 +00:00
Ivan Lozano
a9a1fc0747 rust: Add support to emit certain Cargo env vars.
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
2021-08-12 13:18:34 +00:00
hamzeh
c0a671fc80 Moving common fuzzing code to fuzz package
Test: make haiku and make haiku-rust
Change-Id: Ife80cc10672f51bd6afbae7061cc9373a2a15e7d
2021-08-11 23:54:15 +00:00
Yabin Cui
60880e0517 Merge "Update clang version used for bindgen" 2021-08-11 21:12:27 +00:00
Joel Galenson
adffbe9166 Merge "Add libselinux to the Rust allowlist so we can run its test." 2021-08-11 17:20:35 +00:00
Yabin Cui
1424ea499d Update clang version used for bindgen
Bug: 190099451
Test: none
Change-Id: Ie0480288bb1be2e7d55d8dd01b8d006410bfc7a0
2021-08-10 15:13:01 -07:00
Joel Galenson
e4d6390558 Add libselinux to the Rust allowlist so we can run its test.
Test: Build and atest
Change-Id: Id828f286b35decfd16166e9cbb78cdf477014bf6
2021-08-10 11:54:14 -07:00
Chris Wailes
90c4b14a30 Removed commented out code
A previous CL commented out code instead of removing it.  This CL fixes
this grave error.

Test: TH
Change-Id: I1daeaaa1ad90230aec639d603e7cdb9b61af251a
2021-08-10 10:21:02 -07:00
Chris Wailes
353405d9fb Clean up generated rust-project.json files
This CL removes the roots section from the rust-projects.json file as it
is no longer required by the rust-analyzer tool.

Bug: 162055556
Test: prebuilts/rust/tests/rust-analyzer-integration-test.sh
Change-Id: I85c3277632c88394bc52e709ecce83f6aa1f2e0e
2021-08-09 15:50:39 -07:00
Treehugger Robot
27ac52198d Merge "Update the Rust prebuilt version number to 1.54.0" 2021-08-04 21:28:20 +00:00
Treehugger Robot
1e28e36589 Merge "[rust] [coverage] Don't pass -C link-dead-code" 2021-08-04 20:51:47 +00:00
Pirama Arumuga Nainar
b13e8ac6c8 [rust] [coverage] Don't pass -C link-dead-code
Bug: http://b/186873963

Per jgalenson@, this was added for GCOV and is not needed for clang
coverage.

Test: http://go/abtd/run/L71000000950546158
Change-Id: I352669687cbe764d938acb94d9d4fe0c24a31a56
2021-08-04 05:06:22 +00:00
Christian Wailes
99bc67a548 Merge "Conditionally apply rustdoc flags to third party crates" 2021-08-03 19:39:17 +00:00
Joel Galenson
48a7fb6afa Merge "Add librustutils to the Rust allowlist and remove libc." 2021-08-03 14:20:06 +00:00
Chris Wailes
b2703adce4 Conditionally apply rustdoc flags to third party crates
This CL changes the logic in rust/builder.go so that some rustdoc flags
are only applied to external crates.  This will allow us to since
warnings and deal with soft-failures in external crates while allowing
us to be more strict with our internal Rust code.

Bug: 195136952
Test: m rustdoc
Change-Id: Icdde304bbbb323cae9657e8f842f58ae79e811ce
2021-08-02 11:50:34 -07:00
Ivan Lozano
aa7c980002 rust: Disable dead stripping for fuzzers.
Without `-C link-dead-code`, Rust fuzzers may fail to start fuzzing.
See the cargo-fuzz issue in the code comment for details. This patch
disables dead stripping for our fuzzers by default.

Bug: 193200135
Test: Flag emitted when building Rust fuzzers.
Test: Fuzzer runs on device.
Change-Id: I530de30e9a57db206bcbf3d2d3d371628eef8934
2021-08-02 11:11:11 -04:00
Chris Wailes
3ac8f638df Update the Rust prebuilt version number to 1.54.0
This CL changes the Rust prebuilt version number from 1.53.0 to 1.54.0.

Test: m rust
Bug: 194812675
Change-Id: Icdbeab414dd39814f060e400cdca1fdb59f4f859
2021-07-30 18:10:30 +00:00
Joel Galenson
84be2fc380 Add librustutils to the Rust allowlist and remove libc.
Bug: 182498247
Test: Build
Change-Id: I0ea6c9b61cfdb667646e0067098f0ee5b9d9a2b3
2021-07-30 07:47:56 -07:00
Ivan Lozano
c4dae8eb27 Merge "rust: Prevent manually defined lib link flags." 2021-07-29 17:06:09 +00:00
Treehugger Robot
58fd4c43ea Merge "Added a flag to the rustdoc invocation" 2021-07-28 20:31:03 +00:00