Commit Graph

1391 Commits

Author SHA1 Message Date
Yabin Cui
7d47151afb Merge "Update clang-tools build to clang-r475365b" 2023-01-19 20:42:44 +00:00
Yabin Cui
deddd88b27 Update clang-tools build to clang-r475365b
Also remove -std=c++14 flag. Because clang 16 uses c++17
by default. And some headers don't compile with c++14.

Bug: 253033919
Test: run build-prebuilts.sh
Change-Id: Ia76c227831ed62a9de190fb1d816f23d7c92fad2
2023-01-18 10:27:50 -08:00
Hsin-Yi Chen
3a51bf53f1 Add a field for arrays of unknown bound
The ABI tools do not diff the array length. They cannot distinguish
between arrays of unknown bound (e.g., int foo[]) and arrays of zero
length (e.g., int bar[0]). To implement array diff, this commit adds
"is_of_unknown_bound" field to the ABI dumps. It defaults to false so
that it can be omitted for common cases.

Test: ./test.py ; update prebuilts/clang-tools and build
Bug: 255702405
Change-Id: I5db163eb62e95fa01377ef7202e70cc2a0e89524
2023-01-16 17:36:38 +08:00
Hsin-Yi Chen
e07e343451 Merge "Fix the bug that generates multiple definition of references" 2023-01-10 03:08:11 +00:00
Hsin-Yi Chen
6e5894f6a2 Fix the bug that generates multiple definition of references
If a type ID is persent in local_to_global_type_id_map,
ModuleMerger functions should report that was_newly_added_ = false.

Test: ./test.py ; update prebuilts/clang-tools and build
Bug: 255702405
Change-Id: I0fbe68ebbc6b8df3ea4ae36a017d0bb61bc7d553
2023-01-07 16:24:43 +08:00
Hsin-Yi Chen
a062a6cf35 Determine struct extensions before calling IRDiffDumper
This commit moves the functions that determine struct extensions from
ir_diff_representation.cpp to abi_diff_helpers.cpp. The functions
are called before IRDiffDumper so that the IR and the dumper do not
include the diff logic.

Test: ./test.py
Bug: 259148872
Change-Id: I93aaa3028bf6a30312f0b0e5b1ef5f6ae1041f21
2022-12-30 16:33:48 +08:00
Hsin-Yi Chen
82b8191b50 Merge "Allow extending qualifiers of function parameters and return values" 2022-12-28 09:31:24 +00:00
Hsin-Yi Chen
e77c10f563 Allow extending qualifiers of function parameters and return values
`header-abi-diff --allow-extensions` allows function parameters to be
more qualified, and return types to be less qualified. The ABI tools
follows the qualifier conversion rules in C++.

The ABI tool only allows extending the qualifiers of the functions that
have corresponding symbols. The qualifiers of the other types, such as
function pointers, class members, and global variables, must be
identical between the old and new ABIs.

Test: ./test.py
Bug: 259148872
Change-Id: I227f6ed774cc88009713acce955e35f1c3cff1ca
2022-12-28 10:19:00 +08:00
Yu Liu
0d3029fb87 Explicitly search header files in abi dumper.
Bug: None
Test: Manual
Change-Id: Ie72e0c4490ab9e29152fcdc45e48ca9724e31f7d
2022-12-15 21:48:11 -08:00
Hsin-Yi Chen
4a0b74b22a Refactor DiffStatus into a class
DiffStatus is a class that exposes constants and member functions.
AbiDiffHelper calls the member functions to determine how to report the
diff. The actual value of a DiffStatus object is encapsulated so that
developers can define new status without changing existing logic.

Test: ./test.py
Bug: 259148872
Change-Id: I2c3be62046aa01d68c84690cb158f8fc7a5b474b
2022-12-14 10:06:13 +08:00
Hsin-Yi Chen
98d1ee8c04 Assert the output file of header-abi-diff
Test: ./test.py
Bug: 259148872
Change-Id: Ie4270b3fe8c76a63d0b82f246e012d7ca2622fd4
2022-12-13 18:22:34 +08:00
Hsin-Yi Chen
231fe7b57a Do not remove reference dumps before building new dumps
Adding or removing the dump files cause soong to regenerate the
ninja files, which takes a few minutes for every product.
create_reference_dumps.py makes "findlsdumps" and the lsdumps paths.
These targets do not trigger ABI diff. Thus it is not necessary to
remove the reference dumps before building new dumps.

