Commit graph

85 commits

Author SHA1 Message Date
Aleks Todorov
24a3d377d8
cc: Enable select syntax for cppflags
Bug: 325444956
Test: m
Test: m [custom build target with select in cppflags]
Change-Id: I7d27096526ce5b37afe447f900613a6fbb639986
2024-10-24 19:41:23 +02:00
Cole Faust
e96c16a806 Make the cflags property configurable
So that you can use select statements on it. The current modivation
is to convert a module from make to bp with minimal soong config
variable boilerplate.

Bug: 342006386
Bug: 346922064
Test: m nothing --no-skip-soong-tests
Change-Id: I48d5a11ad3aa65c24cc199458634a5fdbeab2f64
2024-06-13 14:51:14 -07:00
Ivan Lozano
3b591c771a rust: Support for generated c files from bindgen
To handle static inline functions, bindgen generates a C file which is
expected to be compiled and linked into dependents on the generated
bindgen source.

This CL adds support for cc modules ingesting this output and for
bindgen to produce it (and link it against the bindgen rust_library
variant as well).

Bug: 290347127
Test: m blueprint_tests
Test: Example module with static inline functions builds locally
Change-Id: I167a8356eb6e0059fc21169fd3bfc6bf4d9c812f
2024-05-03 14:01:09 -04:00
Ellen Arteca
810c37ec1e Adds support to bindgen to handle static inline fcts
Adds support for bindgen to be able to handle `static inline`
functions. This is done by adding a new boolean field to the `BindgenProperties`
struct, `Handle_static_inline` (default to false).
If this field is true, then the flags to trigger bindgen support of
static inline functions are passed in.

The rust-bindgen documentation list two ways of handling `static inline`
functions, both specified with command line args.
1) --generate-inline-functions
2) --experimental --wrap-static-fns

Option 1 requires some extra effort on the part of the C library developer, in
that they have to expose the function symbols: the docs (linked below) explain
that this is often done by compiling the library with inlining disabled, which
can be detrimental to performance.

Option 2 requires no effort on the part of the C library developer, but it does
require the `--experimental` flag, since this feature is still under development.

This CL goes with option 2.

Relevant docs: https://github.com/rust-lang/rust-bindgen/discussions/2405

This CL also adds a new test: TestBindgenHandleStaticInlining in bindgen_test.go

Test: m blueprint_tests
Change-Id: If28000e3f3ccecc65c4cae1c62d7bf455454239a
2024-04-23 00:48:25 +00:00
Ivan Lozano
1dbfa144f9 rust: Fix handling of bindgen header libs
Static libraries were being appended to the list of header library
dependencies. They should not be. This also makes sure we track them
appropriately in Make.

Test: m blueprint_tests
Change-Id: Ifa664f09fe2102aea57d22cbaaeba71f0c26074d
2024-03-29 16:30:30 +00:00
Yi Kong
52e5e6b1a7 bindgen: set -Wno-unknown-warning-option flag by default
Test: presubmit
Change-Id: Id8547c0b3263f4e3b060f8b0fce2aef8a494b1b2
2024-02-25 12:49:41 +08:00
Aditya Kumar
ef7c121a6b Revert^2 "Update clang version to clang-r510928"
22686bab04

Change-Id: I1117546bb71548e1146c6ae43419b6aef772f812
2024-02-02 14:32:47 -08:00
Pirama Arumuga Nainar
22686bab04 Revert "Update clang version to clang-r510928"
Revert submission 2804373-clang_r510928

Bug: http://b/301328082

Reason for revert: Broke aosp-main/aosp_x86-next-userdebug

Reverted changes: /q/submissionid:2804373-clang_r510928

Change-Id: I6802b329e8dbd9dce5a75aab76c43960765a8594
2024-01-31 06:51:49 +00:00
AdityaK
0790ce2e56 Update clang version to clang-r510928
Bug: b/301328082
Test: N/A
Change-Id: Ied250c42c33d9e2d8bd9b9161b9028874540addb
2024-01-30 15:09:29 -08:00
Kiyoung Kim
aa39480d21 Split usage of UseVndk
UseVndk is a function to check if the module can use VNDK libraries, but
this function was also used to check if the module is installed in the
treblelized partition (vendor or product). As of VNDK deprecation,
UseVndk funtion will return false even when the module is installed in
vendor / product partition, so we need a separated function to check
this. This change introduces a new function 'InVendorOrProduct' which
replaces UseVndk based on its usage.

