Skip to content

Commit 5b5ab80

Browse files
mcl0vinitcyndyishida
authored andcommitted
Reland "[llvm] llvm-tapi-diff"
This is relanding commit d1d36f7 . 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
1 parent 5fc2673 commit 5b5ab80

27 files changed

+1698
-3
lines changed

llvm/include/llvm/Object/TapiUniversal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class TapiUniversal : public Binary {
101101
return make_range(begin_objects(), end_objects());
102102
}
103103

104+
const MachO::InterfaceFile &getInterfaceFile() { return *ParsedFile; }
105+
104106
uint32_t getNumberOfObjects() const { return Libraries.size(); }
105107

106108
static bool classof(const Binary *v) { return v->isTapiUniversal(); }

llvm/include/llvm/TextAPI/Platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ PlatformKind mapToPlatformKind(const Triple &Target);
4040
PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
4141
StringRef getPlatformName(PlatformKind Platform);
4242
PlatformKind getPlatformFromName(StringRef Name);
43+
std::string getOSAndEnvironmentName(PlatformKind Platform,
44+
std::string Version = "");
4345

4446
} // end namespace MachO.
4547
} // end namespace llvm.

llvm/include/llvm/TextAPI/Symbol.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,17 @@ class Symbol {
105105
#endif
106106

107107
bool operator==(const Symbol &O) const {
108-
return (Kind == O.Kind) && (Name == O.Name) && (Targets == O.Targets) &&
109-
(Flags == O.Flags);
108+
return std::tie(Name, Kind, Targets, Flags) ==
109+
std::tie(O.Name, O.Kind, O.Targets, O.Flags);
110110
}
111111

112112
bool operator!=(const Symbol &O) const { return !(*this == O); }
113113

114+
bool operator<(const Symbol &O) const {
115+
return std::tie(Name, Kind, Targets, Flags) <
116+
std::tie(O.Name, O.Kind, O.Targets, O.Flags);
117+
}
118+
114119
private:
115120
StringRef Name;
116121
TargetList Targets;

llvm/include/llvm/TextAPI/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ inline bool operator!=(const Target &LHS, const Architecture &RHS) {
6060
PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
6161
ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
6262

63+
std::string getTargetTripleName(const Target &Targ);
64+
6365
raw_ostream &operator<<(raw_ostream &OS, const Target &Target);
6466

6567
} // namespace MachO

llvm/lib/TextAPI/Platform.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,34 @@ PlatformKind getPlatformFromName(StringRef Name) {
105105
.Default(PlatformKind::unknown);
106106
}
107107

108+
std::string getOSAndEnvironmentName(PlatformKind Platform,
109+
std::string Version) {
110+
switch (Platform) {
111+
case PlatformKind::unknown:
112+
return "darwin" + Version;
113+
case PlatformKind::macOS:
114+
return "macos" + Version;
115+
case PlatformKind::iOS:
116+
return "ios" + Version;
117+
case PlatformKind::tvOS:
118+
return "tvos" + Version;
119+
case PlatformKind::watchOS:
120+
return "watchos" + Version;
121+
case PlatformKind::bridgeOS:
122+
return "bridgeos" + Version;
123+
case PlatformKind::macCatalyst:
124+
return "ios" + Version + "-macabi";
125+
case PlatformKind::iOSSimulator:
126+
return "ios" + Version + "-simulator";
127+
case PlatformKind::tvOSSimulator:
128+
return "tvos" + Version + "-simulator";
129+
case PlatformKind::watchOSSimulator:
130+
return "watchos" + Version + "-simulator";
131+
case PlatformKind::driverKit:
132+
return "driverkit" + Version;
133+
}
134+
llvm_unreachable("Unknown llvm::MachO::PlatformKind enum");
135+
}
136+
108137
} // end namespace MachO.
109138
} // end namespace llvm.

llvm/lib/TextAPI/Target.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@ ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets) {
7272
return Result;
7373
}
7474

75+
std::string getTargetTripleName(const Target &Targ) {
76+
return (getArchitectureName(Targ.Arch) + "-apple-" +
77+
getOSAndEnvironmentName(Targ.Platform))
78+
.str();
79+
}
80+
7581
} // end namespace MachO.
7682
} // end namespace llvm.

