Skip to content

Commit 062f6fe

Browse files
authored
[InstallAPI] Support mutually exclusive parse options (llvm#90686)
Projects like libc use mutually exclusive macros to compile files multiple times and then merge the result into the final library. For installapi to accept these, we'd need to parse the same declarations in different ways. This patch adds the basic pipelining for installapi to create the correct TBD file. * -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix headers * -Xlabel allows: -D and -U settings * Error on 'private' and 'public' labels -X<label> * Xplatform allows: -iframework <path> This is to support the case where zippered frameworks want to pass in iOSSupport search path.
1 parent 9a7262c commit 062f6fe

File tree

22 files changed

+1316
-31
lines changed

22 files changed

+1316
-31
lines changed

clang/include/clang/Basic/DiagnosticInstallAPIKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">;
2525
def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">;
2626
def err_unsupported_os : Error<"os '%0' is not supported: '%1'">;
2727
def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">;
28+
def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X<label>">;
2829
} // end of command line category.
2930

3031
let CategoryName = "Verification" in {

clang/include/clang/InstallAPI/MachO.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ using SimpleSymbol = llvm::MachO::SimpleSymbol;
4545
using FileType = llvm::MachO::FileType;
4646
using PackedVersion = llvm::MachO::PackedVersion;
4747
using PathSeq = llvm::MachO::PathSeq;
48+
using PlatformType = llvm::MachO::PlatformType;
49+
using PathToPlatformSeq = llvm::MachO::PathToPlatformSeq;
4850
using Target = llvm::MachO::Target;
4951
using TargetList = llvm::MachO::TargetList;
5052

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework module Foundation [system] {
2+
umbrella header "Foundation.h"
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef FOO_H
2+
#define FOO_H
3+
#include <macro_defs.h>
4+
5+
#if defined(Foo)
6+
#define FOO "FooLib$"
7+
#else
8+
#define FOO
9+
#endif
10+
11+
#define __STRING(x) #x
12+
#define PLATFORM_ALIAS(sym) __asm("_" FOO __STRING(sym) DARWIN LINUX)
13+
extern int foo() PLATFORM_ALIAS(foo);
14+
15+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef MACRO_DEFS_H
2+
#define MACRO_DEFS_H
3+
4+
#if defined(NONDarwin)
5+
#define LINUX "$linux"
6+
#define DARWIN
7+
#elif defined(Darwin)
8+
#define LINUX
9+
#define DARWIN "$darwin"
10+
#else
11+
#define LINUX
12+
#define DARWIN
13+
#endif
14+
15+
#endif // MACRO_DEFS_H
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef PUBLIC_H
2+
#define PUBLIC_H
3+
#include <macro_defs.h>
4+
5+
#define __STRING(x) #x
6+
#define PLATFORM_ALIAS(sym) __asm("_" __STRING(sym) DARWIN LINUX)
7+
extern int foo() PLATFORM_ALIAS(foo);
8+
9+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#if !__is_target_environment(macabi)
2+
typedef int MyType;
3+
#else
4+
typedef float MyType;
5+
#endif
6+
7+
extern MyType invalidAPI();
8+
9+
#define OS_AVAILABLE(_target, _availability) \
10+
__attribute__((availability(_target, _availability)))
11+
extern int macOSAPI() OS_AVAILABLE(macos, introduced=10.14) OS_AVAILABLE(ios, unavailable);
12+
extern int iOSAPI() OS_AVAILABLE(ios, introduced=12.0) OS_AVAILABLE(macos, unavailable);
13+
extern int commonAPI() OS_AVAILABLE(macos, introduced=10.14) OS_AVAILABLE(ios, introduced=12.0);
14+
15+
extern int obsoletedMacOSAPI() OS_AVAILABLE(macos, obsoleted=10.14) OS_AVAILABLE(ios, unavailable);
16+
17+
#if !__is_target_environment(macabi)
18+
extern int macOSAPI2() OS_AVAILABLE(macos, introduced = 10.14)
19+
OS_AVAILABLE(ios, unavailable);
20+
#endif
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#if __is_target_environment(macabi)
2+
extern int a;
3+
@class UIImage;
4+
UIImage *image;
5+
#else
6+
extern long a;
7+
@class NSImage;
8+
NSImage *image;
9+
#endif
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"main_library": {
3+
"exported_symbols": [
4+
{
5+
"data": {
6+
"global": [
7+
"_image", "_a"
8+
]
9+
},
10+
"text": {
11+
"global": [
12+
"_invalidAPI", "_commonAPI"
13+
]
14+
}
15+
},
16+
{
17+
"targets": [ "x86_64-maccatalyst" ],
18+
"text": {
19+
"global": [ "_iOSAPI"]
20+
}
21+
},
22+
{
23+
"targets": [ "x86_64-macos" ],
24+
"text": {
25+
"global": [ "_macOSAPI", "_macOSAPI2" ]
26+
}
27+
}
28+
],
29+
"flags": [
30+
{
31+
"attributes": ["not_app_extension_safe"]
32+
}
33+
],
34+
"install_names": [
35+
{"name": "/System/Library/Frameworks/Zippered.framework/Versions/A/Zippered"}
36+
],
37+
"target_info": [
38+
{
39+
"min_deployment": "13", "target": "x86_64-macos"
40+
},
41+
{
42+
"min_deployment": "16", "target": "x86_64-maccatalyst"
43+
}
44+
]
45+
},
46+
"tapi_tbd_version": 5
47+
}

0 commit comments

Comments
 (0)