Test: ./create_reference_dumps.py
Bug: 255702405
Change-Id: I4f4a43476d7a9c46d41ef237b846547ed41c7c04
2022-12-09 11:47:19 +08:00
Hsin-Yi Chen
0bfb1a674b Merge "Remove DiffStatus::opaque_diff" 2022-12-06 07:42:04 +00:00
Hsin-Yi Chen
e14853c82d Remove DiffStatus::opaque_diff
Since the helper function can compare the opaque types' unique IDs, it
is not necessary to return opaque_diff and compare the reference types'
names.

Test: ./test.py
Bug: 255702405
Change-Id: I1264b0f4d0db178a3dc2202a265c5ccb38df7dc2
2022-12-06 10:38:52 +08:00
Hsin-Yi Chen
21861cfece Do not create ABI dumps in AOSP directories for vendor libraries
create_reference_dumps.py recognizes VENDOR and PRODUCT tags in
lsdump_paths.txt. The dumps tagged with VENDOR, PRODUCT, VNDK-ext, or
VNDK-SP-ext cannot be created in the AOSP directories in
prebuilts/abi-dumps. The user who wants to generate dumps for vendor
libraries must specify -ref-dump-dir.

Test: ./create_reference_dumps.py -libs libutils
Test: ./create_reference_dumps.py -libs libutils -ref-dump-dir ./test-abi-dumps
Bug: 227282691
Change-Id: Iecf695d23d7a2e5a67859954c905fa9d1481b8ae
2022-11-29 16:20:54 +08:00
Hsin-Yi Chen
1c028bb8dd Deprecate compressed reference dumps
create_reference_dumps.py no longer supports compressing dumps because
they cannot be reviewed or merged.

Bug: 227282691
Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py
Change-Id: If4adccb865e3dba1e8045a6850478e46c9eae5de
2022-11-25 07:48:59 +00:00
Hsin-Yi Chen
9a49ca01f9 Do not create versioned subdirectories in -ref-dump-dir
This commit changes the structure of -ref-dump-dir. If the argument is
specified, create_reference_dumps.py generates
<arch>/source-based/<lib>.so.lsdump. Otherwise, the script generates
<version>/<binder>/<arch>/source-based/<lib>.so.lsdump in the default
dump directories. Library developers need to use -ref-dump-dir to create
opt-in reference dumps.

Bug: 227282691
Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py \
      -libs libutils -ref-dump-dir system/core/libutils/abi-dumps
Change-Id: I74cf7d092de405c76df31757104d66f75fcb9056
2022-11-25 10:39:37 +08:00
Hsin-Yi Chen
315d047b46 Fix the unit test for header-abi-dumper -print-resource-dir
The resource dir has been changed from lib64 to lib since clang-r468909.
build-prebuilts.sh creates lib in the dist dir so that developers can
easily run the binaries.

Test: development/vndk/tools/header-checker/android/build-prebuilts.sh
Test: development/vndk/tools/header-checker/tests/test.py
Bug: 255702405
Change-Id: I9bed6f0fd7948830a89d9e24889d9341ebf1a9c4
2022-11-17 02:32:06 +00:00
Hsin-Yi Chen
f5b6ebad09 Filter global variables and functions by -ignore-linker-set-key
Test: ./test.py HeaderCheckerTest.test_libgolden_cpp_return_type_diff
Bug: 259148872
Change-Id: I81f672d650a93eee69107ade07fc660a64c38e45
2022-11-16 15:43:22 +08:00
Hsin-Yi Chen
393ba54671 Allow extending vtables
This commit adds VTableLayoutDiffIR::IsExtended() that determines
whether the difference is a pure extension, i.e., appending virtual
functions to vtables.

Test: ./test.py
Bug: 248418092
Change-Id: I339713c5fff1dfa50dc7875272c0e3a59f858f57
2022-11-07 14:51:13 +08:00
Hsin-Yi Chen
3776a20379 Add the instructions to resolve ABI difference
The instructions are organized into a section. The developers who need
to resolve ABI difference can easily find it.

Test: None
Bug: 244520027
Change-Id: I211de0e1f65eece093fe716122753ea795c43b3e
2022-10-24 16:41:14 +08:00
Pirama Arumuga Nainar
59eac68f50 [clang-tools] Symlink lib -> lib64 in prebuilts/clang-tools
Bug: http://b/241011085

Create symlink lib -> lib64 as toolchain libraries have a RUNPATH pointing
to $ORIGIN/../lib instead of lib64

