Swift 4.2 - unable to build on Ubuntu 16.04/18/04 - linker error


#1

Hello

I am unable to build Swift 4.2 on either Ubuntu 16.04 or 18.04. I keep on getting clang linker error:

On 18.04:
clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

FAILED: bin/clang-6.0 
....
clang: error: unable to execute command: Killed
clang: error: linker command failed due to signal (use -v to see invocation)

On 16.04:
clang --version
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
...
clang: error: unable to execute command: Killed
clang: error: linker command failed due to signal (use -v to see invocation)

I did git checkout swift-4.2-branch to obtain 4.2

Let me know if this is a known issue and if there are workarounds to address it.

Thanks.


(Johannes Weiss) #2

Total stab in the dark here but it says

clang: error: unable to execute command: Killed

so (especially if this is in Docker) it might be the OOM (out of memory) Killer killing your process. Linking can be quite memory intensive and Docker containers often have no swap so it the linking consumes more memory than available, you'd get something like that.

You could check dmesg | grep -i 'killed process' or similar to see if there's any signs of the OOM killer doing its job.


(Michael Gottesman) #3

@rishi Did you use the update-checkout scheme for 4.2 to make sure you got /all/ of the right branches?


#4

@Michael_Gottesman - yes, I did. This is what I have done prior to building it:

git clone https://github.com/apple/swift.git
cd swift
git checkout swift-4.2-branch
./utils/update-checkout --clone --scheme swift-4.2-branch

I am rebuilding it on a slightly bigger machine (@johannesweiss - no Docker) with 16GB RAM. Will keep you guys posted.


#5

It builds with a VM of 16GB .... 8GB RAM seems insufficient to build the compiler.


#6

The linker is using too much memory. Killing Chrome and all other memory hungry applications and running the build script with "-j 1" works for me with 8GB of RAM. You can just continue building after that error, then kill the build after clang has been linked, and continue with "-j 4" or "-j 8" (or just without it like before).