jinmingjian / sourcekite

the backend of SDE's language server
Apache License 2.0
56 stars 9 forks source link

cannot find -l:sourcekitdInProc #1

Closed TofPlay closed 7 years ago

TofPlay commented 7 years ago

Hi I installed https://swift.org/builds/swift-3.1-branch/ubuntu1610/swift-3.1-DEVELOPMENT-SNAPSHOT-2017-01-31-a/swift-3.1-DEVELOPMENT-SNAPSHOT-2017-01-31-a-ubuntu16.10.tar.gz on my Ubuntu config

I execute the command:

$ swift build -Xlinker -L/usr/lib/sourcekitdInProc.framework -Xlinker -l:sourcekitdInProc
Linking sourcekitd
/usr/bin/ld: cannot find -l:sourcekitdInProc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures

I can not find sourcekitdInProc.framework on my config :(

jinmingjian commented 7 years ago

@TofPlay the sourcekitd framework are not included in the the default official download.

I am also thinking which is the better solution now :question:

  1. build yourself. I leave some suggestions in SDE issue #13
  2. use a prebuilt binary from other's. 2.1 a prebuild docker image(refs: https://hub.docker.com/_/swift/). This seem promising as hinted by some users. But I have not tested this. (I hope to do some explores for this) 2.2 a prebuild sourcekitd library. My own Linux distro is Arch, but it is possible to run if you do some tricks. If you like to consume this way I would like to provide one for you testing.
TofPlay commented 7 years ago

the sourcekitd framework are not included in the the default official download.

Really?!?! 😵

2.1 a prebuild docker image

I check the Dockerfile. There is no instruction that builds sourcekitd. And I'm not sure this the official image of Swift. If I check on the Docker Store (replace Docker Hub) I can not found any official image for Swift from Apple.

2.2 a prebuild sourcekitd library. My own Linux distro is Arch, but it is possible to run if you do some tricks.

I do not have the same environment. I will waste time trying to make it work at home.

  1. build yourself. I leave some suggestions in SDE issue #13

I think I do not have too much choice. I will be obliged to build it on my config. The ticket is quite long. Not easy to extract the correct instructions to build sourcekitd. The ideal will be to have a bash script to build sourcekitd from the official Swift environment we can download on https://swift.org.

jinmingjian commented 7 years ago

@TofPlay Do not give up :smiley: here are some extracts:

docker:

I have not examined the docker way. But I am you may try this tip:

I'm having the same problem on Ubuntu 16.04. I'm using https://github.com/norio-nomura/docker-sourcekit-builder provides sourcekitd-repl.

DIY build:

this preset file now lives here.

the "secret“ may be this:

... extra-cmake-options="-DSWIFT_BUILD_SOURCEKIT:BOOL=ON -DSWIFT_TOOL_SOURCEKITD_REPL_BUILD=1"

dash-dash

swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-inproc;tools ...

at OSX, you may change:

sourcekit-inproc -> sourcekit-xpc-service

and component "tools" should corresponds to sourcekit side gen.

extra-cmake-options is must for Linux. but I guess no harm for OSX.

And it needs two passes in Linux: First, disable "sourcekit-inproc" comopnent for libdispatch, and second enable "sourcekit-inproc" for itself.

jinmingjian commented 7 years ago

In fact, I have not much interests in docker before. So, sorry for the official docker seemly have not included the Sourcekit. I still like to try if the docker way can solve the this problem. Because the distros are varying much. The linked dynamic libraries may not existed in some distro. But the docker provides one standard container for this which is valuable.

jinmingjian commented 7 years ago

to build from scratch is not terrible as many programmers thought:

  1. learn some basics from the readme of https://github.com/apple/swift
  2. use my “secret recipe” above
  3. wait one hour to let building to finish. you will find the library in the buildout directory (like: $REPO_ROOT_PARENT/build/jin/swift-linux-x86_64/lib/sourcekitdInProc.framework)
jinmingjian commented 7 years ago

the benenift of building from scratch is you get the lastest Sourcekit which has more features and less bugs and crashes :smiley:

TofPlay commented 7 years ago

wait one hour to let building to finish

I appreciate your enthusiasm and your support 🙂 But obliged to rebuild swift from scratch just for a tool it's too much for me. I did years ago with Linux but now it's no longer a fun for me and I do not have time for it either. I'm already fully busy. Otherwise I continue to think that SDE is a good tool and if Apple decides to put sourcekit in its standard distribution for Linux I will use SDE with pleasure.

TofPlay commented 7 years ago

Suggestion: You can create an ubuntu package that we can install with apt-get install 😉

jinmingjian commented 7 years ago

@TofPlay I have confirmed the docker way is workable. Maya docker image of sourcekite be welcome?

More interesting is that, @norio-nomura provides a binary[1]. I have confirmed that this package include the sourcekit library. Can you download this binary other than the official one. If this is ok, it at least solves for you problem. :+1:

[1] https://github.com/norio-nomura/docker-sourcekit-builder/releases

TofPlay commented 7 years ago

@jinmingjian the binary is generate for ubuntu 16.04. I'm on Ubuntu 16.10. I'm not sure if we can build sourcekit on 16.04 and run on 16.10. Right now I am too busy I will probably not test it before next week. For future versions, if you want more people use SDE, you should automatically create a deb file for sourcekit for each version of Ubuntu. Then for example for Ubuntu 16.10 we will just have to execute the command dpkg --install sourcekit-swift3.1-ubuntu16.10.deb (or another name is up to you) to install sourcekit. See this link: What is the simplest Debian Packaging Guide? While I think it's strange that Apple is not creating a deb file for Swift. 🤔

jinmingjian commented 7 years ago

@TofPlay thanks for suggestions. I add a docker image support for sourcekite. See more in README.

The installation package way is brittle. And as you seen, even the Apple has no resource for this. So, we just go here. And wait for future...