Commit graph

102 commits

Author SHA1 Message Date
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
4aeaf37bb7 Merge changes from topic "mixed-build-cc-library-shared"
* changes:
  Expose TocFile via CcInfo
  Clean up StarlarkFunctionBody for getCcInfoType
  Incorporate cc_library_shared into mixed builds
2021-09-17 14:29:17 +00:00
Jingwen Chen
16d90a8954 Remove __bp2build__ prefix trimming.
This is no longer needed after r.android.com/1792714

Test: CI
Change-Id: I808c3124cf1a4f3ebe5d25e41f346a818c3cc57c
2021-09-17 07:16:59 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
62585e8436 Expose TocFile via CcInfo
To reflect what's provided in SharedLibraryInfoProvider

Move the logic for identifying the toc file into Starlark
instead of the Soong Go code.

Adapt TestGetCcInfoParseResults to expect the toc as well.

Test: build/bazel/cquery/request_type_test.go:TestGetCcInfoParseResults
Test: cc/library_test.go:TestCcLibrarySharedWithBazel
Test: build/bazel/ci/mixed_{libc,droid}.sh
Change-Id: I40ad47158cb98b14ca03c21e351988818cb01770
2021-09-16 20:55:10 +00:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
4fbc62196d Clean up StarlarkFunctionBody for getCcInfoType
Instead of repeating, pull repetition into vars

Test: build/bazel/ci/mixed_{libc,droid}.sh
Change-Id: If3c8387ac0aeb6364e7e4bc58a4e3a39c3c708d5
2021-09-16 20:54:57 +00:00
Liz Kammer
5fad501aeb bp2build: Split export_{includes,system_includes}
The specification of exporting includes vs system includes has an impact
on inclusion sort order. Conflating the two caused some symbols to not
be resolved correctly.

Bug: 198403271
Test: build/bazel/ci/bp2build.sh
Test: USE_BAZEL_ANALYSIS=1 m libbacktrace_no_dex succeeds with libc++_*
      modules removed from mixed build denylist (would fail otherwise)
Change-Id: I08aff253d8962dc678ed10214b1c171330e0fe19
2021-09-09 15:59:05 -04:00
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
a05a255eac Add infrastructure to support PythonBinary
Add a new request type with its own StarLark function
Hook it up via GetPythonBinary
Add to MockBazelContext a LabelToPythonBinary
Add a test for the new request type

Test: request_type_test.go:TestGetPythonBinaryParseResults
Change-Id: I05f6506adfbbdac8b3f40475509ed02ab8e844e5
2021-08-12 18:48:15 +00:00
Chris Parsons
51f8c39261 bp2build: handle system_shared_libs
- If no system_shared_libs is specified, bp2build writes no attribute
value. In this case, the bazel library macros determine the correct
default behavior.
- If any system_shared_libs is specified for any variant, then bp2build
writes the value verbatim. This includes if an empty list is specified,
as this should override defaulting behavior.

Note this defaulting behavior is incomplete and will be incorrect in
corner cases. For example, if, in an Android.bp, system_shared_libs is
specified for os.linux_bionic but not for os.android, then the bazel
default for os.android will be incorrect. However, there are no current
modules in AOSP which fit this case.

As a related fix, supports static struct for cc_library_static.

Also, removes some elements from the bp2build denylist.

Test: mixed_droid CI
Change-Id: Iee5feeaaf05e8e7209c7a90c913173832ad7bf91
2021-08-09 11:41:09 -04:00
Colin Cross
528d67e523 Reland "Split the x86 host toolchain into glibc and musl variants"
Split the x86 host toolchain into glibc and musl variants

Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

This relands Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546 with changes
for I46672e3a096b6ea94ff4c10e1c31e8fd010a163c.

