Skip to content

[SR-1613] Require blocks runtime when compiling SourceKit on Linux #5272

Closed
@modocache

Description

@modocache
Previous ID SR-1613
Radar None
Original Reporter @modocache
Type Sub-task
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager, XCTest
Labels Sub-task
Assignee @modocache
Priority Medium

md5: a526276c1e36b2d3cc9732aad041c42b

Parent-Task:

  • SR-710 Generate XCTestCaseProvider entries on Linux

blocks:

Issue Description:

The sourcekitd/sourcekitd.h header uses __has_feature(blocks) to only define block-based APIs on platforms that support them. For some of these APIs, function pointer equivalents are also defined.

However, much of the internal implementation of SourceKit uses the block-based APIs. Therefore, SourceKit cannot build on any platform that does not have blocks – specifically, it does not build on Linux.

The following block-based APIs need function pointer equivalents, and SourceKit implementation callsites to these functions should use the function pointer APIs instead:

  • sourcekitd_set_interrupted_connection_handler needs sourcekitd_set_interrupted_connection_handler_f

  • sourcekitd_variant_dictionary_apply needs sourcekitd_variant_dictionary_apply_f

  • sourcekitd_variant_array_apply needs sourcekitd_variant_array_apply_f

  • sourcekitd_send_request needs sourcekitd_send_request_f

  • sourcekitd_set_notification_handler needs sourcekitd_set_notification_handler_f

  • sourcekitd_set_uid_handlers needs sourcekitd_set_uid_handlers_f

As far as I know, adding a function pointer API for a block-based API looks something like the following, using sourcekitd_set_notification_handler as an example:

// Instead of a block `sourcekitd_response_receiver_t`, define a function `sourcekitd_response_receiver_f_t`.
// Because functions can't capture stack variables, it's passed a context pointer.
typedef void (*sourcekitd_response_receiver_f_t)(sourcekitd_response_t resp, void *context);
// Define another function that takes the new function pointer type.
void sourcekitd_set_notification_handler_f(sourcekitd_response_receiver_f_t receiver);

It might be a good idea to create sub-tasks for each of these, although I'd like to confirm that this is a reasonable direction before we do that.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions