Commit graph

30 commits

Author SHA1 Message Date
Kalesh Singh
f4ffe0a026 soong: Add crt_pad_segment to .so's
crt_pad_segment adds a NOTE to the ELF which is used by the binoic
loader to determine whether it should pad segments when mapping them
into the virtual address space, such that there are no gaps between
mappings of consecutive segments. This avoids an increase in
unreclaimable kernel slab memory usage for VMAs on devices where the
runtime-page-size > elf-segment-p_align.

Since -fandroid-pad-segment [1] respects -nostdlib used in android
platform builds, soong must link in crt_pad_segment to platform shared
libraries.

For simplicity, link crt_pad_segment everywhere that crtend_so is
applicable, ignoring nocrt property, as there is no other reason
to track these separately.

Example:

❯ readelf -WS /system/lib64/libc++.so [Output simplified]

...
Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
...
  [ 2] .note.android.pad_segment NOTE            0000000000000288 000288 000018 00   A  0   0  4
...

[1] https://github.com/llvm/llvm-project/pull/77244

Bug: 316403210
Test: readelf -WS <lib>.so
Change-Id: Icc06611376cfd5ee4de7281b4134f9f8ffe7ca60
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-01-31 19:42:31 -08:00
Colin Cross
f61d03d241 Add TestContext parameter to ContentFromFileRuleForTests
The next CL will need a TestContext parameter in
ContentFromFileRuleForTests in order to retrieve the file rule contents
from the Config.  Add it and update all the tests that use it in order
to simply review of the next CL.

Bug: 306029038
Test: go test ./...
Change-Id: Ia4b4c9854017ea3472fa2f8ba42cf7f72720496e
2023-12-03 17:22:56 -08:00
Justin Yun
3cc7846b58 APEX can use any Prebuilt libraries
Vendor snapshot libraries generated from prebuilt libraries set
"apex_inherit" to their min_sdk_version property to allow them to be
used by vendor APEXes.

Bug: 277403349
Test: m vendor-snapshot
Change-Id: Idd9e5f8e94b3fa2adf47a04507bf0c50c59edfb7
2023-05-08 22:33:35 +09:00
Justin Yun
17d0ee2160 VSDK: use relative install path when generating snapshots
Without respecting the relative install path, the snapshot install
path may collide when they use the same stem name.
To avoid this, respect the relative install path when generating the
snapshots.

Bug: 279652606
Test: RECOVERY_SNAPSHOT_VERSION=current m recovery-snapshot
Change-Id: Ic70a5855aeb2a6eda397b4dd06113dddb6ef70f4
2023-05-02 16:29:06 +09:00
Justin Yun
08270c6c2d Disable sanitizer for vendor_snapshot_object modules
vendor_snapshot_object modules do not provide sanitizers.
Avoid sanitizer mutation for these modules.

Bug: 234772527
Test: build against the vsdk with SANITIZE_TARGET=hwaddress
Change-Id: Ib4fe4def673aa77a4321f47c09393adcb2fa2964
2022-12-19 23:04:08 +09:00
Justin Yun
39c303116a Allow hwasan variant for vendor_snapshot_static modules
vendor_snapshot_static modules can define hwasan variant as below:

vendor_snapshot_static {
    name: "libsnapshot",
    vendor: true,
    version: "33",
    arch: {
        arm64: {
            src: "libsnapshot.a",
            hwasan: {
                src: "libsnapshot.hwasan.a",
            },
        },
    },
}

Bug: 234772527
Test: m nothing
Change-Id: I0725028a4fdc302005d86f1e36561b98c0af623b
2022-11-24 17:51:08 +09:00
Inseob Kim
a1888ce78d Add overrides support for snapshots
Overrides properties will now be captured in json flag files, which will
be copied to installed vendor snapshot modules.

Bug: 216567575
Test: soong test && manual install
Change-Id: Ife5e84b126e798fba7802b9cff000c9197756cb9
2022-10-04 14:42:02 +09:00
Inseob Kim
4d945ee719 Fix snapshot symlinks
LOCAL_MODULE_SYMLINKS was enough to install symlinks for snapshot
binaries. However, Soong now requires LOCAL_SOONG_INSTALLED_SYMLINKS,
which results in broken symlink support in snapshots.

This fixes symlink problems, and then amends the Soong snapshot test.

