swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.32k stars 10.34k forks source link

Document the required dependencies on Linux #64147

Open shahmishal opened 1 year ago

shahmishal commented 1 year ago

Document why each of these libraries are required on Linux, and also figure out alternative solution to reduce the dependences.

    binutils 
    git 
    unzip 
    gnupg2 
    libc6-dev 
    libcurl4-openssl-dev 
    libedit2 
    libgcc-9-dev 
    libpython3-dev 
    libsqlite3-0 
    libstdc++-9-dev 
    libxml2-dev 
    libz3-dev 
    pkg-config 
    python3-lldb-13 
    tzdata 
    zlib1g-dev 

@MaxDesiatov has a pull request to reduce some of the dependences. https://github.com/apple/swift/pull/61530

MaxDesiatov commented 1 year ago

In that list zlib1g-dev and libz3-dev seem to be duplicates to me. From what I've been able to find, they seem to be ABI/API-compatible, so I hope we'd be able to use one and not the other.

As for the rest, I think we can separate these into a few categories:

Toolchain build time dependencies:

  1. binutils
  2. git
  3. libc6-dev
  4. libgcc-9-dev
  5. libpython3-dev <- LLDB build-time dependency
  6. libstdc++-9-dev
  7. tzdata <- Foundation dependency

Foundation build dependencies

  1. libcurl4-openssl-dev
  2. libxml2-dev
  3. libz3-dev <- Deflate support for URLSession/curl?
  4. zlib1g-dev <- not needed if above is available?

SwiftPM build dependency

  1. pkg-config

SwiftPM/llbuild runtime dependencies

  1. libsqlite3-0
  2. git
  3. unzip

Swift runtime dependencies

  1. libc6
  2. libstdc++9

Toolchain installation dependencies

  1. gnupg2

LLDB runtime dependencies

  1. python3-lldb-13
  2. libedit2
stevapple commented 1 year ago

🤔️The Windows port managed to reduce dependencies by statically linking Foundation/SwiftPM dependencies. I’m not sure if upstream Linux software repositories allow static linking, but it is a tempting way for reducing the number of dependencies, at least for Swift.org tarballs, despite the risk of increasing the toolchain size.

The Windows guide also declares LLDB dependencies (Python) and SwiftPM external dependencies (Git) as recommended instead of required. On Linux where package management is more mature, I feel it’s reasonable to split the compiler, debugger and developer tools into different packages, to allow user skip some dependency if they really don’t need it.

unzip may be unnecessary if we implement the functionality in Swift…?

futurejones commented 1 year ago

@MaxDesiatov can you expand on your information about

zlib1g-dev and libz3-dev seem to be duplicates

From my research they seem to have very different purposes. https://packages.debian.org/bookworm/zlib1g-dev https://packages.debian.org/bookworm/libz3-dev

futurejones commented 1 year ago

@shahmishal what is the reason for trying to reduce the dependencies? Are we just trying to shorten the list and make the swift installation seem simpler? Most of these dependencies are not for swift but are needed by clang that is now included in the swift toolchain package.

shahmishal commented 1 year ago

@futurejones The goal is to understand the dependencies, and see if we can lower it. I wanted to explore an option in the future to limit OS and version specific distribution if possible.

futurejones commented 1 year ago

@shahmishal the simplest way to do that on ubuntu / debian OS's would be to use the build-essential package. This will install 90% of the depends list and correctly select all the version specific of packages such as libgcc-*-dev, libstdc++-*-dev, etc. The new depends list would be something like -

build-essential
git
unzip
libcurl4-openssl-dev 
libxml2-dev
libz3-dev 
pkg-config 
python3-lldb 
tzdata 
zlib1g-dev 

This will install the correct version of all the required dependencies on any ubuntu / debian distribution.

MaxDesiatov commented 1 year ago

The goal is not to reduce the number of lines in a Dockerfile and it isn't specific to Debian or Ubuntu. We want to reduce the amount and the disk space taken of dependencies for all Linux distributions, as much as possible, for both the toolchain and Swift applications and libraries built by users of the Swift toolchain.

futurejones commented 1 year ago

@shahmishal @MaxDesiatov Are we discussing the installation of the swift toolchain on linux or the creation of docker images? They have very different end goals and requirements.