85 Commits

Author SHA1 Message Date
Cyndy Ishida
03506bc0a9
[TextAPI] Add missing attribute to remove/merge/extract operations (#116729) 2024-11-19 08:01:05 -08:00
Cyndy Ishida
515d3f7d62
[TextAPI] Reorder addRPath parameters (#87601)
It matches up with other _attribute_ adding member functions and helps
simplify InterfaceFile assignment for InstallAPI.
2024-04-04 10:45:55 -07:00
Cyndy Ishida
50ae8a2a38
[InstallAPI] Collect global functions (#83952)
* Include whether functions are inlinable as they impact whether to add
them into the tbd file and for future verification.
* Fix how clang arguments got passed along, previously spacing was
passed along to CC1 causing search path inputs to look non-existent.
2024-03-07 15:32:44 -08:00
Cyndy Ishida
4460fa8814
[TextAPI] Introduce granularity for handling ObjC Interface symbols (#79928)
ObjCInterfaceRecords roughly align to the objc-classes key in tbd-files.
They condensely represent up to 3 symbols. The problem here is that when
represented this way, we lose granularity when these symbols could have
different linkages or outright don't exist. This can happen frequently
in interoptable code generated by the swift compiler. This adds fields
and utility functions to express unique properties for these symbols. If
the record does represent the same properties across all of its symbols,
it will be treated the same in the TBD. Otherwise it will be printed in
global's section.

Reviewed seperately before by Juergen Ributzka
2024-01-29 18:36:48 -08:00
Cyndy Ishida
d9a9872ec4
[TextAPI] Rename SymbolKind to EncodeKind (#79622)
A distinction that doesn't _usually_ matter is that the
MachO::SymbolKind is really a mapping of entries in TBD files not
symbols. To better understand this, rename the enum so it represents an
encoding mapped to TBDs as opposed to symbols alone.

For example, it can be a bit confusing that "GlobalSymbol" is a enum
value when all of those values can represent a GlobalSymbol.
2024-01-26 16:12:50 -08:00
Cyndy Ishida
735adbf1a8
[llvm] Teach MachO about XROS (#78373)
Add support for XROS to encode in Mach-O file formats.
2024-01-17 10:35:20 -08:00
Cyndy Ishida
ab4d6cd6d1
[TextAPI] Update RecordSlice attributes to follow code guidelines (#74743)
Came across simple code cleanup while upstreaming more code, this is
primarily an NFC.
2023-12-07 13:11:13 -08:00
Cyndy Ishida
0801216f62 [TextAPI][Tests] Add missing link to TargetParser in tests
* Caught in buildbot error
2023-12-02 13:34:51 -08:00
Cyndy Ishida
b04b89753d
[TextAPI] Introduce Records & RecordSlice Types (#74115)
`Record`'s hold target triple specific information about APIs and
symbols. This holds information about the relationship between ObjC
symbols and their linkage properties. It will be used to compare and run
significant operations between the frontend representation of symbols in
AST and symbol information extracted from Mach-O binaries. This differs
from the lighter weight Symbol and SymbolSet class where they are
deduplicated across targets and only represent exported symbols, that
class is mostly used for serializing.
2023-12-02 13:19:01 -08:00
Kazu Hirata
1564c225ef [llvm] Stop including llvm/ADT/SmallString.h (NFC)
Identified with clangd.
2023-11-11 12:32:13 -08:00
Cyndy Ishida
e17efa60b1
[llvm][TextAPI] Add new not_for_dyld_shared_cache attribute to file… (#71735)
… format.

Formats >= TBDv4 will now encode new attribute that the system static
linker wil read when tbd files replace binary dylibs.
2023-11-09 09:22:16 -08:00
Juergen Ributzka
2d292ab886
[llvm] Followup fix for "Use XMACROS for MachO platforms" (#70140)
Fix the use of tapi_target in getPlatformFromName.
2023-10-25 08:49:41 -07:00
Cyndy Ishida
455bf3d1cc
[TextAPI] Consolidate TextAPI Reader/Writer APIs. (#66108)
Both Swift & LLD use TextAPI reader/writer apis to interface with TBD
files. Add doc strings to document what each API does. Also, add
shortcut APIs for validating input is a TBD file.

This reduces the differences between downstream and how tapi calls into
these APIs.
2023-09-14 20:43:41 -07:00
Zero Omega
a560d219db
[unittests] Add missing includes (#65681)
There are missing include and using in TextStubTests and
AsmPrinterDwarfTest and they causes build failures when using vanilla
GoogleTest v1.14.0. This patch fixes this issue.
2023-09-08 12:10:37 -07:00
Cyndy Ishida
f9fe6032cd [TextAPI] Support more constructors for PackedVersions
TBD files now record minimum deplyoment versions and tapi interfaces
with apple system linker by a packed version encoding. Support mapping
between that and `VersionTuple`s.
2023-09-07 12:23:12 -07:00
Cyndy Ishida
913f21ae5c [TextAPI] Express MH_SIM_SUPPORT in tbd files.
This adds a new optional flag sim_support which is the same as
MH_SIM_SUPPORT in the MachO header.

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D157433
2023-08-11 10:17:01 -07:00
Cyndy Ishida
3b73139150 [TextAPI] Make min-os deployment version optional in tbd-v5.
The minOS version is recorded in tbd-v5 so the linker can report
diagnostics when a library and client are misconfigured.

Dylibs should always have a minOS recorded, but in was not recorded in
previous TBD versions. To accommodate the format transition, treat
unrecorded minOS versions as 0.

Reviewed By: zixuw

Differential Revision: https://reviews.llvm.org/D156487
2023-07-28 11:21:11 -07:00
Cyndy Ishida
16c1f43642 [TextAPI] Add functionality to manipulate over InterfaceFiles
InterfaceFile is the in-memory representation for tbd files. Add APIs to
merge, extract, remove, and inline reexported libraries.

Reviewed By: zixuw

Differential Revision: https://reviews.llvm.org/D153398
2023-07-25 09:23:57 -07:00
Cyndy Ishida
a0666956b2 [TextAPI] Remove TBD file attributes that aren't used anymore.
UUID's & `installapi` flag are no longer useful in recent apple linker/tapi.
The reason for removing them is that these are attributes that record
how a library was built but not really about the library itself. TBD
files now only track information this is important as link time
dependencies.

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D149861
2023-07-24 14:26:32 -07:00
Cyndy Ishida
0882c70df2 [TextAPI] Introduce SymbolSet
SymbolSet is a structure that acts as a simple container class for exported symbols that
belong to a library interface. It allows tapi to decouple the globals
from the other library attributes. It's uniqued by symbol name and `kind`, which all contain their assigned target triples.

Reviewed By: zixuw

Differential Revision: https://reviews.llvm.org/D149860
2023-07-24 12:01:25 -07:00
NAKAMURA Takumi
7d5d987e93 [CMake] Reorder and reformat deps 2023-04-17 00:32:16 +09:00
Cyndy Ishida
f991f30845 [llvm][TextAPI] compare deployment versions for equality check 2023-03-31 16:50:08 -07:00
Cyndy Ishida
397486566e [llvm][TextAPI] Handle implicitly upgraded deployment versions
Sometimes the clang driver will receive a target triple where the
deployment version is too low to support the platform + arch. In those
cases, the compiler upgrades the final minOS which is what gets recorded
ultimately by the linker in LC_BUILD_VERSION. TextAPI should also reuse
this logic for capturing minOS in recorded TBDv5 files.

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D145690
2023-03-23 14:58:41 -07:00
Cyndy Ishida
e61e761643 [llvm][TextAPI] add Default FileType value to InterfaceFile Objects
* This silences msan errors
2023-02-22 22:26:13 -08:00
Cyndy Ishida
9b29de1c79 [llvm][TextAPI] Clean up minor bugs in YAML TextStub
* Always print out maccatalyst in format
* Traverse symbols via InterfaceFile symbol APIs
* Properly track addition of flags.

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D144428
2023-02-22 15:46:06 -08:00
Cyndy Ishida
d6f9b97bae Reland "[TextAPI] Implement TBDv5 Writer"
Create writer for new JSON format.
The new JSON format allows practically all attributes to be defined per
target in a universal library however the internal representation only
allows one for the time being. For now the write will always write those
attributes as default available for all targets (install name,
compatability & current version, swift abi, flags e.g. flatnamepace &
app exenstion safety)

rdar://102076911

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D144339
2023-02-22 12:01:37 -08:00
Cyndy Ishida
b2b50980de Revert "[TextAPI] Implement TBDv5 Writer"
This reverts commit 8217932aabcb271df7eb30e069fdace904299cba.

Breaks buildbots.
2023-02-22 11:39:23 -08:00
Cyndy Ishida
8217932aab [TextAPI] Implement TBDv5 Writer
Create writer for new JSON format.
The new JSON format allows practically all attributes to be defined per
target in a universal library however the internal representation only
allows one for the time being. For now the write will always write those
attributes as default available for all targets (install name,
compatability & current version, swift abi, flags e.g. flatnamepace &
app exenstion safety)

rdar://102076911

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D144339
2023-02-22 11:34:27 -08:00
Cyndy Ishida
b70d87bc5e
[TextAPI] Capture new properties from TBD to InterfaceFile
* Deployment Versions for targets
* Run Search Paths
* Text vs Data Segment attributes to symbols

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D144158
2023-02-18 10:52:24 -08:00
Cyndy Ishida
79320a0c3f
Reland "[TextAPI] Implement TBDv5 Reader"
Introduce initial reader for TBDv5 which is in JSON. This captures all
the currently understood fields within the internal structure
`InterfaceFile`.
New fields will be followed up in future PRs.

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D144156
2023-02-17 22:27:08 -08:00
Cyndy Ishida
07e3ca238e Revert "[TextAPI] Implement TBDv5 Reader"
This reverts commit b861b1225380175a5a724e2a677754f5f74e5b0d.
This reverts commit 4be17641b05df1e63fa8e069af92676f1246eb83.

This patch wont build on some compilers on buildbot.
2023-02-17 16:26:23 -08:00
Cyndy Ishida
b861b12253 [TextAPI] Implement TBDv5 Reader
[TextAPI] Implement TBDv5 Reader

    Introduce initial reader for TBDv5 which is in JSON. This captures all
    the currently understood fields within the internal structure
    `InterfaceFile`.

    New fields & follow up tests will be followed up in future PRs.

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D144156
2023-02-17 16:03:01 -08:00
Anton Sidorenko
6820cb2dd5 [Test] Fix YAML mapping keys duplication. NFC.
YAML specification does not allow keys duplication an a mapping. However, YAML
parser in LLVM does not have any check on that and uses only the last key entry.
In this change duplicated keys are merged to satisfy the spec.

Differential Revision: https://reviews.llvm.org/D141848
2023-02-09 12:59:50 +03:00
Kazu Hirata
589725f6e8 [llvm] Use std::size (NFC)
std::size, introduced in C++17, allows us to directly obtain the
number of elements of an array.
2022-11-26 13:47:32 -08:00
Dmitri Gribenko
cd9a5cfd2e Use the range-based overload of llvm::sort where possible
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D130403
2022-07-23 15:13:25 +02:00
Juergen Ributzka
3025c3eded Replace PlatformKind with PlatformType.
The PlatformKind/PlatformType enums contain the same information, which requires
them to be kept in-sync. This commit changes over to PlatformType as the sole
source of truth, which allows the removal of the redundant PlatformKind.

The majority of the changes were in LLD and TextAPI.

Reviewed By: cishida

Differential Revision: https://reviews.llvm.org/D117163
2022-01-13 09:23:49 -08:00
Cyndy Ishida
c4ed142e69 [llvm][TextAPI] add mapping from OS string to Platform
* add utility for matching target triple OS value strings  to PlatformKind

This was reviewed offline by ributzka, steven_wu
2021-05-06 16:25:56 -07:00
Cyndy Ishida
0116d04d04 [TextAPI] move source code files out of subdirectory, NFC
TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.

Reviewed By: ributzka, int3, #lld-macho

Differential Revision: https://reviews.llvm.org/D99811
2021-04-05 10:24:42 -07:00
Sam Powell
eb2eeeb76f [llvm][TextAPI] add equality operator for InterfaceFile
This patch adds functionality to compare for the equality between `InterfaceFile`s based on attributes specific to linking.

Reviewed By: cishida, steven_wu

Differential Revision: https://reviews.llvm.org/D96629
2021-02-18 11:53:08 -08:00
Paul Robinson
25fefa5a09 [RGT][TextAPI] Remove a zero-trip loop and the assertions within it
Found by the Rotten Green Tests project.

Differential Revision: https://reviews.llvm.org/D95259
2021-01-22 15:07:41 -08:00
Nathan James
d380c38e34
[YAML] Use correct source location for unknown key errors.
Currently unknown keys when inputting mapping traits have the location set to the Value.
Example:
```
YAML:1:14: error: unknown key 'UnknownKey'
{UnknownKey: SomeValue}
             ^~~~~~~~~
```
This is unhelpful for a user as it draws them to fix the wrong item.

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D93037
2020-12-11 16:34:06 +00:00
Cyndy Ishida
0b15cb70d3 [TextAPI] clean up auto usages in tests, NFC 2020-09-21 08:39:40 -07:00
Greg McGary
eef41efe00 [MachO] Add skeletal support for DriverKit platform
Define the platform ID = 10, and simple mappings between platform ID & name.

Reviewed By: MaskRay, cishida

Differential Revision: https://reviews.llvm.org/D85594
2020-08-14 12:36:43 -07:00
Haowei Wu
d650cbc349 [elfabi] Move llvm-elfabi related code to InterfaceStub library
This change moves elfabi related code to llvm/InterfaceStub library
so it can be shared by multiple llvm tools without causing cyclic
dependencies.

Differential Revision: https://reviews.llvm.org/D85678
2020-08-13 11:51:44 -07:00
Cyndy Ishida
2ba320846b [llvm][TextAPI/MachO] clean up auto usages in tests, NFC 2020-06-15 19:59:42 -07:00
Simon Pilgrim
c5b9fa1ccc Add missing MemoryBuffer.h include 2020-06-02 11:25:13 +01:00
Cyndy Ishida
fd4d07517b [llvm][TextAPI] adding inlining reexported libraries support
Summary:
[llvm][TextAPI] adding inlining reexported libraries support

* this patch adds reader/writer support for MachO tbd files.
The usecase is to represent reexported libraries in top level library
that won't need to exist for linker indirection because all of the
needed content will be inlined in the same document.

Reviewers: ributzka, steven_wu, jhenderson

Reviewed By: ributzka

Subscribers: JDevlieghere, hiraditya, mgrang, dexonsmith, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67646
2020-04-02 13:05:08 -07:00
Cyndy Ishida
d26e0bcfba [llvm][TextAPI/MachO] silence clang-tidy warnings, NFC
* applies only to tests
2020-03-26 16:32:04 -07:00
Cyndy Ishida
a0cd413426 [TextAPI] Teach TextAPI about arm64e
Reviewers: ributzka, cishida

Subscribers: kristof.beyls, dexonsmith, dcoughlin, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75688
2020-03-05 13:22:25 -08:00
Cyndy Ishida
6d2372ce58 [llvm][TextAPI] rename test vars, NFC
* Conforms to clang tidy
2020-02-25 14:28:36 -08:00