Uploaded image for project: 'Swift'
  1. Swift
  2. SR-710 Generate XCTestCaseProvider entries on Linux
  3. SR-1613

Require blocks runtime when compiling SourceKit on Linux

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Component/s: Package Manager, XCTest
    • Labels:
      None

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              modocache Brian Ivan Gesiak
              Reporter:
              modocache Brian Ivan Gesiak
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: