115 Commits

Author SHA1 Message Date
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
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
Benjamin Kramer
6e55370b81 Hide some implementation details so they can't cause ODR conflicts. NFC. 2023-07-14 15:54:04 +02:00
Cyndy Ishida
e63e536044 [TextAPI] add osx to possible string to platform input 2023-06-14 16:31:26 -07:00
Cyndy Ishida
7de8cd617b [llvm][TextAPI] only compare deployment version for InterfaceFile. 2023-04-01 08:38:30 -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
Simon Pilgrim
35e21725e2 [TextAPI] Use const auto& in foreach loop to avoid pass-by-value static analyzer warnings. NFCI. 2023-02-26 15:43:03 +00:00
Cyndy Ishida
bc85cf1687 [TextAPI] Add support for TBDv5 Files to nm & tapi-diff
This includes handling of new attributes for symbols & rpath.
In the event that an older format file is compared to tbd_v5, ignore these new attributes.

Reviewed By: ributzka

Differential Revision: https://reviews.llvm.org/D144529
2023-02-22 19:39:26 -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
4be17641b0 [TextAPI] wrap returned Errors in std::move 2023-02-17 16:16:12 -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
Archibald Elliott
62c7f035b4 [NFC][TargetParser] Remove llvm/ADT/Triple.h
I also ran `git clang-format` to get the headers in the right order for
the new location, which has changed the order of other headers in two
files.
2023-02-07 12:39:46 +00:00
Archibald Elliott
f09cf34d00 [Support] Move TargetParsers to new component
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
  component into a new LLVM Component called "TargetParser". This
  potentially enables using tablegen to maintain this information, as
  is shown in https://reviews.llvm.org/D137517. This cannot currently
  be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
  information in the TargetParser:
  - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
    the current Host machine for info about it, primarily to support
    getting the host triple, but also for `-mcpu=native` support in e.g.
    Clang. This is fairly tightly intertwined with the information in
    `X86TargetParser.h`, so keeping them in the same component makes
    sense.
  - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
    the target triple parser and representation. This is very intertwined
    with the Arm target parser, because the arm architecture version
    appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.

And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM

Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.

If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.

Differential Revision: https://reviews.llvm.org/D137838
2022-12-20 11:05:50 +00:00
Cyndy Ishida
e6cdb00315 [llvm][TextAPI] add driverkit as supported platform for older tbd
versions

 It looks like being able to write it was added, but missed the ability
  to read it.
2022-09-19 15:08:29 -07:00
Fangrui Song
de9d80c1c5 [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-08-08 11:24:15 -07:00
serge-sans-paille
b48e378218 Cleanup LLVMTextAPI headers
Based on the output of iwyu. A full rebuild of llvm-project doesn't exhibit any
significant false dependencies.

The impact on preprocessed output is larger than expected, given the small
amount of changes

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/TextAPI/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 635319
After: 643716

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
2022-01-26 14:21:25 +01:00
Simon Pilgrim
fced2744d3 Fix MSVC "not all control paths return a value" warnings. NFC. 2022-01-13 17:44:10 +00: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
Kazu Hirata
cfc7402419 [llvm] Use drop_begin (NFC) 2021-09-16 08:46:26 -07:00
Sam Powell
5b5ab80e31 Reland "[llvm] llvm-tapi-diff"
This is relanding commit d1d36f7ad2ae82bea8a6fcc40d6c42a72e21f096 .
This patch additionally addresses failures found in buildbots due to unstable build ordering & post review comments.

This patch introduces a new tool, llvm-tapi-diff, that compares and returns the diff of two TBD files.

Reviewed By: ributzka, JDevlieghere

Differential Revision: https://reviews.llvm.org/D101835
2021-06-09 21:17:34 -07:00
Cyndy Ishida
e7b755ecb1 Revert "Reland "[llvm] llvm-tapi-diff""
This reverts commit 20126c9fd4afe2fe11510becccaa769332da302f.
The sorting fixes failed to have stable output on different platforms.
2021-06-09 13:48:09 -07:00
Sam Powell
20126c9fd4 Reland "[llvm] llvm-tapi-diff"
This is relanding commit d1d36f7ad2ae82bea8a6fcc40d6c42a72e21f096 .
This patch additionally addresses failures found in buildbots & post review comments.

This patch introduces a new tool, llvm-tapi-diff, that compares and returns the diff of two TBD files.

Reviewed By: ributzka, JDevlieghere

Differential Revision: https://reviews.llvm.org/D101835
2021-06-09 10:35:41 -07:00
Cyndy Ishida
5337c7550d Revert "[llvm] llvm-tapi-diff"
This reverts commit d1d36f7ad2ae82bea8a6fcc40d6c42a72e21f096.
Reverting this patch to investigate linux bot failures
 + fix with author offline
2021-06-03 21:10:51 -07:00
Sam Powell
d1d36f7ad2 [llvm] llvm-tapi-diff
This patch introduces a new tool, llvm-tapi-diff, that compares and returns the diff of two TBD files.

Reviewed By: ributzka, JDevlieghere

Differential Revision: https://reviews.llvm.org/D101835
2021-06-03 11:38:00 -07:00
Sam Powell
cba508fb67 [TextAPI] Reformat llvm_unreachable message
Change llvm_unreachable message from "Unknown llvm.MachO.PlatformKind
enum" to "Unknown llvm::MachO::PlatformKind enum".

Differential revision: https://reviews.llvm.org/D102250
2021-05-11 09:59:26 -07: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