xref: /llvm-project/clang/test/InstallAPI/rpath.test (revision 515269b0ac0e061731eb5546c44083bf771db4d8)
1; RUN: rm -rf %t
2; RUN: split-file %s %t
3; RUN: yaml2obj %t/RPath.yaml -o %t/RPath
4
5; RUN: clang-installapi --filetype=tbd-v5 \
6; RUN: -target arm64-apple-macos13.0 -target x86_64-apple-macos13.0 \
7; RUN: -install_name @rpath/Frameworks/RPath.framework/Versions/A/RPath \
8; RUN: -current_version 1 -compatibility_version 1 \
9; RUN: --extra-public-header=%t/public.h \
10; RUN: -o %t/RPath_warnings.tbd \
11; RUN: --verify-against=%t/RPath \
12; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s --check-prefix=MISSING
13; RUN: llvm-readtapi --compare %t/RPath_warnings.tbd %t/expected_no_rpaths.tbd
14
15; MISSING-DAG: warning: runpath search paths missing from installAPI option: '@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]'
16; MISSING-DAG: warning: runpath search paths missing from installAPI option: '@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]'
17
18; RUN: clang-installapi --filetype=tbd-v5 \
19; RUN: -target arm64-apple-macos13.0 -target x86_64-apple-macos13.0 \
20; RUN: -install_name @rpath/Frameworks/RPath.framework/Versions/A/RPath \
21; RUN: -current_version 1 -compatibility_version 1 \
22; RUN: --extra-public-header=%t/public.h \
23; RUN: -Xarch_arm64 -rpath @loader_path/../../../SharedFrameworks/ \
24; RUN: -o %t/RPath_Xarch.tbd \
25; RUN: --verify-against=%t/RPath \
26; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s --check-prefix=XARCH
27; RUN: llvm-readtapi --compare %t/RPath_Xarch.tbd %t/expected_xarch_rpaths.tbd
28
29; XARCH: warning: runpath search paths do not match: '@loader_path/../../../SharedFrameworks/ [ arm64 ]' (provided) vs '@loader_path/../../../SharedFrameworks/ [ x86_64 arm64 ]'
30; XARCH: warning: runpath search paths missing from installAPI option: '@loader_path/../../PrivateFrameworks/ [ x86_64 arm64 ]'
31
32; RUN: clang-installapi --filetype=tbd-v5 \
33; RUN: -target arm64-apple-macos13.0 -target x86_64-apple-macos13.0 \
34; RUN: -install_name @rpath/Frameworks/RPath.framework/Versions/A/RPath \
35; RUN: -current_version 1 -compatibility_version 1 \
36; RUN: --extra-public-header=%t/public.h \
37; RUN: -rpath @loader_path/../../../SharedFrameworks/ \
38; RUN: -rpath @loader_path/../../PrivateFrameworks/ \
39; RUN: --verify-against=%t/RPath --verify-mode=Pedantic \
40; RUN: -o %t/RPath.tbd 2>&1 | FileCheck -allow-empty %s
41; RUN: llvm-readtapi --compare %t/RPath.tbd %t/expected.tbd
42
43CHECK-NOT: error
44CHECK-NOT: warning
45
46;--- public.h
47extern int publicGlobalVariable;
48
49;--- expected.tbd
50{
51  "main_library": {
52    "exported_symbols": [
53      {
54        "data": {
55          "global": [
56            "_publicGlobalVariable"
57          ]
58        }
59      }
60    ],
61    "flags": [
62      {
63        "attributes": [
64          "not_app_extension_safe"
65        ]
66      }
67    ],
68    "install_names": [
69      {
70        "name": "@rpath/Frameworks/RPath.framework/Versions/A/RPath"
71      }
72    ],
73    "rpaths": [
74      {
75        "paths": [
76          "@loader_path/../../../SharedFrameworks/",
77          "@loader_path/../../PrivateFrameworks/"
78        ]
79      }
80    ],
81    "target_info": [
82      {
83        "min_deployment": "13.0",
84        "target": "x86_64-macos"
85      },
86      {
87        "min_deployment": "13.0",
88        "target": "arm64-macos"
89      }
90    ]
91  },
92  "tapi_tbd_version": 5
93}
94
95;--- expected_no_rpaths.tbd
96{
97  "main_library": {
98    "exported_symbols": [
99      {
100        "data": {
101          "global": [
102            "_publicGlobalVariable"
103          ]
104        }
105      }
106    ],
107    "flags": [
108      {
109        "attributes": [
110          "not_app_extension_safe"
111        ]
112      }
113    ],
114    "install_names": [
115      {
116        "name": "@rpath/Frameworks/RPath.framework/Versions/A/RPath"
117      }
118    ],
119    "target_info": [
120      {
121        "min_deployment": "13.0",
122        "target": "x86_64-macos"
123      },
124      {
125        "min_deployment": "13.0",
126        "target": "arm64-macos"
127      }
128    ]
129  },
130  "tapi_tbd_version": 5
131}
132
133;--- expected_xarch_rpaths.tbd
134{
135  "main_library": {
136    "exported_symbols": [
137      {
138        "data": {
139          "global": [
140            "_publicGlobalVariable"
141          ]
142        }
143      }
144    ],
145    "flags": [
146      {
147        "attributes": [
148          "not_app_extension_safe"
149        ]
150      }
151    ],
152    "install_names": [
153      {
154        "name": "@rpath/Frameworks/RPath.framework/Versions/A/RPath"
155      }
156    ],
157    "rpaths": [
158      {
159        "paths": [
160          "@loader_path/../../../SharedFrameworks/"
161        ],
162        "targets": [
163          "arm64-macos"
164        ]
165      }
166    ],
167    "target_info": [
168      {
169        "min_deployment": "13.0",
170        "target": "x86_64-macos"
171      },
172      {
173        "min_deployment": "13.0",
174        "target": "arm64-macos"
175      }
176    ]
177  },
178  "tapi_tbd_version": 5
179}
180
181;--- RPath.yaml
182--- !fat-mach-o
183FatHeader:
184  magic:           0xCAFEBABE
185  nfat_arch:       2
186FatArchs:
187  - cputype:         0x1000007
188    cpusubtype:      0x3
189    offset:          0x1000
190    size:            12408
191    align:           12
192  - cputype:         0x100000C
193    cpusubtype:      0x0
194    offset:          0x8000
195    size:            33312
196    align:           14
197Slices:
198  - !mach-o
199    FileHeader:
200      magic:           0xFEEDFACF
201      cputype:         0x1000007
202      cpusubtype:      0x3
203      filetype:        0x6
204      ncmds:           16
205      sizeofcmds:      1072
206      flags:           0x100085
207      reserved:        0x0
208    LoadCommands:
209      - cmd:             LC_SEGMENT_64
210        cmdsize:         152
211        segname:         __TEXT
212        vmaddr:          0
213        vmsize:          8192
214        fileoff:         0
215        filesize:        8192
216        maxprot:         5
217        initprot:        5
218        nsects:          1
219        flags:           0
220        Sections:
221          - sectname:        __text
222            segname:         __TEXT
223            addr:            0x1050
224            size:            0
225            offset:          0x1050
226            align:           0
227            reloff:          0x0
228            nreloc:          0
229            flags:           0x80000000
230            reserved1:       0x0
231            reserved2:       0x0
232            reserved3:       0x0
233            content:         ''
234      - cmd:             LC_SEGMENT_64
235        cmdsize:         152
236        segname:         __DATA_CONST
237        vmaddr:          8192
238        vmsize:          4096
239        fileoff:         8192
240        filesize:        4096
241        maxprot:         3
242        initprot:        3
243        nsects:          1
244        flags:           16
245        Sections:
246          - sectname:        __objc_imageinfo
247            segname:         __DATA_CONST
248            addr:            0x2000
249            size:            8
250            offset:          0x2000
251            align:           0
252            reloff:          0x0
253            nreloc:          0
254            flags:           0x0
255            reserved1:       0x0
256            reserved2:       0x0
257            reserved3:       0x0
258            content:         '0000000040000000'
259      - cmd:             LC_SEGMENT_64
260        cmdsize:         152
261        segname:         __DATA
262        vmaddr:          12288
263        vmsize:          4096
264        fileoff:         12288
265        filesize:        0
266        maxprot:         3
267        initprot:        3
268        nsects:          1
269        flags:           0
270        Sections:
271          - sectname:        __common
272            segname:         __DATA
273            addr:            0x3000
274            size:            4
275            offset:          0x0
276            align:           2
277            reloff:          0x0
278            nreloc:          0
279            flags:           0x1
280            reserved1:       0x0
281            reserved2:       0x0
282            reserved3:       0x0
283      - cmd:             LC_SEGMENT_64
284        cmdsize:         72
285        segname:         __LINKEDIT
286        vmaddr:          16384
287        vmsize:          120
288        fileoff:         12288
289        filesize:        120
290        maxprot:         1
291        initprot:        1
292        nsects:          0
293        flags:           0
294      - cmd:             LC_DYLD_INFO_ONLY
295        cmdsize:         48
296        rebase_off:      0
297        rebase_size:     0
298        bind_off:        0
299        bind_size:       0
300        weak_bind_off:   0
301        weak_bind_size:  0
302        lazy_bind_off:   0
303        lazy_bind_size:  0
304        export_off:      12288
305        export_size:     32
306      - cmd:             LC_SYMTAB
307        cmdsize:         24
308        symoff:          12328
309        nsyms:           2
310        stroff:          12360
311        strsize:         48
312      - cmd:             LC_DYSYMTAB
313        cmdsize:         80
314        ilocalsym:       0
315        nlocalsym:       0
316        iextdefsym:      0
317        nextdefsym:      1
318        iundefsym:       1
319        nundefsym:       1
320        tocoff:          0
321        ntoc:            0
322        modtaboff:       0
323        nmodtab:         0
324        extrefsymoff:    0
325        nextrefsyms:     0
326        indirectsymoff:  0
327        nindirectsyms:   0
328        extreloff:       0
329        nextrel:         0
330        locreloff:       0
331        nlocrel:         0
332      - cmd:             LC_RPATH
333        cmdsize:         56
334        path:            12
335        Content:         '@loader_path/../../../SharedFrameworks/'
336        ZeroPadBytes:    5
337      - cmd:             LC_RPATH
338        cmdsize:         56
339        path:            12
340        Content:         '@loader_path/../../PrivateFrameworks/'
341        ZeroPadBytes:    7
342      - cmd:             LC_ID_DYLIB
343        cmdsize:         80
344        dylib:
345          name:            24
346          timestamp:       0
347          current_version: 65536
348          compatibility_version: 65536
349        Content:         '@rpath/Frameworks/RPath.framework/Versions/A/RPath'
350        ZeroPadBytes:    6
351      - cmd:             LC_UUID
352        cmdsize:         24
353        uuid:            4C4C4489-5555-3144-A1D1-28C8EA66FB24
354      - cmd:             LC_BUILD_VERSION
355        cmdsize:         32
356        platform:        1
357        minos:           851968
358        sdk:             983040
359        ntools:          1
360        Tools:
361          - tool:            4
362            version:         1245184
363      - cmd:             LC_LOAD_DYLIB
364        cmdsize:         56
365        dylib:
366          name:            24
367          timestamp:       0
368          current_version: 14942208
369          compatibility_version: 65536
370        Content:         '/usr/lib/libobjc.A.dylib'
371        ZeroPadBytes:    8
372      - cmd:             LC_LOAD_DYLIB
373        cmdsize:         56
374        dylib:
375          name:            24
376          timestamp:       0
377          current_version: 88539136
378          compatibility_version: 65536
379        Content:         '/usr/lib/libSystem.B.dylib'
380        ZeroPadBytes:    6
381      - cmd:             LC_FUNCTION_STARTS
382        cmdsize:         16
383        dataoff:         12320
384        datasize:        8
385      - cmd:             LC_DATA_IN_CODE
386        cmdsize:         16
387        dataoff:         12328
388        datasize:        0
389    LinkEditData:
390      ExportTrie:
391        TerminalSize:    0
392        NodeOffset:      0
393        Name:            ''
394        Flags:           0x0
395        Address:         0x0
396        Other:           0x0
397        ImportName:      ''
398        Children:
399          - TerminalSize:    3
400            NodeOffset:      25
401            Name:            _publicGlobalVariable
402            Flags:           0x0
403            Address:         0x3000
404            Other:           0x0
405            ImportName:      ''
406      NameList:
407        - n_strx:          2
408          n_type:          0xF
409          n_sect:          3
410          n_desc:          0
411          n_value:         12288
412        - n_strx:          24
413          n_type:          0x1
414          n_sect:          0
415          n_desc:          512
416          n_value:         0
417      StringTable:
418        - ' '
419        - _publicGlobalVariable
420        - dyld_stub_binder
421        - ''
422        - ''
423        - ''
424        - ''
425        - ''
426        - ''
427        - ''
428  - !mach-o
429    FileHeader:
430      magic:           0xFEEDFACF
431      cputype:         0x100000C
432      cpusubtype:      0x0
433      filetype:        0x6
434      ncmds:           17
435      sizeofcmds:      1088
436      flags:           0x100085
437      reserved:        0x0
438    LoadCommands:
439      - cmd:             LC_SEGMENT_64
440        cmdsize:         152
441        segname:         __TEXT
442        vmaddr:          0
443        vmsize:          16384
444        fileoff:         0
445        filesize:        16384
446        maxprot:         5
447        initprot:        5
448        nsects:          1
449        flags:           0
450        Sections:
451          - sectname:        __text
452            segname:         __TEXT
453            addr:            0x1060
454            size:            0
455            offset:          0x1060
456            align:           0
457            reloff:          0x0
458            nreloc:          0
459            flags:           0x80000000
460            reserved1:       0x0
461            reserved2:       0x0
462            reserved3:       0x0
463            content:         ''
464      - cmd:             LC_SEGMENT_64
465        cmdsize:         152
466        segname:         __DATA_CONST
467        vmaddr:          16384
468        vmsize:          16384
469        fileoff:         16384
470        filesize:        16384
471        maxprot:         3
472        initprot:        3
473        nsects:          1
474        flags:           16
475        Sections:
476          - sectname:        __objc_imageinfo
477            segname:         __DATA_CONST
478            addr:            0x4000
479            size:            8
480            offset:          0x4000
481            align:           0
482            reloff:          0x0
483            nreloc:          0
484            flags:           0x0
485            reserved1:       0x0
486            reserved2:       0x0
487            reserved3:       0x0
488            content:         '0000000040000000'
489      - cmd:             LC_SEGMENT_64
490        cmdsize:         152
491        segname:         __DATA
492        vmaddr:          32768
493        vmsize:          16384
494        fileoff:         32768
495        filesize:        0
496        maxprot:         3
497        initprot:        3
498        nsects:          1
499        flags:           0
500        Sections:
501          - sectname:        __common
502            segname:         __DATA
503            addr:            0x8000
504            size:            4
505            offset:          0x0
506            align:           2
507            reloff:          0x0
508            nreloc:          0
509            flags:           0x1
510            reserved1:       0x0
511            reserved2:       0x0
512            reserved3:       0x0
513      - cmd:             LC_SEGMENT_64
514        cmdsize:         72
515        segname:         __LINKEDIT
516        vmaddr:          49152
517        vmsize:          544
518        fileoff:         32768
519        filesize:        544
520        maxprot:         1
521        initprot:        1
522        nsects:          0
523        flags:           0
524      - cmd:             LC_DYLD_INFO_ONLY
525        cmdsize:         48
526        rebase_off:      0
527        rebase_size:     0
528        bind_off:        0
529        bind_size:       0
530        weak_bind_off:   0
531        weak_bind_size:  0
532        lazy_bind_off:   0
533        lazy_bind_size:  0
534        export_off:      32768
535        export_size:     32
536      - cmd:             LC_SYMTAB
537        cmdsize:         24
538        symoff:          32808
539        nsyms:           2
540        stroff:          32840
541        strsize:         48
542      - cmd:             LC_DYSYMTAB
543        cmdsize:         80
544        ilocalsym:       0
545        nlocalsym:       0
546        iextdefsym:      0
547        nextdefsym:      1
548        iundefsym:       1
549        nundefsym:       1
550        tocoff:          0
551        ntoc:            0
552        modtaboff:       0
553        nmodtab:         0
554        extrefsymoff:    0
555        nextrefsyms:     0
556        indirectsymoff:  0
557        nindirectsyms:   0
558        extreloff:       0
559        nextrel:         0
560        locreloff:       0
561        nlocrel:         0
562      - cmd:             LC_RPATH
563        cmdsize:         56
564        path:            12
565        Content:         '@loader_path/../../../SharedFrameworks/'
566        ZeroPadBytes:    5
567      - cmd:             LC_RPATH
568        cmdsize:         56
569        path:            12
570        Content:         '@loader_path/../../PrivateFrameworks/'
571        ZeroPadBytes:    7
572      - cmd:             LC_ID_DYLIB
573        cmdsize:         80
574        dylib:
575          name:            24
576          timestamp:       0
577          current_version: 65536
578          compatibility_version: 65536
579        Content:         '@rpath/Frameworks/RPath.framework/Versions/A/RPath'
580        ZeroPadBytes:    6
581      - cmd:             LC_UUID
582        cmdsize:         24
583        uuid:            4C4C440D-5555-3144-A18B-DB67A0A12202
584      - cmd:             LC_BUILD_VERSION
585        cmdsize:         32
586        platform:        1
587        minos:           851968
588        sdk:             983040
589        ntools:          1
590        Tools:
591          - tool:            4
592            version:         1245184
593      - cmd:             LC_LOAD_DYLIB
594        cmdsize:         56
595        dylib:
596          name:            24
597          timestamp:       0
598          current_version: 14942208
599          compatibility_version: 65536
600        Content:         '/usr/lib/libobjc.A.dylib'
601        ZeroPadBytes:    8
602      - cmd:             LC_LOAD_DYLIB
603        cmdsize:         56
604        dylib:
605          name:            24
606          timestamp:       0
607          current_version: 88539136
608          compatibility_version: 65536
609        Content:         '/usr/lib/libSystem.B.dylib'
610        ZeroPadBytes:    6
611      - cmd:             LC_FUNCTION_STARTS
612        cmdsize:         16
613        dataoff:         32800
614        datasize:        8
615      - cmd:             LC_DATA_IN_CODE
616        cmdsize:         16
617        dataoff:         32808
618        datasize:        0
619      - cmd:             LC_CODE_SIGNATURE
620        cmdsize:         16
621        dataoff:         32896
622        datasize:        416
623    LinkEditData:
624      ExportTrie:
625        TerminalSize:    0
626        NodeOffset:      0
627        Name:            ''
628        Flags:           0x0
629        Address:         0x0
630        Other:           0x0
631        ImportName:      ''
632        Children:
633          - TerminalSize:    4
634            NodeOffset:      25
635            Name:            _publicGlobalVariable
636            Flags:           0x0
637            Address:         0x8000
638            Other:           0x0
639            ImportName:      ''
640      NameList:
641        - n_strx:          2
642          n_type:          0xF
643          n_sect:          3
644          n_desc:          0
645          n_value:         32768
646        - n_strx:          24
647          n_type:          0x1
648          n_sect:          0
649          n_desc:          512
650          n_value:         0
651      StringTable:
652        - ' '
653        - _publicGlobalVariable
654        - dyld_stub_binder
655        - ''
656        - ''
657        - ''
658        - ''
659        - ''
660        - ''
661        - ''
662      FunctionStarts:  [ 0x1060 ]
663...
664