148 Commits

Author SHA1 Message Date
Troy Butler
e6e931960b
[LLVM][TextAPI] Refactor Redundant Condition (#86542)
Fixes #83241

---------

Signed-off-by: Troy-Butler <squintik@outlook.com>
Co-authored-by: Troy-Butler <squintik@outlook.com>
2024-04-19 09:36:08 -07:00
Cyndy Ishida
4c18681a2d
[InstallAPI] Add support for aliased exports (#88750)
Apple's ld supports alias_lists, described as
```
     -alias_list filename
             The specified filename contains a list of aliases. The symbol name and its alias are on one
             line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
2024-04-18 07:39:21 -07:00
Cyndy Ishida
b8d0cba14b
[TextAPI] Apply NFC code fixups (#88639)
* Remove unnecessary cast
* Annotate `#endif`
2024-04-14 09:23:42 -07: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
a4de589d11
[InstallAPI] Add support for parsing dSYMs (#86852)
InstallAPI does not directly look at object files in the dylib for
verification. To help diagnose violations where a declaration is
undiscovered in headers, parse the dSYM and look up the source location
for symbols. Emitting out the source location with a diagnostic is
enough for some IDE's (e.g. Xcode) to have them map back to editable
source files.
2024-03-29 08:29:22 -07:00
Cyndy Ishida
487720fc13
Reapply "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)" (#86574) 2024-03-25 17:32:21 -04:00
Cyndy Ishida
2d7df3167b Revert "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)"
This reverts commit b7d8c6188986f62573b9516fe27fdd0c7df1aaf9. And
This reverts commit 2d40f179124f874aca4cf1145fdbc42fb8fb17f3.

It caused a build failure i'll need to reproduce.
` error: could not convert ‘Rule’ from ‘llvm::Regex’ to ‘llvm::Expected<llvm::Regex>’`
2024-03-25 15:50:46 -04:00
Cyndy Ishida
b7d8c61889 [TextAPI] Add missing include for Expected type 2024-03-25 15:45:25 -04:00
Cyndy Ishida
2d40f17912
[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)
InstallAPI takes a json list of headers that is typically generated from
a build system like Xcode based on a project's attributes. Sometimes,
maintainers may want to alter this for tapi input. Using e.g.
`--extra-public-headers`, users can manipulate what headers will be used
for TBD file generation.
2024-03-25 15:38:27 -04:00
Cyndy Ishida
e470ca89ba
[InstallAPI] Report exports discovered in binary but not in interface (#86025)
This patch completes the classes of errors installapi can detect.
2024-03-21 15:03:34 -07:00
Cyndy Ishida
c51095f51b
[InstallAPI] Add installapi specific options & diagnostics (#85100)
* A lot of `tapi installapi` options are already shared with clang, but
not all. This patch handles installapi-specific options by filtering for
them in the initial argv input, then passing the rest to the clang
driver.
* Installapi not only generates a text file but also reports to library
developers when there are inconsistencies between an interface and its
implementation. To allow this, add support for reporting installapi
diagnostics. This will be leveraged in the verifier service.
2024-03-16 09:08:17 -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
06fea93341 [TextAPI] add missing platforms for translating triples to tapi targets 2024-03-05 09:34:44 -08:00
Cyndy Ishida
10ccde30e7
[InstallAPI] Collect symbols from ObjC Ivars (#83632) 2024-03-04 14:50:04 -08:00
Cyndy Ishida
346766eae8
[TextAPI] Fixup symbol names of ivars from extensions (#83525) 2024-02-29 22:06:04 -08:00
Cyndy Ishida
3a080a0195
[TextAPI] Refactor BinaryAttrs to InterfaceFile assignment (#81551)
Create a helper method for this operation, so it can be reused in
multiple places.
Additonally move FileType enum into its own header to avoid include
cycles.
2024-02-12 16:15:21 -08:00
Cyndy Ishida
6eb7273b11
[readtapi] Ensure universal dylibs record the same input path location across slices (#80875)
resolves: https://github.com/llvm/llvm-project/issues/80868
2024-02-06 10:01:45 -08:00
Cyndy Ishida
7189219ec9
[readtapi] Add support for stubify-ing directories (#76885)
When given a directory input `llvm-readtapi` traverses through the
directory to find dylibs or tbd files to operate on. TBD files will be
created with the same base file name as the dylib. Symlinks should be
created if the input is one.

This also introduces options to delete input files which are defined as
library files that existed before `readtapi -stubify` was invoked. Also
the ability to delete private libraries where private libraries are in a
predefined file system locations on darwin based platforms.
2024-02-03 09:33:42 -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
7d3466b5c3
[llvm] Introduce XROS platform (#77707)
Accepts but otherwise ignores visionOS/XROS target triples as Darwin
based platform.

https://developer.apple.com/documentation/visionos
2024-01-16 16:32:10 -08:00
Kazu Hirata
96f14ea618 [llvm] Use range-based for loops with llvm::drop_begin (NFC) 2024-01-13 18:18:47 -08:00
Cyndy Ishida
8ca0364d33
[TextAPI] Skip adding empty attributes (#77400)
An empty string attribute value (e.g. a parent-umbrella: "") is
equivalent to omitting it. Theres no reason to write it out.
2024-01-09 09:41:14 -08:00
Cyndy Ishida
8fa3184539
[TextAPI] Use function_ref where possible, NFCI (#76732) 2024-01-02 09:47:38 -08:00
Cyndy Ishida
c6f29dbb59
[readtapi] Setup simple stubify support (#76075)
Stubify broadly takes either tbd files or binary dylibs and turns them
into tbd files. In future patches, stubify will also allow additional
information to be embedded into the final TBD output too.

Add Util APIs to TextAPI for common operations used by readtapi for now.
2023-12-20 14:56:53 -08:00
Cyndy Ishida
5ea15fab19
[TextAPI] Add support to convert RecordSlices -> InterfaceFile (#75007)
Introduce RecordVisitor. This is used for different clients that want to
extract information out of RecordSlice types.
The first and immediate use case is for serializing symbol information
into TBD files.
2023-12-20 08:47:10 -08:00
Cyndy Ishida
e6ebe8bf81
[TextAPI] use unique sorted vector for holding target triples for (#75959)
reading dylibs

* This is a better fix than what I originally did to appease CI.
2023-12-19 14:49:57 -08:00
Cyndy Ishida
7ea7267cc5 [TextAPI] switch container for holding triples in dylib
Resolves buildbot failure reported on windows bot
2023-12-18 19:00:54 -08:00
Cyndy Ishida
e3627e2690
Reland '[TextAPI] Add DylibReader' (#75862)
> Add support for reading binary Mach-o dynamic libraries. It uses
libObject APIs for extracting information relevant to TAPI and tbd
files. This includes but is not limited to load commands encode data
like install names, current/compat versions, and symbols.

This originally broke because DylibReader uses Object and Object depends
on TextAPI. Breaking this up in a nested library prevents this cycle.
2023-12-18 16:55:30 -08:00
Cyndy Ishida
1fef0fac32 Revert "[TextAPI] Add missing link to libObject" and "[TextAPI] Add DylibReader (#75006)"
This reverts commit aa217eb04459039b5ff18b6b134020ed0248a241.
This reverts commit 634feddc84bfd402fc916d331627528c41346d8c.

This breaks buildbots by introducing cycle dependency between libObject
and TextAPI and breaks gcc compiles on buildbots.
2023-12-12 20:01:49 -08:00
Cyndy Ishida
aa217eb044 [TextAPI] Add missing link to libObject
* Reported in buildbot failures
2023-12-12 19:55:18 -08:00
Cyndy Ishida
634feddc84
[TextAPI] Add DylibReader (#75006)
Add support for reading binary Mach-o dynamic libraries. It uses
libObject APIs for extracting information relavant to TAPI and tbd
files. This includes but is not limited to load commands encode data
like install names, current/compat versions and symbols.
2023-12-12 19:50:24 -08:00
Kazu Hirata
586ecdf205
[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-11 21:01:36 -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
Cyndy Ishida
f501659768
[TextAPI] don't write out empty/zeroed out min os (#72603) 2023-11-17 06:54:52 -08:00
Cyndy Ishida
ec64af5994
[readtapi] Use OptParser.td for options (#72183)
This includes revamping how --compare was handled and adds `-o` ontop of
tablegen approach.

This will be used to add more complex options.
2023-11-15 09:31:31 -08:00
Cyndy Ishida
d8a4011f5b
[TextAPI] Add error code for invalid input formats (#71824) 2023-11-09 13:17:41 -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
Juergen Ributzka
bde2e6981e
[llvm] Use XMACROS for MachO platforms. (#69262)
This change adds the PLATFORM XMACRO to simplify the addition of new MachO
platforms and reduce the number of required changes. Many of the changes needed
for adding a new platform are mechanical, such as adding new cases to a switch
statement. This will help streamline the process by consolidating much of the
necessary information into the MachO.def file.
2023-10-20 09:37:39 -07:00
Gregory Alfonso
40dc8e6889 [NFC] Use const references to avoid copying objects in for-loops
Differential Revision: https://reviews.llvm.org/D139487
2023-09-27 13:39:30 -07:00
Cyndy Ishida
dc787bc94c [TextAPI] Add missing flag input for <=tbdv3 formats 2023-09-15 08:30:28 -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
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
Kazu Hirata
6da470d7f8 [llvm] Use range-based for loops (NFC) 2023-09-02 09:32:45 -07:00
Cyndy Ishida
1a0d6992ae [llvm][ReadTAPI] Add & fix rpath comparison checks
* Check and emit out differences in rpath inputs
* Prevent rpaths from being overwritten
* Capture file path for tbd-v5
2023-08-30 07:42:52 -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
Kazu Hirata
3c03a15104 [llvm] Use DenseMap::lookup (NFC) 2023-08-10 18:44:16 -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
27459a3a2b [TextAPI] Update missing enum cases & utility functions
* Expand understood `FileType`s that InterfaceFile class can represent.
* Add `hasTarget` function.
* Cleanup symbol `<` comparator to account for SymbolSet operations.
2023-07-27 08:24:42 -07:00