Bug: 190084016
Change-Id: Iaa9f7a50ff601155ecd73acc5701a2c226be66dc
Test: TestArchMutator
2021-07-23 22:25:36 +00:00
Colin Cross
5d6904e1cf Revert "Split the x86 host toolchain into glibc and musl variants"
This reverts commit 4fb4ef2242.

Reason for revert: crossed with aosp/1775072

Change-Id: Ied922850b810d82627ba4f9ee42f672cfe286c91
2021-07-23 22:20:29 +00:00
Colin Cross
4fb4ef2242 Split the x86 host toolchain into glibc and musl variants
Create new musl toolchains that are based on the existing glibc
toolchains, and add the necessary flags for musl compiles.

Bug: 190084016
Test: TestArchMutator
Change-Id: Ifc02f9e5afa61ff758be98b0c962f3a4b53d0546
2021-07-23 08:57:17 -07:00
Colin Cross
cb0ac95bde Remove Fuchsia support from Soong
Bug: 194215932
Test: m checkbuild
Change-Id: Id7d3964d9417f8b0938af9b168bb4c00cebe9390
2021-07-21 20:37:46 -07:00
Liz Kammer
01a16e8275 Handle target.bionic in bp2build.
Soong supports some hand-crafted target.<type> that match multiple os or
arch types to simplify configuring for similar targets. target.bionic is
used to match on both android and linux_bionic OSes for cases where they
should be handled the same way.

Test: build/bazel/ci/bp2build.sh
Change-Id: I47b6aaf3279e4d242c4fd0e12f24117eb98e0665
2021-07-19 12:53:58 +00:00
Chris Parsons
69fa9f9e5e Seperate asflags and cflags
This fixes a bug which was a misunderstanding of soong properties:
Soong's cflags pertain only to C and C++ language, whereas bazel's copts
pertain to all three languages. This change ensures that asflags are
added as specifically asflags, and the 'copts' for the static library
macro pertains only to C and C++ languages.

This requires a somewhat hacky workaround for asflags, however: Since
assembly sources also need includepath-related flags, this duplicates
these flags between copts and asflags. To reduce verbosity of
bp2build-generated targets, this also ensures that asflags are omitted
in cases where there are no assembly sources.

Test: Mixed build droid CI
Change-Id: Ic0babed1f90d6dc82e5788638681ce5b995043f8
2021-07-13 14:06:14 -04:00
Jingwen Chen
c63677b3c9 Direct Bazel builds from m.
This CL adds support to bp2build/Soong to dump a BUILD file under
out/soong/soong_injection/targets containing alias targets to their real
targets for every converted Soong module, regardless of whether they are
handcrafted or generated.

Test: TH
Change-Id: Ic1816fda5d019c395301618134fac68b3057d752
2021-06-21 06:12:34 +00:00
Chris Parsons
94a0bba5a9 Support cc_library_shared for mixed builds
Authors: cparsons, eakammer, jingwen

This CL also contains .toc file integration between Bazel and Make.

Fixes: b/190524879

Test: build/bazel/ci/mixed_droid.sh

Co-authored-by: Christopher Parsons <cparsons@google.com>
Co-authored-by: Liz Kammer <eakammer@google.com>
Co-authored-by: Jingwen Chen <jingwen@google.com>

Change-Id: If484042a58cb9f0db6d30a460f415f5684b4cbf6
2021-06-15 12:40:28 +00:00
Liz Kammer
c49e682f37 Handle simple symlinks in mixed builds
Bug: 180945121
Test: build/bazel/ci/mixed_libc.sh
Change-Id: I49fba569a41dcb8cd4c2e58560817443697f58f1
2021-06-09 10:40:32 -04:00
Liz Kammer
d366c909ca Handle no_libcrt in bp2build.
Test: ci/bp2build.sh
Bug: 187928307
Change-Id: Ib80c4318169652b322e5d878c8784679e42f87dd
2021-06-08 17:18:22 -04:00
Liz Kammer
2f26595072 Merge changes I4a5ea40c,I40ab16e3
* changes:
  Handle excludes_{shared,static}_libs
  Extract function to handle configurable excludes