Bug: 220639435
Bug: 220907049
Test: manually add symlinks and try building
Test: Soong test
Change-Id: Ia75ddf3aa642558e396f1d80736310c3c8d02ad1
2022-02-24 10:29:18 +09:00
Liz Kammer
718eb27f5b Delete toolchain_library
Test: m && ci
Change-Id: Iab5267e02e3559431d980c70a58b49c2b8b4e6de
2022-01-14 12:52:59 -05:00
Ivan Lozano
c2ca1ee83d rust: Add Recovery Snapshot Soong tests for rust.
Bug: 197866992
Test: m nothing
Change-Id: I4b5401cf2ffa0dbcc6fea60f90bad4c47a9d5e6b
2021-11-15 17:11:20 -05:00
Justin Yun
27b9572433 Rewrite snapshot dependencies for vndk-ext
VNDK-ext libraries have dependency on VNDK libraries. When building
against snapshots, the dependency must be rewritten with the
snapshots.

Bug: 194864314
Test: m nothing
Change-Id: I1244c6a6590e89b344ab39514bb5142d36b04268
2021-07-30 10:49:02 +00:00
Ivan Lozano
d67a6b0a88 Export cc vendor functions for usage by rust.
This CL exports and refactors some cc vendor-snapshot related functions
so they can be reused by rust modules to support vendor snapshotting.

Bug: 184042776
Test: m nothing
Change-Id: I12706e62ce0ac3b2b4298085fafc1d77b8e0a0c4
2021-06-03 08:31:55 -04:00
Justin Yun
dee806fd09 VNDK snapshot may provide LLNDK stub libraries
VNDK snapshots newer than v30 have LLNDK stub libraries. In that
case, the vendor variant for the BOARD_VNDK_VERSION must not be
generated from the LLNDK modules. They are already provided by the
VNDK snapshots.
Generate the vendor variant of the BOARD_VNDK_VERSION only if
BOARD_VNDK_VERSION has an integer value less than or equal to 30.

Bug: 187963715
Bug: 181815415
Test: m nothing
Change-Id: I31e90f4d7e7678c45558f6bf987f5582a4c34f78
2021-05-20 21:05:19 +09:00
Colin Cross
203b421043 Remove obsolete llndk_library
Remove llndk_library in favor of cc_library with llndk.symbol_file.

Bug: 170784825
Test: m checkbuild
Test: TestLlndkLibrary
Change-Id: I43580976589a7a2a176d7442be53fa043c0c8324
2021-04-26 18:41:00 -07:00
Inseob Kim
dd0295d774 Support reexporting vndk from vendor snapshot
Bug: 184795475
Test: soong test
Change-Id: I0146de55e2ef54c1c8abd42f0f4d8b4db7444350
2021-04-13 10:16:49 +09:00
Inseob Kim
f7aadf70d8 Add flag test for cfi snapshot
Test: soong test
Change-Id: I651120b11f5b80c4b5f04172170afc533f24c54d
2021-04-13 10:15:31 +09:00
Inseob Kim
d4c9f55468 Use old unwinder for R cc modules
Modules linking against VNDK R have been using libgcc_stripped and
libunwind_llvm as their unwinder. This change uses those old unwinder
libraries if current module's VNDK version is R.

Bug: 178470649
Test: soong test
Change-Id: I86d0600b2fb09cd9828c0a5b1157558711b0ec86
2021-04-08 19:28:28 +09:00
Inseob Kim
253f521dbc Redirect memtag libraries to snapshot
memtag sanitizer libraries are vendor available and can be captured as
snapshots. This change adds a redirection logic for memtag libraries.

This is just a workaround, just like other SnapshotInfoProvider calls.
In the future we need to refactor these codes. So TODO is added to
remind refactoring.

Bug: 178470649
Test: soong test
Change-Id: Id77f1ce94255b56a68f3e1d7446a68189c45ac54
2021-04-08 17:10:31 +09:00
Jose Galmes
f9523ed579 Fix arch in snapshot DepsMutator.
Suffixes attached to snapshot modules are based on the main architecture
(e.g. "arm64" for aosp_cf_x86_64_phone-userdebug), not the architecture
of arch variants.

Bug: 184588077
Bug: 184695066
Test: Run unit tests using:
Test: source build/envsetup.sh
Test: m -j nothing
Change-Id: Id8d002d45864a6fb12d642b60011e7a9eaf29e07
2021-04-07 11:45:25 +00:00
Inseob Kim
1b6fb87654 Automatically set Androidmk suffix of snapshot
Androidmk_suffix has been captured with "m vendor-snapshot". But the
suffix is to avoid collision with core variants, so the suffix should be
based on the existence of core variants. This change sets the suffix by
using OtherModuleDependencyVariantExists. This way we can also avoid
mutators and global states.

