22 Commits

Author SHA1 Message Date
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
5bcd91058e [readtapi] Use ExitOnError instead of errorcodes for readlink wrapper
Silences: ` error C4716: 'read_link': must return a value` windows error
2024-02-03 10:02:16 -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
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
b64992a367
[readtapi] Cleanup usages of ExitOnError, NFCI (#76745) 2024-01-02 15:22:26 -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
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
142e567cf0
[readtapi] Cleanup printing command line options (#75106)
Also, add a version option.
2023-12-12 08:25:53 -08:00
Cyndy Ishida
86fa4b2c46
[readtapi] Swap anon namespaces in favor of annotating static, NFC (#75078) 2023-12-11 13:33:36 -08:00
Cyndy Ishida
e1f69b863d
[readtapi] Add Extract & Remove architecture functionality (#72657)
This adds functionality to tbd files similar to what `lipo -extract`
and `lipo -remove` does for binaries.
2023-11-27 14:24:04 -08:00
Cyndy Ishida
bc191ac376
[readtapi] Use consistent error handling diagnostics (#73419) 2023-11-26 11:08:55 -08:00
Cyndy Ishida
ae182dbb1d
[readtapi] Add Merge functionality (#72656)
Merge allows a user to merge different files (tbds for now or dylibs in
the future) to emit out a single tbd with all input contents. This does
require that all inputs represent the same library.
2023-11-17 12:26:04 -08:00
Cyndy Ishida
3b48a7a008
[readtapi] add optional --<option>"=" to some cli opts (#72426) 2023-11-15 15:32:36 -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
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
Nivetha Kuruparan
c3356ac3b9
[llvm-readtapi] Fix bad symlink with readtapi tool (#68835)
The Clang-AIX-Wyvern-Dev buildbot is currently failing at the set
directory permission due to a bad symlink caused by this
[commit](a54f31fabd).
This change is creating the additional symlink `readtapi ->
llvm-readtapi` which causes it to appear in
`/buildbot_worker/official-worker/clang-aix-dev/installdir`.

After some investigation, it looks like `readtapi` is the only tool that
is getting symlinked that is not guarded by the
`LLVM_INSTALL_BINUTILS_SYMLINKS` macro. For example:

1. `llvm/tools/llvm-objcopy/CMakeLists.txt`

```
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
  add_llvm_tool_symlink(objcopy llvm-objcopy)
endif()
```

2. `llvm/tools/llvm-dwp/CMakeLists.txt`
```
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
  add_llvm_tool_symlink(dwp llvm-dwp)
endif()
```
2023-10-12 10:34:05 -04:00
Cyndy Ishida
a54f31fabd
[llvm-readtapi] Add symlink to call readtapi (#67748) 2023-09-29 14:48:24 -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
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
Danila Kutenin
1094e2ebba [TextAPI] Make sortTargetValues strict weak ordering compliant
Second sorting was not following strict weak ordering as it
does not follow transitivity of equivalence property.

If you build llvm with libcxx at head as a standard library with -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK and -D_LIBCPP_ENABLE_DEBUG_MODE, then tests like llvm/test/tools/llvm-readtapi/compare-right-single-inline.test.test will fail

I don't have commit rights. Danila Kutenin kudanila@yandex.ru

Reviewed By: cishida

Differential Revision: https://reviews.llvm.org/D157958
2023-08-21 08:56:39 -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
5656d7971b [llvm][tapi-diff] Transition diff-tool to be more general purpose
This is the first of transition tapi-diff to be readtapi.
This tool will eventually replace functionality for Xcode's `xcrun tapi stubify` and
`xcrun tapi archive`.
This patch updates the tool name and is a minor refactor for the driver to handle more options.

Reviewed By: zixuw

Differential Revision: https://reviews.llvm.org/D153045
2023-07-31 09:32:26 -07:00