20 Commits

Author SHA1 Message Date
Chandler Carruth
dd647e3e60
Rework the Option library to reduce dynamic relocations (#119198)
Apologies for the large change, I looked for ways to break this up and
all of the ones I saw added real complexity. This change focuses on the
option's prefixed names and the array of prefixes. These are present in
every option and the dominant source of dynamic relocations for PIE or
PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of
them for the Clang driver which has a huge number of options.

This PR addresses this by building a string table and a prefixes table
that can be referenced with indices rather than pointers that require
dynamic relocations. This removes almost 7k dynmaic relocations from the
`clang` binary, roughly 8% of the remaining dynmaic relocations outside
of vtables. For busy-boxing use cases where many different option tables
are linked into the same binary, the savings add up a bit more.

The string table is a straightforward mechanism, but the prefixes
required some subtlety. They are encoded in a Pascal-string fashion with
a size followed by a sequence of offsets. This works relatively well for
the small realistic prefixes arrays in use.

Lots of code has to change in order to land this though: both all the
option library code has to be updated to use the string table and
prefixes table, and all the users of the options library have to be
updated to correctly instantiate the objects.

Some follow-up patches in the works to provide an abstraction for this
style of code, and to start using the same technique for some of the
other strings here now that the infrastructure is in place.
2024-12-11 15:44:44 -08:00
Cyndy Ishida
2d48489cc3
[Clang][Darwin] Introduce SubFrameworks as a SDK default location (#115048)
* Have clang always append & pass System/Library/SubFrameworks when determining default sdk search paths.
* Teach clang-installapi to traverse there for framework input.
* Teach llvm-readtapi that the library files (TBD or binary) in there should be considered private.

resolves: rdar://137457006
2024-11-15 09:27:08 -08:00
Kazu Hirata
61a286ac08
[tools] Don't call StringRef::str() when calling StringMap::find (NFC) (#113119)
StringMap::find takes StringRef.  We don't need to create an instance
of std::string from StringRef only to convert it right back to
StringRef.
2024-10-21 06:50:34 -07:00
Kazu Hirata
a99bf0f6c9
[llvm-readtapi] Simplify code with StringMap::operator[] (NFC) (#112824) 2024-10-18 08:40:05 -07:00
Cyndy Ishida
5134048066
[readtapi] Add option to ignore architecture slices to ignore (#110615)
For qualification purposes, it's helpful to ignore certain slices that
can be expected to differ.
2024-10-01 14:31:22 -07:00
Abhina Sree
74dcf0b595
[SystemZ][z/OS] Open text files in text mode (#109972)
This patch continues the work that was started here
https://reviews.llvm.org/D99426 to correctly open text files in text
mode.
2024-09-25 10:49:45 -04:00
Fangrui Song
2c0a185e99 Remove unneeded LLVM_FALLTHROUGH. NFC 2024-04-25 13:21:46 -07: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
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
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
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
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