37 Commits

Author SHA1 Message Date
Ian Anderson
bd197ca003
[clang][modules] Determine if the SDK supports builtin modules independent of the target (#134005)
Whether the SDK supports builtin modules is a property of the SDK
itself, and really has nothing to do with the target. This was already
worked around for Mac Catalyst, but there are some other more esoteric
non-obvious target-to-sdk mappings that aren't handled. Have the SDK
parse its OS out of CanonicalName and use that instead of the target to
determine if builtin modules are supported.
2025-04-03 16:09:57 -07:00
Cyndy Ishida
4ed543d414
[InstallAPI] Fix early return for scanning sub-directories (#100636) 2024-07-25 15:26:41 -07:00
Haowei
2df9fd7edb
Fix diagnostics-dsym.test on mac-arm64 (#99399)
The check ordering of diagnostics-dsym.test is wrong and it causes
test failure when running on mac-arm64 machine. This patch fixes it.
2024-07-19 00:03:12 -07:00
Cyndy Ishida
a4a8d36b85
[InstallAPI] Don't look for linker directive symbols in reexports (#98171)
`$ld$previous` symbols need to be exported for them to be seen by
clients. TAPI cannot omit them in tbd files, so account for this in
installapi verification when handling reexport verification.

Reviewed internally by Zixu Wang
resolves: rdar://131317591
2024-07-10 07:50:07 -07:00
Cyndy Ishida
feed66f3ea
[InstallAPI] Pick up input headers by directory traversal (#94508)
Match TAPI behavior and allow input headers to be resolved via a passed
directory, which is expected to be a library sitting in a build
directory.
2024-06-14 13:08:27 -07:00
Aaron Ballman
b49ce9c304
Fix more diagnostic wording for style; NFC (#93190)
This tries to fix all of the places where a diagnostic message starts
with a capital letter (other than acroynyms or proper nouns) or ends
with punctuation (other than a question mark).

This is in support of a planned change to tablegen to start diagnosing
incorrect diagnostic message styles.
2024-05-23 14:50:29 -04:00
Cyndy Ishida
c9dc52d424
[InstallAPI] add JSON option to pass X<label> arguments (#91770) 2024-05-20 21:22:24 -07:00
Cyndy Ishida
504cf55463
[InstallAPI] Pass explicit module cache to avoid permissions issues.
Fixes: https://lab.llvm.org/buildbot/#/builders/192/builds/9313
2024-05-10 17:17:38 -07:00
Cyndy Ishida
062f6fe324
[InstallAPI] Support mutually exclusive parse options (#90686)
Projects like libc use mutually exclusive macros to compile files
multiple times and then merge the result into the final library. For
installapi to accept these, we'd need to parse the same declarations in
different ways. This patch adds the basic pipelining for installapi to
create the correct TBD file.

* -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix
headers
* -Xlabel allows: -D and -U settings
* Error on 'private' and 'public' labels -X<label>
* Xplatform allows: -iframework <path> This is to support the case where
zippered frameworks want to pass in iOSSupport search path.
2024-05-10 09:35:41 -07:00
Cyndy Ishida
515269b0ac
[InstallAPI][Tests] Update tests to be resilient to reversion iteration config (#89270) 2024-04-18 12:21:20 -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
c24efffabb
[InstallAPI] Handle zippered frameworks (#88205)
A zippered framework is a single framework that can be loaded in both
macOS and macatalyst processes. Broadly to InstallAPI, it means the same
interface can represent two separate platforms.

A dylib's symbol table does not distinguish between macOS/macCatalyst.
  `InstallAPI` provides the ability for the tbd file to distinct
symbols between them.
The verifier handles this special logic by tracking all unavailable and
obsoleted APIs in this context and checking against those when
determining dylib symbols with no matching declaration.

* If there exists an available decl for either platform, do not warn.
* If there is no available decl, emit a diagnostic and print the source
location for both decls.
2024-04-11 20:01:55 -07:00
Cyndy Ishida
27b2d7d4bb
[InstallAPI] Capture & compare load commands that may differ per arch slice (#87674)
* Capture reexported libraries, allowable clients, rpaths, shared cache
eligibility.
* Add support for select Xarch options.
* Add diagnostics related to capturing these options.
* Add support for verifying these attributes against what is encoded in
the dylib.
2024-04-05 13:58:24 -07:00
Cyndy Ishida
1c683eb324
[InstallAPI] Add test to validate cc1 arg forwarding (#87666) 2024-04-04 22:15:06 -07:00
Cyndy Ishida
8ebf7b7d7a
[InstallAPI][Test] Add test for invalid verification mode (#87602) 2024-04-04 07:46:55 -07:00
Cyndy Ishida
30fd099d50
[InstallAPI] Fixup dsym test (#87299)
Update the test to run when the compiler is built to support
arm64-darwin targets.
2024-04-01 18:30:23 -07:00
Cyndy Ishida
bdb60e6f0c [InstallAPI][test] Add requires x86_64 for hardcoded target test 2024-03-29 10:34:35 -07:00
Cyndy Ishida
60deb8b39a [InstallAPI][test] Tweak test to run on older CI config 2024-03-29 10:00:51 -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
6ad1cf3b37
[InstallAPI] Add *umbrella-header options (#86587)
Umbrella headers are a concept for Darwin-based libraries. They allow
framework authors to control the order in which their headers should be
parsed and allow clients to access available headers by including a
single header.

InstallAPI will attempt to find the umbrella based on the name of the
framework. Users can also specify this explicitly by using command line
options specifying the umbrella header by file path. There can be an
umbrella header per access level.
2024-03-27 12:34:21 -04: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
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
9f168591f3
[InstallAPI] Simplify & improve symbol printing for diagnostics (#85894)
* Defer mangling of symbols until an error is ready to report
* Pass around fewer parameters when reporting
2024-03-20 07:26:08 -07:00
Cyndy Ishida
936519f25c
[InstallAPI] Verify that declarations in headers map to exports found in dylib (#85348)
* This completes support for verifying every declaration found in a
header is discovered in the dylib. Diagnostics are reported for each
class for differences that are representable in TBD files.

* This patch also now captures unavailable attributes that depend on
target triples. This is needed for proper tbd file generation.
2024-03-19 18:36:46 -07:00
Cyndy Ishida
f2794ccede
[InstallAPI] Introduce Basic Verifier (#85106)
This adds basic support for calling the verifier on global declarations
that are expected to represent symbol exports. The driver now
exclusively uses this for knowing what symbols make up a TBD file.
Future patches will check against the dylib's symbol table.
2024-03-16 10:37:52 -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
b058b7e628
[InstallAPI] capture compatibility versions (#85261) 2024-03-14 11:24:16 -07:00
Cyndy Ishida
2c93beccdf
[InstallAPI] Collect C++ Decls (#84403)
This includes capturing symbols for global variables, functions,
classes, and templated defintions. As pre-determing what symbols are
generated from C++ declarations can be non-trivial, InstallAPI only
parses select declarations for symbol generation when parsing c++.

For example, installapi only looks at explicit template instantiations
or full template specializations, instead of general function or class
templates, for symbol emittion.
2024-03-11 09:02:43 -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
10ccde30e7
[InstallAPI] Collect symbols from ObjC Ivars (#83632) 2024-03-04 14:50:04 -08:00
Cyndy Ishida
17ede03a92
[InstallAPI] Collect frontend attributes & ObjCInterface decls (#83378)
* This patch introduces a container class, for holding records and
attributes only collectible from the clang frontend, which is a subclass
of `llvm::MachO::RecordsSlice`
* This also prunes out collecting declarations from headers that aren't
considered input to installapi.
* Uses these constructs for collecting global objective-c interfaces.
2024-03-01 14:56:20 -08:00
Cyndy Ishida
c6cbf81c84
[InstallAPI] Hookup Input files & basic ASTVisitor (#82552)
This patch takes in json files as input to determine that header files
to process, and in which order, to pass along for CC1 invocations. This
patch also includes an ASTVisitor to collect simple global variables.
2024-02-28 09:47:45 -08:00
Cyndy Ishida
bc841bb0f8 [clang] Rename installapi tests, NFC
* Reduces redundancy
2024-02-22 09:56:21 -08:00
Cyndy Ishida
0a518db99e
[InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action (#82293)
Installapi has important distinctions when compared to the clang driver,
so much that, it doesn't make much sense to try to integrate into it.

This patch partially reverts the CC1 action & driver support to replace
with its own driver as a clang tool.

For distribution, we could use `LLVM_TOOL_LLVM_DRIVER_BUILD` mechanism
for integrating the functionality into clang such that the toolchain
size is less impacted.
2024-02-21 09:39:31 -08:00
Cyndy Ishida
09e98950bf
[clang][InstallAPI] Introduce basic driver to write out tbd files (#81571)
This introduces a basic outline of installapi as a clang driver option.
It captures relevant information as cc1 args, which are common arguments
already passed to the linker to encode into TBD file outputs. This is
effectively an upstream for what already exists as `tapi installapi` in
Xcode toolchains, but directly in Clang. This patch does not handle any
AST traversing on input yet.

InstallAPI is broadly an operation that takes a series of header files
that represent a single dynamic library and generates a TBD file out of
it which represents all the linkable symbols and necessary attributes
for statically linking in clients. It is the linkable object in all
Apple SDKs and when building dylibs in Xcode. `clang -installapi` also
will support verification where it compares all the information recorded
for the TBD files against the already built binary, to catch possible
mismatches like when a declaration is missing a definition for an
exported symbol.
2024-02-13 18:52:11 -08:00