Skip to content

Commit 35f2dee

Browse files
committed
[SR-1639] Fix linker errors for sourcekitd when in-process
Several SourceKit symbols are declared in `sourcekitd/sourcekitd.h` and `sourcekitd/Internal.h`, but are only implemented for OS X, in `tools/SourceKit/tools/sourcekitd/lib/API/sourcekitdAPI-XPC.cpp`. These need implementations that are only included in builds of SourceKit that use an in-process communication model (in other words, not XPC). Add stub implementations of the undefined symbols for in-process builds. This reduces the number of linker errors, getting us closer to at least *compiling* SourceKit on Linux. Of course, these stub functions will not work at runtime, they'll just let us compile.
1 parent 87115f8 commit 35f2dee

File tree

3 files changed

+253
-9
lines changed

3 files changed

+253
-9
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ set(sourcekitdAPI_sources
77
TokenAnnotationsArray.cpp
88
)
99

10-
set(sourcekitdAPI_Darwin_sources
11-
sourcekitdAPI-XPC.cpp)
12-
set(LLVM_OPTIONAL_SOURCES ${sourcekitdAPI_Darwin_sources})
13-
if(APPLE)
14-
list(APPEND sourcekitdAPI_sources ${sourcekitdAPI_Darwin_sources})
10+
set(sourcekitdAPI_InProc_sources sourcekitdAPI-InProc.cpp)
11+
set(sourcekitdAPI_XPC_sources sourcekitdAPI-XPC.cpp)
12+
13+
set(LLVM_OPTIONAL_SOURCES ${sourcekitdAPI_InProc_sources})
14+
set(LLVM_OPTIONAL_SOURCES ${sourcekitdAPI_XPC_sources})
15+
16+
if(SWIFT_SOURCEKIT_USE_INPROC_LIBRARY)
17+
list(APPEND sourcekitdAPI_sources ${sourcekitdAPI_InProc_sources})
18+
else()
19+
list(APPEND sourcekitdAPI_sources ${sourcekitdAPI_XPC_sources})
1520
endif()
1621