llvm/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ set(LLVM_TEST_DEPENDS
116116
llvm-strip
117117
llvm-symbolizer
118118
llvm-tblgen
119+
llvm-tapi-diff
119120
llvm-undname
120121
llvm-windres
121122
llvm-xray

llvm/test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def get_asan_rtlib():
164164
'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', 'llvm-otool',
165165
'llvm-pdbutil', 'llvm-profdata', 'llvm-profgen', 'llvm-ranlib', 'llvm-rc', 'llvm-readelf',
166166
'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings',
167-
'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-windres',
167+
'llvm-strip', 'llvm-tblgen', 'llvm-tapi-diff', 'llvm-undname', 'llvm-windres',
168168
'llvm-c-test', 'llvm-cxxfilt',
169169
'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder',
170170
'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
--- !mach-o
2+
FileHeader:
3+
magic: 0xFEEDFACF
4+
cputype: 0x1000007
5+
cpusubtype: 0x3
6+
filetype: 0x6
7+
ncmds: 13
8+
sizeofcmds: 584
9+
flags: 0x100085
10+
reserved: 0x0
11+
LoadCommands:
12+
- cmd: LC_SEGMENT_64
13+
cmdsize: 152
14+
segname: __TEXT
15+
vmaddr: 0
16+
vmsize: 4096
17+
fileoff: 0
18+
filesize: 4096
19+
maxprot: 7
20+
initprot: 5
21+
nsects: 1
22+
flags: 0
23+
Sections:
24+
- sectname: __text
25+
segname: __TEXT
26+
addr: 0x1000
27+
size: 0
28+
offset: 0x1000
29+
align: 0
30+
reloff: 0x0
31+
nreloc: 0
32+
flags: 0x80000400
33+
reserved1: 0x0
34+
reserved2: 0x0
35+
reserved3: 0x0
36+
content: ''
37+
- cmd: LC_SEGMENT_64
38+
cmdsize: 72
39+
segname: __LINKEDIT
40+
vmaddr: 4096
41+
vmsize: 4096
42+
fileoff: 4096
43+
filesize: 112
44+
maxprot: 7
45+
initprot: 1
46+
nsects: 0
47+
flags: 0
48+
- cmd: LC_ID_DYLIB
49+
cmdsize: 48
50+
dylib:
51+
name: 24
52+
timestamp: 1
53+
current_version: 65536
54+
compatibility_version: 65536
55+
PayloadString: macho-no-exports.dylib
56+
ZeroPadBytes: 2
57+
- cmd: LC_DYLD_INFO_ONLY
58+
cmdsize: 48
59+
rebase_off: 0
60+
rebase_size: 0
61+
bind_off: 0
62+
bind_size: 0
63+
weak_bind_off: 0
64+
weak_bind_size: 0
65+
lazy_bind_off: 0
66+
lazy_bind_size: 0
67+
export_off: 0
68+
export_size: 0
69+
- cmd: LC_SYMTAB
70+
cmdsize: 24
71+
symoff: 4168
72+
nsyms: 1
73+
stroff: 4184
74+
strsize: 24
75+
- cmd: LC_DYSYMTAB
76+
cmdsize: 80
77+
ilocalsym: 0
78+
nlocalsym: 0
79+
iextdefsym: 0
80+
nextdefsym: 0
81+
iundefsym: 0
82+
nundefsym: 1
83+
tocoff: 0
84+
ntoc: 0
85+
modtaboff: 0
86+
nmodtab: 0
87+
extrefsymoff: 0
88+
nextrefsyms: 0
89+
indirectsymoff: 0
90+
nindirectsyms: 0
91+
extreloff: 0
92+
nextrel: 0
93+
locreloff: 0
94+
nlocrel: 0
95+
- cmd: LC_UUID
96+
cmdsize: 24
97+
uuid: A24CBA21-865D-372D-B267-4964F4ADCDFC
98+
- cmd: LC_VERSION_MIN_MACOSX
99+
cmdsize: 16
100+
version: 657920
101+
sdk: 657920
102+
- cmd: LC_SOURCE_VERSION
103+
cmdsize: 16
104+
version: 0
105+
- cmd: LC_LOAD_DYLIB
106+
cmdsize: 56
107+
dylib:
108+
name: 24
109+
timestamp: 2
110+
current_version: 79495168
111+
compatibility_version: 65536
112+
PayloadString: '/usr/lib/libSystem.B.dylib'
113+
ZeroPadBytes: 6
114+
- cmd: LC_FUNCTION_STARTS
115+
cmdsize: 16
116+
dataoff: 4096
117+
datasize: 8
118+
- cmd: LC_DATA_IN_CODE
119+
cmdsize: 16
120+
dataoff: 4104
121+
datasize: 0
122+
- cmd: LC_DYLIB_CODE_SIGN_DRS
123+
cmdsize: 16
124+
dataoff: 4104
125+
datasize: 64
126+
LinkEditData:
127+
NameList:
128+
- n_strx: 2
129+
n_type: 0x1
130+
n_sect: 0
131+
n_desc: 256
132+
n_value: 0
133+
StringTable:
134+
- ' '
135+
- dyld_stub_binder
136+
- ''
137+
- ''
138+
- ''
139+
- ''
140+
- ''
141+
...
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--- !tapi-tbd
2+
tbd-version: 4
3+
targets: [ i386-macos, x86_64-macos, x86_64-ios ]
4+
uuids:
5+
- target: i386-macos
6+
value: 00000000-0000-0000-0000-000000000000
7+
- target: x86_64-macos
8+
value: 11111111-1111-1111-1111-111111111111
9+
- target: x86_64-ios
10+
value: 11111111-1111-1111-1111-111111111111
11+
flags: [ flat_namespace, installapi ]
12+
install-name: Umbrella.framework/Umbrella
13+
current-version: 1.2.3
14+
compatibility-version: 1.2
15+
swift-abi-version: 5
16+
parent-umbrella:
17+
- targets: [ i386-macos, x86_64-macos, x86_64-ios ]
18+
umbrella: System
19+
allowable-clients:
20+
- targets: [ i386-macos, x86_64-macos, x86_64-ios ]
21+
clients: [ ClientA ]
22+
exports:
23+
- targets: [ i386-macos ]
24+
symbols: [ _symA ]
25+
objc-classes: []
26+
objc-eh-types: []
27+
objc-ivars: []
28+
weak-symbols: []
29+
thread-local-symbols: []
30+
- targets: [ x86_64-ios ]
31+
symbols: [_symB]
32+
- targets: [ x86_64-macos, x86_64-ios ]
33+
symbols: [_symAB]
34+
reexports:
35+
- targets: [ i386-macos ]
36+
symbols: [_symC]
37+
objc-classes: []
38+
objc-eh-types: []
39+
objc-ivars: []
40+
weak-symbols: []
41+
thread-local-symbols: []
42+
undefineds:
43+
- targets: [ i386-macos ]
44+
symbols: [ _symD ]
45+
objc-classes: []
46+
objc-eh-types: []
47+
objc-ivars: []
48+
weak-symbols: []
49+
thread-local-symbols: []

0 commit comments

Comments
 (0)