Bug: 316829758
Test: m nothing --no-skip-soong-tests passed
Change-Id: Ic61fcd16c4554c355f6005894a4519b044b27fe5
2024-01-09 11:37:14 +09:00
Justin Yun
41cbb5e9b5 Define __ANDROID_VENDOR_API__
cc modules can use __ANDROID_VENDOR_API__ to read BOARD_API_LEVEL
that is the API level of the vendor surface.

Bug: 313822931
Test: check ninja commands to have -D__ANDROID_VENDOR_API__=<version>
Change-Id: Iceb5918cbfce0f24929d02d7e3caf1e9942b88e8
2023-11-30 05:26:12 +00:00
Ivan Lozano
829e1e9378 rust: Emit -x c++ for bindgen modules with cpp_std
rust_bindgen modules which defined cpp_std with a .h file were not
correctly emitting the `-x c++` flag. This CL addresses that, and
ensures that if either cpp_std or c_std is set then the appropriate
behavior occurs no matter the file extension.

Bug: 304269101
Test: Soong tests
Change-Id: I71a8ae30ac0ed502d9d3fbf2f3039b0c56529d39
2023-10-09 11:52:18 -04:00
Yi Kong
06521c4f46 Update rust bindgen to clang-r498229b
Bug: 293616148
Change-Id: I5102c5834a4f2f74242d57c9ec946d0b9381e893
Test: presubmit
2023-09-07 07:18:50 +00:00
Vinh Tran
4eeb2a9514 Remove dylibs prop from rust module types
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
2023-08-14 14:03:28 -04:00
Andrei Homescu
78a1f8dfb8 rust: Add Bindgen_flag_files property
Add a new Bindgen_flag_files property to bindgen modules
that let users specify files that contain extra flags for
bindgen.

Bug: 242243245
Test: presubmit
Change-Id: I21d987c08ac417c04aaa3bfb3b75d563fc662d5b
2023-07-27 07:03:14 +00:00
Yabin Cui
2850da608e Update rust bindgen to clang-r498229
Bug: 280683256
Test: presubmit
Change-Id: I30c57035eaba408cdbaa4f1151ea2605fdd9d32b
2023-07-18 13:41:21 -07:00
Andrei Homescu
4494685aec rust: Allow any host tool for custom_bindgen
Switch custom_bindgen to use any HostToolProvider
instead of just Rust modules, so any host binary can
be used as the bindgen wrapper.

Bug: 242243245
Test: presubmit
Change-Id: I9ba189b2857b3049dcf14842c178ce5846bab2f7
2023-07-07 04:59:07 +00:00
Yi Kong
6974c7ec72 Update clang version for Rust bindgen to clang-r487747c
Test: presubmit
Bug: 279955553
Change-Id: I9092263024b5b8dc7a1538b00f318ef0d5c29bb7
2023-05-12 15:06:20 +01:00
Yi Kong
fd07ed2c14 Revert^2 "Update clang version to clang-r487747"
9ede280375

Bug: 264965700
Change-Id: I4154c70c050a825525d5b591fa757104eb78c158
2023-03-23 14:14:31 +00:00
Dan Albert
30e66dcce5 Don't link bionicDeps for noStdlibs bindgen.
Bug: None
Test: treehugger
Change-Id: I213328f038061099d5c0dad0ef22cfd632ed268d
2023-02-23 19:17:50 +00:00
Yi Kong
bd1888156a Migrate to the new clang lib dir
Test: presubmit
Change-Id: I7ac7eb415a5f5c3d8b6d9298c1b4ccf2839aaea6
2023-02-08 19:54:05 +09:00
Yabin Cui
43d873625f Update bindgen clang version to r475365b
Bug: 253033919
Test: build
Change-Id: I2fd71206a540da7001956f1f6f5aae5d4f925920
2023-02-01 11:17:09 -08:00
Vinh Tran
f9754735f2 Delete __ANDROID_APEX_MIN_SDK_VERSION__ from Soong
Currently, Bazel sets __ANDROID_APEX_MIN_SDK_VERSION__ based on the cc library's min_sdk_version while Soong does based on apex's min_sdk_version. This causes a diff in the clang commands.

