Skip to content

Commit d3249ac

Browse files
committed
sourcekitd: adjust the definition of SOURCEKIT_PUBLIC
The API surface for sourcekitd is exported through libAPI and libService. Use the `sourcekitd_EXPORTS` macro (reflecting the CMake default behaviour of `_EXPORTS` macros) to provide a proper definition of the macro on Windows. This is not related to MSVC but to PE/COFF which uses this to define the ABI boundary for the symbol. This is helpful in partially repairing the ARM64 build of sourcekitd.
1 parent 60d82c7 commit d3249ac

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

tools/SourceKit/tools/sourcekitd/bin/InProc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ else()
4949
HAS_SWIFT_MODULES
5050
)
5151
endif()
52+
set_target_properties(sourcekitdInProc PROPERTIES
53+
DEFINE_SYMBOL sourcekitd_EXPORTS)
5254
target_link_libraries(sourcekitdInProc PRIVATE
5355
SourceKitSwiftLang
5456
sourcekitdAPI

tools/SourceKit/tools/sourcekitd/include/sourcekitd/Internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
#ifndef LLVM_SOURCEKITD_INTERNAL_H
1414
#define LLVM_SOURCEKITD_INTERNAL_H
1515

16-
#if defined (_MSC_VER)
17-
# define SOURCEKITD_PUBLIC __declspec(dllexport)
18-
#endif
19-
2016
#include "SourceKit/Support/CancellationToken.h"
2117
#include "sourcekitd/sourcekitd.h"
2218
#include "llvm/ADT/Optional.h"

tools/SourceKit/tools/sourcekitd/include/sourcekitd/sourcekitd.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@
5252
# define SOURCEKITD_END_DECLS
5353
#endif
5454

55-
#ifndef SOURCEKITD_PUBLIC
56-
# if defined (_MSC_VER)
57-
# define SOURCEKITD_PUBLIC __declspec(dllimport)
55+
#if defined(_WIN32)
56+
# if defined(sourcekitd_EXPORTS)
57+
# define SOURCEKITD_PUBLIC __declspec(dllexport)
5858
# else
59-
# define SOURCEKITD_PUBLIC
59+
# define SOURCEKITD_PUBLIC __declspec(dllimport)
6060
# endif
61+
#else
62+
# define SOURCEKITD_PUBLIC
6163
#endif
6264

6365
#ifndef __has_feature

tools/SourceKit/tools/sourcekitd/lib/API/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ add_sourcekit_library(sourcekitdAPI
1414
VariableTypeArray.cpp
1515
UIDHandling.cpp)
1616

17+
target_compile_definitions(sourcekitdAPI PRIVATE
18+
sourcekitd_EXPORTS)
1719
target_link_libraries(sourcekitdAPI PRIVATE
1820
swiftBasic
1921
SourceKitSupport)

tools/SourceKit/tools/sourcekitd/lib/Service/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
add_sourcekit_library(sourcekitdService
33
Requests.cpp
44
)
5+
target_compile_definitions(sourcekitdService PRIVATE
6+
sourcekitd_EXPORTS)
57
target_link_libraries(sourcekitdService PRIVATE
68
sourcekitdAPI
79
swiftBasic

0 commit comments

Comments
 (0)