2021-06-07 16:42:38 +00:00
Christopher Parsons
fa4ab8a7f4 Merge "Support mixedbuilds for static variant cc_library" 2021-06-04 15:09:21 +00:00
Liz Kammer
74deed445b Extract function to handle configurable excludes
This allows it to be used for other modules types and other properties
(e.g. static_libs & exclude_static_libs).

Test: go test soong tests
Bug: 188497994
Change-Id: I40ab16e3b540ece0a6684558b32f7e8e25df6f24
2021-06-04 10:15:34 -04:00
Liz Kammer
9abd62d133 Use maps in bazel *attribute types
This is to simplify the process of resolving label + exclude labels
across the various configuration axes we have and across the various
properties/modules that use this behavior.

Test: ci/bp2build.sh && ci/mixed_droid.sh
Change-Id: I8efae3e75ddb365384f5caaf5bb504a5206618d3
2021-06-03 17:37:56 -04:00
Chris Parsons
bcc9b88d49 Support mixedbuilds for static variant cc_library
Test: mixed_droid CI
Change-Id: I3126b528b375462d78e8146b5432d1e5cec20829
2021-06-03 16:52:46 -04:00
Jingwen Chen
14a8bda31e bp2build: split as, c, and cpp srcs for cc_library
This CL adds support for cc_library to correctly split c, as and cpp
srcs in shared/static nested props, as well as splitting
the *filegroup* deps in those props, where each filegroup is expanded
into its own c, cpp and as srcs filegroups. This ensures that the
correct sources go into cc_library_static's underlying cc_libraries for
c, cpp and as sources respectively.

See the bp2build conversion test for a better visualization.

Bug: 183064430

Test: TH
Change-Id: I29add5140672d042adff65527d8b65f4a5f0a05b
2021-06-03 05:00:37 +00:00
Treehugger Robot
72aedde483 Merge "Handle product vars *flags props in cc* modules" 2021-05-31 08:21:19 +00:00
Liz Kammer
ba7a9c5e4a Handle product vars *flags props in cc* modules
Test: build/bazel/ci/bp2build.sh
Bug: 188497994
Change-Id: Ifb379e370075d6a7bc55b82d79c210c31ef377e9
2021-05-27 13:57:01 -04:00
Rupert Shuttleworth
ffd4582b86 Add cc_prebuilt_library helpers for use by the llvm_prebuilt_library_static converter.
Test: bazel build //prebuilts/clang/host/linux-x86:prebuilt_libFuzzer
Test: bazel build //prebuilts/clang/host/linux-x86:prebuilt_libomp
Test: bazel build //prebuilts/clang/host/linux-x86:prebuilt_libunwind
Test: bazel build //prebuilts/clang/host/linux-x86:prebuilt_libunwind-exported

Change-Id: I9343e19a149b62785e8ee3096254776c19675032
2021-05-27 09:07:57 -04:00
Liz Kammer
f6840284b6 Merge "Support empty srcs for configurable attrs" 2021-05-27 12:56:29 +00:00
Rupert Shuttleworth
69e7231677 Merge "Remove unused Common field." 2021-05-27 12:13:31 +00:00
Rupert Shuttleworth
9d63de8c6e Remove unused Common field.
Test: TH
Change-Id: I8364dc70bde4ba02925dc713ca9f2a17fa3da083
2021-05-27 04:48:47 -04:00
Rupert Shuttleworth
22cd2eb3d1 Add e.g. Target: { Android_arm: { ...} } support to LabelAttribute.
LabelListAttribute support was already added, but LabelAttribute support is needed for cc_import rules.

Test: Added unit test for version_script, which is the only supported LabelAttribute so far.

