Commit d58809f
committed
[WIP] Relative VTables for Rust
This is a WIP patch for implementing
rust-lang/compiler-team#903. It adds a new
unstable flag `-Zexperimental-relative-rust-abi-vtables` that makes
vtables PIC-friendly. This is only supported for LLVM codegen and
not supported for other backends.
Early feedback on this is welcome. I'm not sure if how I implemented it
is the best way of doing so since much of the actual vtable emission is
heavily done during LLVM codegen. That is, the vtable to MIR looks like
a normal table of pointers and byte arrays and I really only make the
vtables relative on the codegen level.
Locally, I can build the stage 1 compiler and runtimes with relative
vtables, but I couldn't figure out how to tell the build system to only
build stage 1 binaries with this flag, so I work around this by
unconditionally enabling relative vtables in rustc. The end goal I think
we'd like is either something akin to multilibs in clang where the
compiler chooses which runtimes to use based off compilation flags, or
binding this ABI to the target and have it be part of the default ABI
for that target (just like how relative vtables are the default for
Fuchsia in C++ with Clang). I think the later is what target modifiers
do (#136966).
Action Items:
- I'm still experimenting with building Fuchsia with this to assert it
works e2e and I still need to do some measurements to see if this is
still worth pursuing.
- More work will still be needed to ensure the correct relative
intrinsics are emitted with CFI and LTO. Rn I'm experimenting on a normal
build.1 parent 213d946 commit d58809f
File tree
19 files changed
+452
-48
lines changed- compiler
- rustc_abi/src
- rustc_codegen_llvm/src
- llvm
- rustc_codegen_ssa/src
- mir
- traits
- rustc_llvm/llvm-wrapper
- rustc_session/src
- rustc_ty_utils/src
- src/doc/rustc/src/codegen-options
- tests/codegen-llvm/relative-vtables
19 files changed
+452
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
819 | 819 | | |
820 | 820 | | |
821 | 821 | | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
822 | 830 | | |
823 | 831 | | |
824 | 832 | | |
| |||
906 | 914 | | |
907 | 915 | | |
908 | 916 | | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
909 | 936 | | |
910 | 937 | | |
911 | 938 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
617 | 621 | | |
618 | 622 | | |
619 | 623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
| |||
320 | 324 | | |
321 | 325 | | |
322 | 326 | | |
323 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
324 | 333 | | |
325 | 334 | | |
326 | 335 | | |
| |||
354 | 363 | | |
355 | 364 | | |
356 | 365 | | |
357 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
358 | 397 | | |
359 | 398 | | |
360 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| 57 | + | |
54 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
74 | 81 | | |
75 | 82 | | |
76 | 83 | | |
77 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
78 | 121 | | |
79 | 122 | | |
80 | 123 | | |
| |||
92 | 135 | | |
93 | 136 | | |
94 | 137 | | |
95 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
96 | 145 | | |
97 | 146 | | |
98 | 147 | | |
| |||
108 | 157 | | |
109 | 158 | | |
110 | 159 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
119 | 188 | | |
120 | 189 | | |
121 | 190 | | |
122 | 191 | | |
123 | 192 | | |
124 | 193 | | |
125 | 194 | | |
126 | | - | |
| 195 | + | |
127 | 196 | | |
128 | 197 | | |
129 | 198 | | |
130 | 199 | | |
131 | 200 | | |
132 | 201 | | |
133 | 202 | | |
134 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
135 | 210 | | |
136 | 211 | | |
137 | 212 | | |
138 | 213 | | |
139 | 214 | | |
140 | 215 | | |
141 | 216 | | |
142 | | - | |
| 217 | + | |
143 | 218 | | |
144 | 219 | | |
145 | 220 | | |
| |||
232 | 307 | | |
233 | 308 | | |
234 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
235 | 321 | | |
236 | 322 | | |
237 | 323 | | |
238 | 324 | | |
239 | | - | |
| 325 | + | |
240 | 326 | | |
241 | 327 | | |
242 | 328 | | |
243 | 329 | | |
244 | 330 | | |
245 | | - | |
| 331 | + | |
246 | 332 | | |
247 | | - | |
248 | 333 | | |
249 | 334 | | |
250 | 335 | | |
| |||
277 | 362 | | |
278 | 363 | | |
279 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
280 | 374 | | |
281 | 375 | | |
282 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1169 | 1169 | | |
1170 | 1170 | | |
1171 | 1171 | | |
| 1172 | + | |
| 1173 | + | |
1172 | 1174 | | |
1173 | 1175 | | |
1174 | 1176 | | |
| |||
1198 | 1200 | | |
1199 | 1201 | | |
1200 | 1202 | | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1201 | 1210 | | |
1202 | 1211 | | |
1203 | 1212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
| |||
0 commit comments