Test: presubmit with new clang-tools prebuilts
Change-Id: I90973fc756b9489a16a0837473b86e728f50d8e0
2022-10-18 16:39:07 +00:00
Chih-Hung Hsieh
21b04bc844 Update clang-tools build to clang-r468909
Bug: 241011085
Test: presubmit
Change-Id: I969239931c07dd97ce0259a3766ae93d68b21927
2022-10-17 23:45:22 +00:00
Hsin-Yi Chen
959646a857 Fix the comparison of opaque types that have multiple definitions
The types defined in more than one source file are identified with
"#ODR:" and the source paths. The paths can be in intermediate
directories and differ between build targets. They cause ABI check
failure on opaque types. This commit fixes the bug by removing the
suffixes before the comparison.

Test: make libcamera2ndk
Bug: 253095767
Change-Id: I79e6e843460c981afcf2ce0e0d2ad9335d0b3e90
2022-10-14 14:33:00 +08:00
Hsin-Yi Chen
5cc255dee6 Fix the comparison between opaque parameters
Function parameters can be opaque and have no size information. For
example, __va_list in AArch64 ABI. header-abi-diff considers opaque
types compatible if their mangled names are the same.

The mangled name of __va_list can be _ZTI9__va_list or _ZTISt9__va_list.
They are also compatible.

Test: ./test.py
Bug: 248418092
Change-Id: I812abcabb620301eb575c54c7e3d2ff63dade488
2022-10-06 15:46:16 +08:00
Hsin-Yi Chen
f5f04a5b6c Simplify the error message for ABI check
- Remove "VNDK" from the message.
- Deprecate -elf-unreferenced-symbol-errors.
- Fix the status string for CompatibilityStatusIR::UnreferencedChanges.

Test: ./test.py
Bug: 249324120
Change-Id: I5a1fd64f9101caa29d87d9f65bd4d17b8bd77059
2022-10-05 10:13:41 +08:00
Hsin-Yi Chen
fc212f2a34 Merge "Do not allow extending pass-by-value parameters or return types" 2022-10-05 02:03:26 +00:00
Hsin-Yi Chen
9f22a276fd Allow adding class/struct members to padding space
This commit removes the comparison between class size and member offsets
from RecordTypeDiffIR::IsExtended. New members can be added to padding
space in a class without changing the existing members.

Test: ./test.py
Bug: 248418092
Change-Id: I34d002478f1dcfd3c183e76899917e602de2b4c1
2022-09-29 19:49:41 +08:00
Hsin-Yi Chen
d875d513f2 Do not allow extending pass-by-value parameters or return types
Resizing the parameters or return types changes the stack layout. It
is not an allowed extension to functions.
AbiDiffHelper::CompareFunctionTypes additionally checks the sizes of the
parameters and the return types. The difference cannot be ignored by
-allow-extensions. The user who intends to ignore the difference should
specify -ignore-symbols or -ignore-linker-set-key.

Test: ./test.py
Bug: 248418092
Change-Id: Ibef3b9260504afff3fc0260b0565736133b8e0dc
2022-09-28 10:59:51 +00:00
Hsin-Yi Chen
efd3826863 Merge "Allow appending members to structs and classes" 2022-09-28 09:18:15 +00:00
Hsin-Yi Chen
e0d81eed8f Merge "Delete VNDK definition tools" 2022-09-28 04:24:25 +00:00
Hsin-Yi Chen
cdf49db15c Allow appending members to structs and classes
This commit adds RecordTypeDiffIR::IsExtended() that determines whether
the difference is a pure extension, i.e., appending members and
increasing the size. The extensions are stored in
record_type_extension_diffs in abi_diff messages. They can be ignored by
specifying -allow-extensions.

Test: ./test.py
Bug: 248418092
Change-Id: Ibdef042c6176dc84d2dd61f71a3f88035e943dd4
2022-09-28 12:18:01 +08:00
Hsin-Yi Chen
adc960d590 Merge "Filter added or removed types by -ignore-linker-set-key" 2022-09-23 03:31:49 +00:00
Hsin-Yi Chen
cc90871286 Merge "Add linker_set_key to RecordTypeDiff and EnumTypeDiff" 2022-09-22 07:00:47 +00:00
Hsin-Yi Chen
37792200d3 Filter added or removed types by -ignore-linker-set-key
Test: development/vndk/tools/header-checker/tests/test.py
Bug: 243903630
Change-Id: I103779591cf8f52f9178d33ad5a205ca4eaaba2f
2022-09-21 09:00:40 +00:00
Hsin-Yi Chen
00d8159166 Add linker_set_key to RecordTypeDiff and EnumTypeDiff
RecordTypeDiff and EnumTypeDiff in abi_diff.proto contain linker set
keys. The developers can copy them to the ignore list. The other Diff
messages do not need the field because it's in the messages imported
from abi_dump.proto.