Digging further, we realized __ANDROID_APEX_MIN_SDK_VERSION__ isn't used anywhere so we might just delete it altogether instead of fixing it.

Bug: 265134933
Test: presubmit
Change-Id: I08e89dc8f6ef86669248ea5c47de6603e9d2ffbb
2023-01-20 00:14:48 -05:00
Colin Cross
645874d0cd Update musl bindgen clang lib directory
Musl libclang.so is in musl/lib, not musl/lib64.

Bug: 216192129
Test: m USE_HOST_MUSL=true host-native -k
Change-Id: Id12630d5c0f51d85278f8562b3d988458a56021a
2022-10-18 12:26:05 -07:00
Colin Cross
8a5a1e2074 Update bindgen clang version to r468909b
r468909b is the first version to contain musl libclang.so.

Bug: 216192129
Test: m checkbuild
Change-Id: If4c986e285914ca909981ea5dc972c3047c2ac7c
2022-10-18 12:25:05 -07:00
Matthew Maurer
e94f3e73dd Revert^4 "rust: Only allow bindgen to produce rlibs."
199c188502

Change-Id: I28b353fa89354cc572806b2274169342a473a03c
2022-08-10 20:25:50 +00:00
Matthew Maurer
199c188502 Revert^3 "rust: Only allow bindgen to produce rlibs."
9cc801ab7a

Change-Id: Ib59840b51b316c0ad03bc66565814dd96be0b072
2022-08-02 23:26:16 +00:00
Matthew Maurer
9cc801ab7a Revert^2 "rust: Only allow bindgen to produce rlibs."
b983c8971b

Change-Id: Ic82433885f7932be8cfe65433330527214807684
2022-08-02 16:57:30 +00:00
Matthew Maurer
b983c8971b Revert "rust: Only allow bindgen to produce rlibs."
This reverts commit 53a452d1ff.

Reason for revert: Broken build

Change-Id: I4c1c6f2166c3729ef1916ad7c21e32599c5e692f
2022-08-01 21:59:00 +00:00
Matthew Maurer
53a452d1ff rust: Only allow bindgen to produce rlibs.
Generated bindings are intended to be slim translation layers, usually
consisting of nothing more than type signatures and constants.
Generally, they should also be used in exactly one location by the safe
wrapper for these bindings. By preventing them from building as
`dylib`s, we avoid the per-library overhead of these non-reused pieces
of code.

Additionally, default visibility restrict all bindgen modules to their
subpackages. This is being done both:
* to encourage use of a single safe bindings crate
* to avoid diamond dependency graphs with mixed rlib/dylib dependencies

Bug: 166332519
Test: m; Make sample module use dylib bindgen dependency, see build failure.
Change-Id: I8e9d9cb851c2ec99f4ed63e6e18c4ba26b29721c
2022-08-01 16:28:51 +00:00
Yi Kong
4f664e9128 [bindgen] Allow unrecognised -Wno-* flags on LLVM_NEXT
Test: LLVM_NEXT=true m
Bug: 236798112
Change-Id: I5d1625a30d7271c94cba71347f17fbcb0b87f4ae
2022-07-14 12:38:06 +00:00
Colin Cross
567d342ed8 Use musl rust prebuilts for USE_HOST_MUSL=true
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
2022-07-01 02:58:14 +00:00
Yi Kong
4f6c92765d Update clang version to clang-r450784d
Test: presubmit
Bug: 219872355
Change-Id: If6c2c331044a363cb8f20a2516da894e72c4b7e7
2022-05-02 23:52:44 +08:00
Pirama Arumuga Nainar
f80a59fac9 [rust] Update clang version used to build bindgen
Bug: http://b/214080353

Use clang-r445002