1722
add_sourcekit_library(sourcekitdAPI
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
//===--- sourcekitdAPI-InProc.cpp -----------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "sourcekitd/sourcekitd.h"
14+
#include "sourcekitd/Internal.h"
15+
#include "SourceKit/Support/UIdent.h"
16+
#include "llvm/ADT/ArrayRef.h"
17+
#include "llvm/ADT/StringRef.h"
18+
#include "llvm/Support/ErrorHandling.h"
19+
20+
using namespace SourceKit;
21+
using namespace sourcekitd;
22+
using llvm::ArrayRef;
23+
using llvm::StringRef;
24+
using llvm::raw_ostream;
25+
26+
// The following functions are declared in sourcekitd/sourcekitd.h.
27+
// These are their "in-process" implementations.
28+
29+
sourcekitd_uid_t
30+
sourcekitd_uid_get_from_buf(const char *buf, size_t length) {
31+
llvm::report_fatal_error("not yet implemented");
32+
}
33+
34+
size_t
35+
sourcekitd_uid_get_length(sourcekitd_uid_t uid) {
36+
llvm::report_fatal_error("not yet implemented");
37+
}
38+
39+
const char *
40+
sourcekitd_uid_get_string_ptr(sourcekitd_uid_t uid) {
41+
llvm::report_fatal_error("not yet implemented");
42+
}
43+
44+
sourcekitd_object_t
45+
sourcekitd_request_retain(sourcekitd_object_t object) {
46+
llvm::report_fatal_error("not yet implemented");
47+
}
48+
49+
void sourcekitd_request_release(sourcekitd_object_t object) {
50+
llvm::report_fatal_error("not yet implemented");
51+
}
52+
53+
sourcekitd_object_t
54+
sourcekitd_request_dictionary_create(const sourcekitd_uid_t *keys,
55+
const sourcekitd_object_t *values,
56+
size_t count) {
57+
llvm::report_fatal_error("not yet implemented");
58+
}
59+
60+
void
61+
sourcekitd_request_dictionary_set_value(sourcekitd_object_t dict,
62+
sourcekitd_uid_t key,
63+
sourcekitd_object_t value) {
64+
llvm::report_fatal_error("not yet implemented");
65+
}
66+
67+
sourcekitd_object_t
68+
sourcekitd_request_array_create(const sourcekitd_object_t *objects,
69+
size_t count) {
70+
llvm::report_fatal_error("not yet implemented");
71+
}
72+
73+
void
74+
sourcekitd_request_array_set_value(sourcekitd_object_t array, size_t index,
75+
sourcekitd_object_t value) {
76+
llvm::report_fatal_error("not yet implemented");
77+
}
78+
79+
sourcekitd_object_t
80+
sourcekitd_request_int64_create(int64_t val) {
81+
llvm::report_fatal_error("not yet implemented");
82+
}
83+
84+
sourcekitd_object_t
85+
sourcekitd_request_string_create(const char *string) {
86+
llvm::report_fatal_error("not yet implemented");
87+
}
88+
89+
sourcekitd_object_t
90+
sourcekitd_request_uid_create(sourcekitd_uid_t uid) {
91+
llvm::report_fatal_error("not yet implemented");
92+
}
93+
94+
void
95+
sourcekitd_response_dispose(sourcekitd_response_t obj) {
96+
llvm::report_fatal_error("not yet implemented");
97+
}
98+
99+
bool
100+
sourcekitd_response_is_error(sourcekitd_response_t obj) {
101+
llvm::report_fatal_error("not yet implemented");
102+
}
103+
104+
sourcekitd_error_t
105+
sourcekitd_response_error_get_kind(sourcekitd_response_t obj) {
106+
llvm::report_fatal_error("not yet implemented");
107+
}
108+
109+
const char *
110+
sourcekitd_response_error_get_description(sourcekitd_response_t obj) {
111+
llvm::report_fatal_error("not yet implemented");
112+
}
113+
114+
sourcekitd_variant_t
115+
sourcekitd_response_get_value(sourcekitd_response_t resp) {
116+
llvm::report_fatal_error("not yet implemented");
117+
}
118+
119+
// The following functions are declared in sourcekitd/Internal.h.
120+
// These are their "in-process" implementations.
121+
122+
void sourcekitd::printRequestObject(sourcekitd_object_t Obj, raw_ostream &OS) {
123+
llvm::report_fatal_error("not yet implemented");
124+
}
125+
126+
ResponseBuilder::ResponseBuilder() {
127+
llvm::report_fatal_error("not yet implemented");
128+
}
129+
130+
ResponseBuilder::~ResponseBuilder() {
131+
llvm::report_fatal_error("not yet implemented");
132+
}
133+
134+
ResponseBuilder::Dictionary ResponseBuilder::getDictionary() {
135+
llvm::report_fatal_error("not yet implemented");
136+
}
137+
138+
sourcekitd_response_t ResponseBuilder::createResponse() {
139+
llvm::report_fatal_error("not yet implemented");
140+
}
141+
142+
void ResponseBuilder::Dictionary::set(UIdent Key, SourceKit::UIdent UID) {
143+
llvm::report_fatal_error("not yet implemented");
144+
}
145+
146+
void ResponseBuilder::Dictionary::set(UIdent Key, sourcekitd_uid_t UID) {
147+
llvm::report_fatal_error("not yet implemented");
148+
}
149+
150+
void ResponseBuilder::Dictionary::set(UIdent Key, const char *Str) {
151+
llvm::report_fatal_error("not yet implemented");
152+
}
153+
154+
void ResponseBuilder::Dictionary::set(UIdent Key, llvm::StringRef Str) {
155+
llvm::report_fatal_error("not yet implemented");
156+
}
157+
158+
void ResponseBuilder::Dictionary::set(UIdent Key, int64_t val) {
159+
llvm::report_fatal_error("not yet implemented");
160+
}
161+
162+
void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
163+
ArrayRef<StringRef> Strs) {
164+
llvm::report_fatal_error("not yet implemented");
165+
}
166+
167+
void ResponseBuilder::Dictionary::setBool(UIdent Key, bool val) {
168+
llvm::report_fatal_error("not yet implemented");
169+
}
170+
171+
ResponseBuilder::Dictionary
172+
ResponseBuilder::Dictionary::setDictionary(UIdent Key) {
173+
llvm::report_fatal_error("not yet implemented");
174+
}
175+
176+
void ResponseBuilder::Dictionary::setCustomBuffer(
177+
SourceKit::UIdent Key,
178+
CustomBufferKind Kind, std::unique_ptr<llvm::MemoryBuffer> MemBuf) {
179+
llvm::report_fatal_error("not yet implemented");
180+
}
181+
182+
ResponseBuilder::Array
183+
ResponseBuilder::Dictionary::setArray(UIdent Key) {
184+
llvm::report_fatal_error("not yet implemented");
185+
}
186+
187+
ResponseBuilder::Dictionary ResponseBuilder::Array::appendDictionary() {
188+
llvm::report_fatal_error("not yet implemented");
189+
}
190+
191+
sourcekitd_uid_t RequestDict::getUID(UIdent Key) {
192+
llvm::report_fatal_error("not yet implemented");
193+
}
194+
195+
196+
Optional<StringRef> RequestDict::getString(UIdent Key) {
197+
llvm::report_fatal_error("not yet implemented");
198+
}
199+
200+
Optional<RequestDict> RequestDict::getDictionary(SourceKit::UIdent Key) {
201+
llvm::report_fatal_error("not yet implemented");
202+
}
203+
204+
bool RequestDict::getStringArray(SourceKit::UIdent Key,
205+
llvm::SmallVectorImpl<const char *> &Arr,
206+
bool isOptional) {
207+
llvm::report_fatal_error("not yet implemented");
208+
}
209+
210+
bool RequestDict::getUIDArray(SourceKit::UIdent Key,
211+
llvm::SmallVectorImpl<sourcekitd_uid_t> &Arr,
212+
bool isOptional) {
213+
llvm::report_fatal_error("not yet implemented");
214+
}
215+
216+
bool RequestDict::dictionaryArrayApply(
217+
SourceKit::UIdent key, llvm::function_ref<bool(RequestDict)> applier) {
218+
llvm::report_fatal_error("not yet implemented");
219+
}
220+
221+
bool RequestDict::getInt64(SourceKit::UIdent Key, int64_t &Val,
222+
bool isOptional) {
223+
llvm::report_fatal_error("not yet implemented");
224+
}
225+
226+
sourcekitd_response_t
227+
sourcekitd::createErrorRequestInvalid(const char *Description) {
228+
llvm::report_fatal_error("not yet implemented");
229+
}
230+
231+
sourcekitd_response_t
232+
sourcekitd::createErrorRequestFailed(const char *Description) {
233+
llvm::report_fatal_error("not yet implemented");
234+
}
235+
236+
sourcekitd_response_t
237+
sourcekitd::createErrorRequestCancelled() {
238+
llvm::report_fatal_error("not yet implemented");
239+
}

tools/SourceKit/tools/sourcekitd/lib/API/sourcekitdAPI-XPC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ class SKDObjectPrinter : public SKDObjectVisitor<SKDObjectPrinter> {
195195

196196
} // anonymous namespace.
197197

198+
//===----------------------------------------------------------------------===//
199+
// Internal API
200+
//===----------------------------------------------------------------------===//
201+
198202
void sourcekitd::printRequestObject(sourcekitd_object_t Obj, raw_ostream &OS) {
199203
if (!Obj) {
200204
OS << "<<NULL>>";
@@ -204,10 +208,6 @@ void sourcekitd::printRequestObject(sourcekitd_object_t Obj, raw_ostream &OS) {
204208
SKDObjectPrinter(OS).visit(Obj);
205209
}
206210

207-
//===----------------------------------------------------------------------===//
208-
// Internal API
209-
//===----------------------------------------------------------------------===//
210-
211211
ResponseBuilder::ResponseBuilder() {
212212
Impl = xpc_dictionary_create(nullptr, nullptr, 0);
213213
}

0 commit comments

Comments
 (0)