Need help building Swift on Debian server


(Mickaël Rémond) #1

Hello,

I have been trying to build Swift on my Linux Debian server. The process seems to get through fine, despite the fact that two test are failing.

I have built the platform with the following command:

./utils/build-script -R --foundation

Now, how can I use it or install it locally (for example in /usr/local ?)

When I try to run Swift, it says this is the REPL intended for compiler and stdlib. Simply trying to use print fails:

/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin# ./swift
***  You are running Swift's integrated REPL,  ***
***  intended for compiler and stdlib          ***
***  development and testing purposes only.    ***
***  The full REPL is built as part of LLDB.   ***
***  Type ':help' for assistance.              ***
(swift) print("Hello")
Stack dump:                                                                                                      0.      Program arguments: /opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift -frontend -repl -disable-objc-interop -color-diagnostics -module-name REPL 
1.      while processing REPL source:
print("Hello")
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x460cc54]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x460aa20]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x460ce02]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7fe81a1ca0c0]
[0x7fe81a5f5010]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0xce9c3e]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0xcedf22]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x51dea4]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x5190b5]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x4e85fd]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x4e6ac7]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x48dfee]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7fe8189222e1]
/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift[0x48be2a]
Illegal instruction                                                                                              

Trying to compile a basic test file fails as well:

/opt/swift-source/build/Ninja-ReleaseAssert/swift-linux-x86_64# bin/swiftc test.swift
/usr/bin/ld.gold: fatal error: test: open: Is a directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

Any idea what I am missing ?


(Simon Evans) #2

To do a build and install without running the tests I use:
swift/utils/build-script --preset=buildbot_linux,no_test install_destdir=~/swift-install installable_package=~/swift.tgz

which will install it into ~/swift-install and also create a tar.gz of the installation.

To run the tests as well use --preset=buildbot_linux instead.

Note these 2 commands will use the same build directory but it will be different to the one used in your original command so the first time you run it there will be a full rebuild.


(Mickaël Rémond) #3

Hello Simon,

It worked like a charm. Many thanks!

For the record, I had to install Swig 2.0 instead of the Swig 3.0 package with latest Debian version, and of course install the needed dependencies. After that, with your build command all went very well.

Thanks again :slight_smile:


(Ian Partridge) #4

That's surprising, because the build instructions say apt-get install swig is enough, and Ubuntu 16.04 comes with Swig 3. We build on Ubuntu 16.04 all the time don't we?


(Mickaël Rémond) #5

I find it surprising as well. I had a failure at the end, with a specific message saying that Swift (or LLDB ?) is not compliant with Swig 3.0.9 and 3.0.10.

I can reinstall Swig 3 and reproduce the exact message if you need to.

Note that I tried with Swig 2, because of this comment in the Swift README:

Note: LLDB currently requires at least swig-1.3.40 but will successfully build with version 2 shipped with Ubuntu.

Maybe using Swig 3.0.8 or 3.0.12 would be ok. I could try this as well.


(Ian Partridge) #6

OK, here's what I've found out:

ubuntu:14.04 - swig 2.0.11
ubuntu:16.04 - swig 3.0.8
ubuntu:18.04 - swig 3.0.12
debian:latest - swig 3.0.10

Testing done via docker run -it <image> /bin/bash; apt-get update && apt-get install -y swig && swig -version

As your error was "a specific message saying that Swift (or LLDB ?) is not compliant with Swig 3.0.9 and 3.0.10." I think that explains it?

Can you confirm that you are able to find a version of swig 3 that works on debian:latest?


(Mickaël Rémond) #7

Hello Ian,

Sure, let me experiment with it. I will report ASAP.

Thanks !


(Mickaël Rémond) #8

Hello Ian,

So, I made some tests and I confirms that the issue is coming from the Swig version packaged with Debian, which makes LLBD unhappy.

Swig version packaged with Debian Stretch is 3.0.10. With this version, Swift build process fails on LLDB with the following error: “Swig versions 3.0.9 and 3.0.10 are incompatible with lldb.”

It seems that Swig API changed and broke LLDB in version 3.0.9 and 3.0.10 and that newer version offers workaround: https://github.com/llvm-mirror/lldb/blob/master/scripts/lldb.swig#L35

As a result, the compilation is working fine with Swig 3.0.12 that is packaged with Ubuntu for example. I tried installing the .deb package from Ubuntu and I could successfully build Swift.

I will report this to Debian, hoping they will update Swig, as it will make the distribution more Swift friendly as default.


(Ian Partridge) #9

Thanks - I'm glad you solved the mystery. If Debian could ship Swig 3.0.12 that would be great.