Test: presubmit
Change-Id: I8b7d5b55757838c303e3695e398e84687804e948
2022-02-23 19:35:08 +00:00
Colin Cross
e32f093120 Support building rust modules against musl libc
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
2022-01-24 17:33:05 -08:00
Chih-Hung Hsieh
5140a042e1 Update clang version to clang-r437112b
Bug: 201432564
Test: make
Change-Id: I77bb074ed8dee7cad63d3b3765d9a2c3bc1b8aae
2022-01-05 16:44:51 -08:00
Chih-Hung Hsieh
253fd0609d Update clang version to clang-r437112
Bug: 201432564
Test: make
Change-Id: Idad9e1154b2c65eb29b7682c205f7bb50af17f0b
2021-12-07 15:24:38 -08:00
Ivan Lozano
e950cdad6d rust: Add missing variation -D flags to bindgen.
rust_bindgen calls are missing a large set of -D cflags which control
how headers are interpretted for certain variations (such as
-D__ANDROID_VNDK__). This CL introduces the full set of these flags.

Bug: 205609024
Test: rust_bindgen vendor variant builds correctly.

Change-Id: Id781c1f88352e9c238c49619f0dce20f804cfc77
2021-11-10 13:28:55 -05: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
Yabin Cui
1424ea499d Update clang version used for bindgen
Bug: 190099451
Test: none
Change-Id: Ie0480288bb1be2e7d55d8dd01b8d006410bfc7a0
2021-08-10 15:13:01 -07:00
Colin Cross
0523ba2675 Rename ninja variables with Clang in the name
Rename the ninja variables that have an extraneous Clang in the name,
since there are no longer any non-Clang variables.

Bug: 68947919
Test: no change to command lines used to build mmma bionic
Change-Id: I081d5e1d423a66d55faece6cb1d265cd5e504d5f
2021-07-14 20:55:23 -07:00
Colin Cross
33bac24bb9 Remove clang indirection without affecting build.ninja
Remove cflags that are not handled by clang from the global defaults,
and remove calls to ClangFilterUnknownCflags.

Squash lists of clang-specific default flags into the main default
flags lists.

Rename Toolchain.Clang*flags to Toolchain.*flags.

Rename Go variables with Clang in the name that have no non-Clang
equivalent.

Remove unused ninja variables.

Bug: 68947919
Test: no change to build.ninja for aosp_cf_x86_64_phone-userdebug or aosp_crosshatch-userdebug
Change-Id: Id287945315d53e5eaef197adbbb4f1302f2e3680
2021-07-14 20:54:22 -07:00
Ivan Lozano
e934263d18 Merge "rust: Pass additional Clang C flags from toolchain" 2021-04-23 18:13:10 +00:00
Ivan Lozano
871e34290e rust: Pass additional Clang C flags from toolchain
The set of Clang flags passed to bindgen from the toolchain was
incomplete. In addition to ToolchainClangCflags(), we also need to call
ClangCflags().

Bug: 184081465
Test: m libgrpc_bindgen
Change-Id: I0b62345fee2f55ba18b4a0c4d825f0447c99db06
2021-04-23 10:25:35 -04:00
Treehugger Robot
f9b3e22293 Merge "Remove unnecessary android:"path" tags in rust" 2021-04-21 15:53:44 +00:00
Liz Kammer
eda9398bbf Remove unnecessary android:"path" tags in rust
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
2021-04-20 16:06:02 +00:00
Pirama Arumuga Nainar
655a7d50f4 [rust] Update clang version used for bindgen
Bug: http://b/185528062

Test: presubmit
Change-Id: I0060643b0dec998d1d4f8da2c504c79223995f98
2021-04-19 10:10:21 -07:00
Thiébaud Weksteen
f1ff54a10b rust: Drop libgcc dependency
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
2021-03-23 13:55:40 +01:00
Pirama Arumuga Nainar
7b33d41170 Update clang used for bindgen to clang-r412851
Test: presubmit
Change-Id: I4883bd3c26a4037d01829c0806fc908b2c8e1c37
2021-03-17 10:37:51 -07:00
Peter Collingbourne
9a868f1238 Allow the clang version used for bindgen to be configured.
This is useful when experimenting with new compiler flags that the
existing compiler does not support.

Change-Id: I45b8a2980b247d60a7f4e2ba55169267aeceef2b
2020-12-30 21:18:54 -08:00