How to compile swift on Ubuntu 19.04?

I installed dependencies from README, did ./swift/utils/update-checkout --clone, and build script fails with the following message:

$ utils/build-script --release-debuginfo
utils/build-script: note: Using toolchain default
+ cmake --version
+ /home/cukier/Developer/swift-source/cmake/bootstrap
---------------------------------------------
CMake 3.15.1, Copyright 2000-2019 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc       
C++ compiler on this system is: g++          
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
make: 'cmake' is up to date.
loading initial cache file /home/cukier/Developer/swift-source/build/cmake-linux-x86_64/Bootstrap.cmk/InitialCacheFlags.cmake
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfig.cmake:27 (message):
  The imported target "Qt5::Gui" references the file

     "/usr/lib/x86_64-linux-gnu/libEGL.so"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/x86_64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:63 (_qt5_Gui_check_file_exists)
  /usr/lib/x86_64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:85 (_qt5gui_find_extra_libs)
  /usr/lib/x86_64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfig.cmake:186 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:101 (find_package)
  Tests/CMakeLists.txt:1351 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/cukier/Developer/swift-source/build/cmake-linux-x86_64/CMakeFiles/CMakeOutput.log".
See also "/home/cukier/Developer/swift-source/build/cmake-linux-x86_64/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
utils/build-script: fatal error: command terminated with a non-zero exit status 11, aborting

Are there some dependencies not mentioned in the README?
Installing libncurses5, libtinfo5, and libncurses5-dev didn't help this time

Tagging @compnerd @spevans @mishal_shah who should know the most about how we build cmake.

1 Like

Hmm, interesting error message. Are you building on a version of Ubuntu which does not have a graphical environment available? If so, that's just a new configuration that no one has built in before I think. We should be able to configure the build such that it disables the graphical helpers for CMake.

No, it's a normal desktop version of Ubuntu unfortunately

Since I don't use Linux or Ubuntu, and it's been a long time since I have used Ubuntu, I'm not sure what gets installed by default. By the naming of the CMake files, it looks like CMake wants to have Qt5 installed. Does Ubuntu, or Linux in general, install Qt by default? If not, should the user be given the option to not use the graphical helpers if they don't want to install Qt? On my Mac, at least, Qt is a major install.

The quickest way to get past this would be not to build CMake from source, which isn't really needed. It looks like you already have the latest CMake 3.15.1 installed, so just rename the CMake source directory that you checked out to something else or delete it and the build-script will just use your pre-installed CMake, which should be fine. Once you get everything else built, you can come back and debug configuring the CMake build, if you want.

1 Like

That was a very good suggestion! Unfortunately after lots of compiling, cmake realized that I don't have the latest cmake installed

CMake Error at CMakeLists.txt:2 (cmake_minimum_required):
  CMake 3.15.1 or higher is required.  You are running version 3.13.4


-- Configuring incomplete, errors occurred!
[27/1010][  2%][0.748s] Building CXX object stdli...Runtime-linux-x86_64.dir/AnyHashableSupport.cpp.o
ninja: build stopped: subcommand failed.
utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
cukier@papryka:~/Developer/swift-source/swift$ cmake --version
cmake version 3.13.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

The missing dependency is not QT, its EGL (mesa). That seems odd.

Ive just installed Ubuntu19.04 server and did a bare minimum install then added the packages in the README.md. CMake builds from source.

I would suggest just trying to get CMake to build outside of the swift build script, use something like:

mkdir cmake-build
cd cmake-build
<path to cmake>/bootstrap
make

And try and debug it from there. There should be a log file produced if there are errors.
Also I dont have the libEGL.so file installed either:

$ ls /usr/lib/x86_64-linux-gnu/libEGL.so
ls: cannot access '/usr/lib/x86_64-linux-gnu/libEGL.so': No such file or directory

I think that build: bootstrap cmake without QT by compnerd · Pull Request #28636 · apple/swift · GitHub should allow the build to go through even without EGL.

1 Like

@cukr, @spevans - if either one of you can verify that the error is resolved with that change, I can merge it. We should do that earlier rather than later - the branch cut is soon.

Unfortunately it didn't help. I tried it just now, and I get the exact same error (I deleted build directory, replaced swift directory with your repo, checked out your cute branch, and ran the build script)

I'm sorry but the debugging part of my brain is filled with info like having to know that initializer 'init(_:)' requires that 'String' conform to 'BinaryInteger' means "You forgot to unwrap your optional", and when I look at 10787 lines of errors I cannot comprehend what even am I looking at. :(

Do you know a good site where I can upload literally hundreds kB of error file, and over MB of log file?

Thanks everyone, I appreciate your help.

@cukr can you provide some details on your build server?

I have completed several builds of Swift on servers running Ubuntu 19.04, both x86_64 and aarch64. None have had any problems with the build completing.

If you are just looking to use Swift I have a copy that was built on 19.04 here - https://github.com/futurejones/swift-arm64/releases/tag/dev-master-x86.

Also the any of the Ubuntu 18.04 versions from Swift.org should run fine on 19.04 - Swift.org - Download Swift

It's a desktop version of Ubuntu, that I'm using every day. It's not a fresh install, but an update from the previous version.

Toolchain from swift.org works fine for me (at least the one from 6 months ago or so) but I got an urge to possibly contribute some code to the standard library, and compiling from source is the first step for that

As long as you have a recent 64bit cpu there should be no reason why you can't get successful builds.

There are couple of thing that may make a difference.
1.
When checking the dependencies between what I install (I have a dependency install script that I use to set up a new build server) and what is in the README I noticed that i have libblocksruntime-dev installed but I cant remember when or why I added it to my install list.:thinking:
2.
Also I use the build script presets command to build

  • ./utils/build-script --preset=buildbot_linux,no_test install_destdir=/home/[USER]/install installable_package=/home/[USER]/install/swift-master-x86_64-Dev-Ubuntu-19.04.tar.gz

replace [USER] with your username and change the package name to whatever you like.

You can use --preset=buildbot_linux if you want to build and run all tests but it will take a lot longer and the build will fail if any of the tests fail.

You could also try building the swift-5.1.2-RELEASE and see if you get the same errors.

@futurejones - the problem is actually pretty interesting. There is a broken dependency in Ubuntu's package. They are missing the EGL implementation, but for some reason QT is available, which is resulting in the tests for that path getting triggered. This is something where you can trivially work around it by doing apt-get install libglvnd-dev. What I'm trying to figure out is how to avoid the dependency in the first place because it seems silly. Unfortunately, I do not have easy access to an Ubuntu host to actually look into this myself.

Why not just setup one using VirtualBox?

My MacBook nor my Windows machine are viable to run both a VM and the host reasonably at the same time. My Linux machine is currently unusable (due to a broken libc), but that also would not be able to run VirtualBox OSE.