Can't Compile Sourckit_LSP with Errors

$ swift build -Xcxx -I/home/zhaoxin/Downloads/swift-5.5.1-RELEASE-ubuntu20.04/usr/bin/swift/Block
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCLibc/CMakeFiles': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCLibc/cmake_install.cmake': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCclibc/cmake_install.cmake': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCclibc/CMakeFiles': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCBasic/cmake_install.cmake': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCBasic/CMakeFiles': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCUtility/CMakeFiles': File not found.
'swift-tools-support-core' /home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core: warning: Invalid Exclude '/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCUtility/cmake_install.cmake': File not found.
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:23:8: error: unknown type name 'dispatch_queue_priority_t'; did you mean 'dispatch_queue_attr_t'?
static dispatch_queue_priority_t toDispatchPriority(WorkQueue::Priority Prio) {
       ^~~~~~~~~~~~~~~~~~~~~~~~~
       dispatch_queue_attr_t
/usr/include/dispatch/queue.h:75:1: note: 'dispatch_queue_attr_t' declared here
DISPATCH_DECL(dispatch_queue_attr);
^
/usr/include/dispatch/base.h:56:84: note: expanded from macro 'DISPATCH_DECL'
#define DISPATCH_DECL(name) typedef struct name##_s : public dispatch_object_s {} *name##_t
                                                                                   ^
<scratch space>:142:1: note: expanded from here
dispatch_queue_attr_t
^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:25:42: error: cannot initialize return object of type 'dispatch_queue_attr_t' (aka 'dispatch_queue_attr_s *') with an rvalue of type '(anonymous enum at /usr/include/dispatch/queue.h:372:1)'
  case WorkQueue::Priority::High: return DISPATCH_QUEUE_PRIORITY_HIGH;
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:26:45: error: cannot initialize return object of type 'dispatch_queue_attr_t' (aka 'dispatch_queue_attr_s *') with an rvalue of type '(anonymous enum at /usr/include/dispatch/queue.h:372:1)'
  case WorkQueue::Priority::Default: return DISPATCH_QUEUE_PRIORITY_DEFAULT;
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:27:41: error: cannot initialize return object of type 'dispatch_queue_attr_t' (aka 'dispatch_queue_attr_s *') with an rvalue of type '(anonymous enum at /usr/include/dispatch/queue.h:372:1)'
  case WorkQueue::Priority::Low: return DISPATCH_QUEUE_PRIORITY_LOW;
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:29:12: error: use of undeclared identifier 'DISPATCH_QUEUE_PRIORITY_BACKGROUND'
    return DISPATCH_QUEUE_PRIORITY_BACKGROUND;
           ^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:36:49: error: use of undeclared identifier 'DISPATCH_QUEUE_CONCURRENT'
  case WorkQueue::Dequeuing::Concurrent: return DISPATCH_QUEUE_CONCURRENT;
                                                ^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:37:45: error: use of undeclared identifier 'DISPATCH_QUEUE_SERIAL'
  case WorkQueue::Dequeuing::Serial: return DISPATCH_QUEUE_SERIAL;
                                            ^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:43:10: error: no matching function for call to 'dispatch_get_global_queue'
  return dispatch_get_global_queue(toDispatchPriority(Prio), 0);
         ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/dispatch/queue.h:402:1: note: candidate function not viable: no known conversion from 'dispatch_queue_attr_t' (aka 'dispatch_queue_attr_s *') to 'long' for 1st argument
dispatch_get_global_queue(long priority, unsigned long flags);
^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:89:51: error: use of undeclared identifier 'DISPATCH_BLOCK_ASSIGN_CURRENT'
  ExecuteInfo->BlockToRun = dispatch_block_create(DISPATCH_BLOCK_ASSIGN_CURRENT,
                                                  ^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:119:3: error: use of undeclared identifier 'dispatch_barrier_async_f'
  dispatch_barrier_async_f(queue, Context, CFn);
  ^
/home/zhaoxin/Downloads/sourcekit-lsp/.build/checkouts/indexstore-db/lib/Support/Concurrency-Mac.cpp:128:3: error: use of undeclared identifier 'dispatch_barrier_sync_f'; did you mean 'dispatch_async_f'?
  dispatch_barrier_sync_f(queue, Context, CFn);
  ^~~~~~~~~~~~~~~~~~~~~~~
  dispatch_async_f
/usr/include/dispatch/queue.h:178:1: note: 'dispatch_async_f' declared here
dispatch_async_f(dispatch_queue_t queue,
^
11 errors generated.
[0/629] Compiling llvmSupport raw_ostream.cpp

Which package do I have to install to fix this issue? Thanks.

Maybe you can refer this link https://github.com/apple/sourcekit-lsp/blob/main/Documentation/Development.md#linux

Linux

Install the following dependencies of SourceKit-LSP:

  • libsqlite3-dev, libncurses5-dev, python, ninja-build
$ export PATH="<path_to_swift_toolchain>/usr/bin:${PATH}" 
$ swift package update 
$ swift build -Xcxx -I<path_to_swift_toolchain>/usr/lib/swift -Xcxx -I<path_to_swift_toolchain>/usr/lib/swift/Block

@Zhao_Xin

Still the same.

I think you are missing

-Xcxx -I<path_to_swift_toolchain>/usr/lib/swift 

in addition to

-Xcxx -I<path_to_swift_toolchain>/usr/lib/swift/Blocks

which you specified.

Let me know if adding that option helped.