Change-Id: I4e86e7391586e0780623d06b794e7399f0ccd50e
2021-05-27 04:32:48 -04:00
Liz Kammer
2b07ec7b3b Support empty srcs for configurable attrs
Test: mixed build linkerconfig
Change-Id: I1ee56f7fa46ce2971ecae6d2ca9258631a32f46a
2021-05-26 16:58:54 -04:00
Rupert Shuttleworth
c194ffbcf3 Make GetTargetProperties() aware of more complex targets, like 'android_arm', instead of just 'android'.
Test: Added new unit test and updated existing tests.

Test: bazel build //bionic/... //external/... //frameworks/... //system/...

Test: ./build/bazel/scripts/run_presubmits.sh

Change-Id: I250d1964f5cf42b92ddb929379d35d8c844423f7
2021-05-25 19:40:16 -04:00
Chris Parsons
990c4f4fc3 Rollforward "Split asm and c flags and srcs in..."
This fixes a test and rolls forward I28cf7437ee96cdf2fdbcb1eda2303691cff08ba4

Test: m nothing
Test: See I28cf7437ee96cdf2fdbcb1eda2303691cff08ba4
Change-Id: I0e450c28e70087e406e7b562d7e772785f177379
2021-05-25 12:15:52 -04:00
Colin Cross
4f9d8d6482 Merge "Revert "Split asm and c flags and srcs in bp2build output"" 2021-05-25 15:21:36 +00:00
Colin Cross
52aa4e1fd4 Revert "Split asm and c flags and srcs in bp2build output"
Revert submission 1714835-roboleaf-asm-c

Reason for revert: TestCcLibraryStaticProductVariableSelects fails everywhere
Reverted Changes:
I28cf7437e:Split asm and c flags and srcs in bp2build output
I2b47e6b55:Split libraries by language in cc_library_static

Change-Id: I85d39a462f0a5b3f5ff3d685906813fab9f01358
2021-05-25 15:20:39 +00:00
Christopher Parsons
ed73b76513 Merge "Split asm and c flags and srcs in bp2build output" 2021-05-25 14:58:32 +00:00
Chris Parsons
af24cdd99f Split asm and c flags and srcs in bp2build output
This allows removal of almost all current items from the mixed build
denylist, which were previously broken due to being unable to separately
control flags for compilations of different languages within the same
target.

Note that this does not appropriately implement asm/c srcs and flags for
either the shared variant or the static variant. This will require a
followup.

Test: bp2build.sh and mixed_libc.sh CI scripts
Test: Updated b2build tests

Change-Id: I28cf7437ee96cdf2fdbcb1eda2303691cff08ba4
2021-05-24 21:49:14 -04:00
Liz Kammer
e3e4a5f2d8 Handle arch/os-specific product variables
Bug: 183595873
Test: go test bp2build tests
Change-Id: I36e93ae1eb2943555dd304d5bdf62d995e77b437
2021-05-24 14:32:38 -04:00
Liz Kammer
6fd7b3fee9 Handle product config vars in bp2build.
Test: bp2build ci  & mixed build libc
Bug: 183595873
Change-Id: I2d87434ff4df5a24efc5e3e38f087de035228934
2021-05-24 14:22:31 -04:00
Liz Kammer
50d601731b Merge "Dump bazel product config in Soong" 2021-05-20 14:09:18 +00:00
Liz Kammer
09f947d67e Dump bazel product config in Soong
Bug: 187862880
Test: build/bazel/ci/bp2build.sh
Test: build/soong/tests/bp2build_bazel_test.sh
Change-Id: I24b09baad973e25bec4476e1ea4a7692b72b7d20
2021-05-19 17:38:56 -04:00
Chris Parsons
c4fb133380 Support middleman actions in mixed builds
This allows support of generated hdrs / srcs in mixed builds.

Test: Manually verified that libc_bionic_ndk passes compilation (failed
previously due to missing generated heaer)
Test: bp2build and mixed_libc CI scripts
Test: New aquery test

Change-Id: I88e359a4bd9eba383c207d5cf812272725ff0a3d
2021-05-18 14:07:44 -04:00
Chris Parsons
484e50aa7c bp2build: support generated sources and hdrs
There are two pieces to make this work:
1. Local include paths must include $(BINDIR)-relative paths, to support
generated headers in those directories.
2. The srcs that bp2build outputs for BUILD targets must include labels
for targets given in generated_hdrs and generated_srcs.

Support for exported_generated_hdrs intentionally deferred.

This allows us to remove several targets from the bp2build denylist.
Some are moved to the mixed build denylist, because genreated headers are
still unsupported in mixed builds.
Test: bp2build.sh CI script

Change-Id: Ib4f9dac20f6445487b8dad53b91eac01f437a590
2021-05-17 14:30:07 -04:00
Lukacs T. Berki
598dd00236 Refactor how bp2build gets arch-specific props.
Then plumb them to LabelAttribute.

This refactoring is required because the previous implementation did not
handle properties in shards other than the first one (e.g.
version_script) well. In addition, it also makes the code paths between
bp2build and analysis more similar.

Bug: 186650430
Test: Presubmits.
Change-Id: Ic4393e8ae47f4e88816bf45c89399efd61494d22
2021-05-05 09:00:01 +02:00
Lukacs T. Berki
1353e59690 Handle the version_script property.
Doesn't work when depends on arch/target/etc., but good enough for
libdl_android.

Bug: 186650430
Test: Presubmits.
Change-Id: Ib0facb41a89454717c74663e5e078aedd33d1b9c
2021-04-30 16:46:41 +02:00
Jingwen Chen
e32e9e07d7 bp2build: arch-specific exclude_srcs and srcs.
OS-specific exclude_srcs and srcs will be done in a follow-up, due to
complexities from merging multiple select statements together.

Test: TH
Bug: 186153868
Change-Id: I01b881e9a5a7cd41b4a507f8be7e9e65eab37bdc
2021-04-27 11:02:07 +00:00
Jingwen Chen
882bcc1c1c bp2build: remove header globs in generated srcs.
Not needed anymore for bp2build-incremental since https://android-review.googlesource.com/q/topic:no-include-check.

Not needed for mixed builds either, since cc compile actions aren't sandboxed.

Fixes: 186488830
Test: treehugger and go tests

Change-Id: Ib5d4908dcce6bf910a653c457bb251d726e717d4
2021-04-27 06:26:40 +00:00
Liz Kammer
b6a55bf065 Incorporate cc_library_headers into mixed builds
Test: go soong tests
Test: bp2build generate & sync; mixed build libc; mixed build su (su is
      an Android.mk target that relies on converted a cc_library_headers)
Bug: 181552740
Change-Id: I9efd587970551fd41f642a208f0aa0a80e8694e0
2021-04-23 09:37:33 -04:00
Jingwen Chen
ed9c17d033 bp2build: refactor/standardize cc_* bp2build converters
This CL refactors the cc* bp2build converters to use the common
attribute extractors in cc/bp2build.go.

This also adds include_build_directory to be handled by the compiler
attr extractor to generate recursive headers as inputs.

This also turns include_dirs and local_include_dirs into the
execroot-relative -I flags.

e.g. if a module in  bionic/libc has "private" in local_include_dirs,
the "-Ibionic/libc/private" copt is generated for it.

Fixes: 185139955

Test: TH
Test: Forrest for mixed_clean-droid
Change-Id: Ib67056482227e62068fbbea0455035bdf5d56319
2021-04-22 08:31:24 +00:00
Rupert Shuttleworth
b7e30760af Add various test files as testSrcs, so that they run on CI.
Test: go test
Test: TH (now that these are hooked up to TH)

Change-Id: Ia199794ef1a64074f3f9159f8c160ba3e45fd181
2021-04-21 11:23:57 -04:00