Test: Update prebuilts/clang-tools; make libz
Bug: 243903630
Change-Id: I1e90d3c6cbfd09d72b3fdb244a4079ae899630aa
2022-09-21 16:50:58 +08:00
Pirama Arumuga Nainar
dafc6d0793 Merge "Update clang-tools build to clang-r458507" 2022-09-19 20:02:41 +00:00
Pirama Arumuga Nainar
2e6f159eae Update clang-tools build to clang-r458507
Bug: http://b/236798112
Bug: http://b/244486343
Test: presubmit
Change-Id: Icff1712b289925901582f5429bfea3fde1834eec
2022-09-19 05:16:10 +00:00
Krzysztof Kosiński
45c7ebda06 Remove Python enables identical to global defaults.
Bug: 245854393
Test: presubmit
Change-Id: I9bb5cbd972432a26afcb13d7c2a6bbc73fb0991f
2022-09-17 11:33:50 +00:00
Hsin-Yi Chen
f38939ac24 Delete VNDK definition tools
The tools have not been maintained since Android 11.
vndk-lib-extra-list-*.txt are not deleted because VTS depends on them.

Test: make
Bug: 247032590
Change-Id: Iafaf98d13e77edea34a45c84ac44804703aa6d24
2022-09-16 14:37:04 +08:00
Mu-Le Lee
3ccbbe8717 Merge "Update README in header checker for option ignored_linker_set_keys" 2022-09-05 08:13:48 +00:00
Mu-Le Lee
a008152637 Merge "Add option to ignore some specific LinkerSetKeys in header-abi-diff" 2022-09-05 07:37:06 +00:00
Mu-Le Lee
d93d4de71f Add option to ignore some specific LinkerSetKeys in header-abi-diff
Sometimes developers may want to ignore some incompatible changes in ABI
because it is safe for some reason. An option should be added to
header-abi-diff so it ignores these LinkerSetKeys passed from cli or
config file.

Test: perform abi diff on libz with abi-dump version 33 with the LinkerSetKey _ZTI14internal_stat is specified.
Bug: 243903630
Change-Id: Iccc79d648ae17634a987faac32a2a7cbaa784e5c
2022-09-01 08:08:13 +00:00
Mu-Le Lee
173a9dd208 Update README in header checker for option ignored_linker_set_keys
NDK and platform Libraries are required to ensure the compatibility
across SDK version. However, some changes of a library that break its
ABI compatibility are necessary. Thus a ignored_linker_set_keys option
is added to let developers to skip some symobls.

Test: no need
Bug: 243903630
Change-Id: If6ca665189fdeec7c3e735a0f691dffd180ddc63
2022-08-31 09:08:44 +00:00
Mu-Le Lee
d8fdf8bc91 Merge "Update README in header checker for header-abi-diff configuration" 2022-08-26 12:59:18 +00:00
Mu-Le Lee
06f41abd76 Update README in header checker for header-abi-diff configuration
Add description of the config format and logic for developer to add
flags to header-abi-diff in Cross-Version ABI Check.

Test: no need
Bug: 239790286
Change-Id: I5b8fbe57aaafd1357495395a416a5d6b51f0ff3f
2022-08-26 11:19:46 +00:00
Mu-Le Lee
3bf758113b Merge "Fix header-abi-diff skips diff when config.json is not found" 2022-08-22 15:09:09 +00:00
Mu-Le Lee
82c4dd2bc7 Fix header-abi-diff skips diff when config.json is not found
Skip loading config.json when the config.json is not found so the
header-abi-diff will still perform abi diff.

Test: preform abi diff without config.json
Bug: 243328443
Change-Id: I92ebf7e7bfe6abb57bdefa211eaf604efaee517e
2022-08-22 08:32:57 +00:00
Mu-Le Lee
7b72a4f5f1 Merge "Implement the Cross-Version ABI diff configuration" 2022-08-19 08:25:45 +00:00
Mu-Le Lee
2ce72d8673 Implement the Cross-Version ABI diff configuration
Enable the Cross-Version ABI diff configuration so developers can
specify different flags for current and previous version ABI Check. The
-target-version flag were added to determine the config section to be
selected. The details of this configuration logic could be found in
go/cross-version-abi-diff-configuration.

Test: preform abi diff with config.json
Bug: 239792343
Change-Id: I8fdad2d18096cfa7866183ecc2d7826682c85eb6
2022-08-19 04:42:03 +00:00