Bug: 179665538
Test: m nothing (soong test)
Change-Id: I35343aa2c4c07782057b82e6dd0e705a786e55fc
2021-04-07 17:24:08 +09:00
Jiyong Park
f58c46e36f Don't use incorrect version names like VER or BOARD even in tests
All version names will go through ApiLevelFromUser which triggers an
error when the name is not a valid one.

Bug: 175678607
Test: m
Change-Id: Id33bf64085603914d45ad7942cb8908a4734493f
2021-04-05 09:32:06 +09:00
Paul Duffin
c3e6ce04d9 Remove buildDir from cc package
Bug: 182885307
Test: m nothing
Change-Id: I964af3cb9a3e7a1dfbd9d5176a702591f6b19f16
2021-03-30 23:44:43 +01:00
Justin Yun
07b9f86f0c Define getSnapshotNameSuffix()
By sharing a single function for generating snapshot name suffix,
make sure both the DepsMutator and the snapshot modules use the same
names.

Bug: 179666286
Test: m nothing
Change-Id: I9efa94f2981a6bd1b4128bf0e84ca44873ebf3b7
2021-02-26 14:00:03 +09:00
Justin Yun
4813867ec3 Remove dependency from vendor_snapshot to each module
The 'vendor_snapshot' module is required to every cc_library to check
if the dependencies need to be rewritten to the snapshot modules or
not. However, as the 'vendor_snapshot' module has dependencies to the
snapshot modules, the dependency to the 'vendor_snapshot' module
creates circular dependencies.
The dependency from the 'vendor_snapshot' to the snapshot modules is
required only to read the module names of the snapshot modules. We
may remove the dependency by setting the name of the snapshot modules
directly.

Bug: 179666286
Test: m nothing
Change-Id: I14abcb06c5c81ef7f8535103578747385c89ae0f
2021-02-25 09:31:12 +00:00
Jose Galmes
4c6895e5a3 Implement directed recovery snapshot.
Bug: 177451657
Test: m -j nothing
Change-Id: I0b84c34fb2e9e9340d9f9e7405428cd2cc4d43b5
2021-02-09 08:25:34 -08:00
Jose Galmes
0a942a0368 Generate fake versions of modules excluded in directed vendor snapshot.
When using the directed vendor snapshot, the build fails because soong
fails to find some variants of the modules that have been excluded
from VENDOR_SNAPSHOT_MODULES, even though those modules are not going
to be used by the build.

The solution implemented here is to generate fake versions of those
modules (empty files) and include them in the generated Android.bp,
so that soong finds the modules, even though trying to use them would
fail.

Bug: 171821997
Bug: 179275601

Test: source build/envsetup.sh
Test: m -j nothing

Change-Id: Ibd3e963ab3e5504c0ac817f7cabbd241bf47a5cb
2021-02-05 17:53:53 +00:00
Colin Cross
a889080aba Remove global state on module suffixes from vendor and recovery snapshots
Propgate the Android.mk suffix from source modules into the snapshot so
that it can be used for the prebuilt modules.

Bug: 177098205
Test: vendor_snapshot_test.go
Change-Id: Iea151dc91395f714fbcad1df3a6fd0874e5455d9
2021-02-01 20:06:29 +09:00
Colin Cross
e0edaf9d49 Remove some global state from vendor and recovery snapshots
Snapshots storead global sets of modules that should be replaced with
vendor snapshot modules.  Move the data instead to a vendor_snapshot
or recovery_snapshot module type that depends on all the modules in
the snapshot, and then have modules that should use the snaphsot
depend on it to query for the set of modules that should be replaced.

Bug: 177098205
Test: vendor_snapshot_test.go
Change-Id: I2826adacfb473e9139b5ea93ba83b8a54cc1a56b
2021-02-01 20:02:39 +09:00
Colin Cross
2e577f3657 Add vendor_available coverage to TestVendorSnapshotUse
Test that the correct suffix is added to the Make references to a
vendor_available library in a vendor snapshot.

Bug: 177098205
Test: vendor_snapshot_test.go
Change-Id: I0c9b81d63798e221db856fa0e4742a467c356fcb
2021-01-22 17:42:31 -08:00
Colin Cross
0fce0bab12 Move vendor snapshot tests into vendor_snapshot_test.go
Move the vendor snapshot tests into vendor_snapshot_test.go to
reduce the size of cc_test.go

Bug: 177098205
Test: go test ./build/soong/cc/...
Change-Id: Ib1120f986fc0111a9487fce00539a4c5ae7e2e87
2021-01-22 17:42:28 -08:00