Skip to content

Amazon Linux 2023 / x64 / release/5.8 #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions platforms/Linux/DEB/Shared/versions.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

debversion=5.7.1
debversion=5.8.1

swift_version=5.7.1-RELEASE
swift_version=5.8.1-RELEASE
icu_version=65-1
yams_version=4.0.2
swift_argument_parser_version=1.0.3
swift_crypto_version=1.1.5
swift_crypto_version=2.2.3
ninja_version=1.10.2
cmake_version=3.19.6
swift_atomics_version=1.0.2
Expand Down
31 changes: 31 additions & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

FROM amazonlinux:2023
LABEL PURPOSE="This image is configured to build Swift for the version of Amazon Linux listed above"

RUN dnf -y update

# RPM and yum development tools
RUN dnf install -y rpmdevtools yum-utils createrepo

# Compile ld.gold from the source and install it.
ADD install_ld.gold.sh /tmp/install_ld.gold.sh
RUN chmod u+x /tmp/install_ld.gold.sh
RUN cd tmp && ./install_ld.gold.sh

# Optimization: Install Swift build requirements listed in the spec file
ADD swiftlang.spec /tmp/swiftlang.spec

# rewrite a minimal spec with the build requirements
RUN echo -e "Name: optimization\nVersion: optimization\nRelease: optimization\nSummary: optimization\nLicense: optimization\n" > /tmp/optimization.spec
RUN cat /tmp/swiftlang.spec | grep BuildRequires >> /tmp/optimization.spec
RUN echo -e "\n%description" >> /tmp/optimization.spec
# install the build requirements
RUN cd /tmp && yum-builddep -y optimization.spec

31 changes: 31 additions & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Swift on Amazon Linux


### building with docker-compose

* to run the build end-to-end

```
docker-compose run build
```

* to enter the docker env in shell mode

```
docker-compose run shell
```

then you can run `./build_rpm.sh` to run the build manually inside the docker


* to rebuild the base image

```
docker-compose build --pull
```

note this still uses the docker cache, so will rebuild only if the version of the underlying base image changed upstream


### Open Issues / TODO
* the list of build requirements (BuildRequires) and especially requirements (Requires) should come from an external file, likely one per swift release version (which we can use it to also drive documentation)
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/build_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/createrepo_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/description.inc
47 changes: 47 additions & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

# this setup is designed to build the RPM with docker
# usage:
# docker-compose -f platforms/Linux/amazonlinux/2/docker-compose.yaml build
# to shell into the container for debugging purposes:
# docker-compose -f platforms/Linux/amazonlinux/2/docker-compose.yaml run build

version: "3"

services:

docker-setup:
image: amazonlinux-2023-rpm-builder
build:
context: .
dockerfile: Dockerfile

common: &common
image: amazonlinux-2023-rpm-builder
depends_on: [docker-setup]
volumes:
- ../../Amazonlinux/2023:/code/Amazonlinux/2023:z
- ../../Shared:/code/Shared:z
- ./.output:/output:z
working_dir: /code/Amazonlinux/2023
cap_drop:
- CAP_NET_RAW
- CAP_NET_BIND_SERVICE

build:
<<: *common
command: /bin/bash -cl "./build_rpm.sh"

createrepo:
<<: *common
command: /bin/bash -cl "./createrepo_rpm.sh"

shell:
<<: *common
entrypoint: /bin/bash -l
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/global.inc
16 changes: 16 additions & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dnf install gmp-devel mpfr-devel texinfo bison git gcc-c++ -y

mkdir ld.gold && cd ld.gold
git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils

mkdir build && cd build
../binutils/configure --enable-gold --enable-plugins --disable-werror
make all-gold
cd gold
make all-am
cd ..

cp gold/ld-new /usr/bin/ld.gold
cd ../..

/usr/bin/ld.gold -v
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/metadata.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize b/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
index dd5f859561e1..21d18998cf31 100755
--- a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
+++ b/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#===- lib/hwasan/scripts/hwasan_symbolize ----------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
169 changes: 169 additions & 0 deletions platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
%include global.inc
%include metadata.inc

Source0: https://github.com/apple/swift/archive/swift-%{swift_version}.tar.gz#/swift.tar.gz
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swift_version}.tar.gz#/corelibs-libdispatch.tar.gz
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swift_version}.tar.gz#/corelibs-foundation.tar.gz
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swift_version}.tar.gz#/swift-integration-tests.tar.gz
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swift_version}.tar.gz#/corelibs-xctest.tar.gz
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swift_version}.tar.gz#/package-manager.tar.gz
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swift_version}.tar.gz#/llbuild.tar.gz
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}.tar.gz#/cmark.tar.gz
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swift_version}.tar.gz#/swift-xcode-playground-support.tar.gz
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swift_version}.tar.gz#/sourcekit-lsp.tar.gz
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swift_version}.tar.gz#/indexstore-db.tar.gz
Source11: https://github.com/apple/llvm-project/archive/swift-%{swift_version}.tar.gz#/llvm-project.tar.gz
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swift_version}.tar.gz#/swift-tools-support-core.tar.gz
Source13: https://github.com/apple/swift-argument-parser/archive/%{swift_argument_parser_version}.tar.gz#/swift-argument-parser.tar.gz
Source14: https://github.com/apple/swift-driver/archive/swift-%{swift_version}.tar.gz#/swift-driver.tar.gz
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz#/icu.tar.gz
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swift_version}.zip#/swift-syntax.tar.gz
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.tar.gz#/yams.tar.gz
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz#/swift-crypto.tar.gz
Source19: https://github.com/ninja-build/ninja/archive/refs/tags/v%{ninja_version}.tar.gz#/ninja.tar.gz
Source20: https://github.com/KitWare/CMake/archive/refs/tags/v%{cmake_version}.tar.gz#/cmake.tar.gz
Source21: https://github.com/apple/swift-atomics/archive/%{swift_atomics_version}.tar.gz#/swift-atomics.tar.gz
Source23: https://github.com/apple/swift-docc/archive/swift-%{swift_version}.tar.gz#/swift-docc.tar.gz
Source24: https://github.com/apple/swift-docc-render-artifact/archive/swift-%{swift_version}.tar.gz#/swift-docc-render-artifact.tar.gz
Source25: https://github.com/apple/swift-docc-symbolkit/archive/swift-%{swift_version}.tar.gz#/swift-docc-symbolkit.tar.gz
Source26: https://github.com/apple/swift-collections/archive/%{swift_collections_version}.tar.gz#/swift-collections.tar.gz
Source27: https://github.com/apple/swift-numerics/archive/%{swift_numerics_version}.tar.gz#/swift-numerics.tar.gz
Source28: https://github.com/apple/swift-system/archive/%{swift_system_version}.tar.gz#/swift-system.tar.gz
Source29: https://github.com/apple/swift-nio/archive/%{swift_nio_version}.tar.gz#/swift-nio.tar.gz
Source30: https://github.com/apple/swift-nio-ssl/archive/%{swift_nio_ssl_version}.tar.gz#/swift-nio-ssl.tar.gz
Source31: https://github.com/apple/swift-format/archive/swift-%{swift_version}.tar.gz#/swift-format.tar.gz
Source32: https://github.com/apple/swift-lmdb/archive/swift-%{swift_version}.tar.gz#/swift-lmdb.tar.gz
Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_version}.tar.gz#/swift-markdown.tar.gz
Source34: https://github.com/apple/swift-experimental-string-processing/archive/swift-%{swift_version}.tar.gz#/swift-experimental-string-processing.tar.gz

Patch0: patches/hwasan_symbolize.patch

BuildRequires: clang
BuildRequires: curl-devel
BuildRequires: gcc-c++
BuildRequires: git
BuildRequires: glibc-static
BuildRequires: libbsd-devel
BuildRequires: libedit-devel
BuildRequires: libicu-devel
BuildRequires: libuuid-devel
BuildRequires: libxml2-devel
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: python-pexpect
BuildRequires: pkgconfig
BuildRequires: procps-ng
BuildRequires: python
BuildRequires: python-devel
BuildRequires: python3-pkgconfig
BuildRequires: python-six
BuildRequires: python3-devel
BuildRequires: rsync
BuildRequires: sqlite-devel
BuildRequires: swig
BuildRequires: tzdata
BuildRequires: uuid-devel
BuildRequires: wget
BuildRequires: which

Requires: binutils
Requires: gcc
Requires: git
Requires: glibc-static
Requires: gzip
Requires: libbsd
Requires: libcurl-devel
Requires: libedit
Requires: libicu
Requires: libstdc++-static
Requires: libuuid
Requires: libxml2-devel
Requires: sqlite
Requires: tar
Requires: tzdata
Requires: unzip
Requires: zip

ExclusiveArch: x86_64 aarch64

%description
%include description.inc

%prep
%setup -q -c -n %{swift_source_location} -a 0 -a 1 -a 2 -a 3 -a 4 -a 5 -a 6 -a 7 -a 8 -a 9 -a 10 -a 11 -a 12 -a 13 -a 14 -a 15 -a 16 -a 17 -a 18 -a 19 -a 20 -a 21 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33 -a 34

# The Swift build script requires directories to be named
# in a specific way so renaming the source directories is
# necessary
mv CMake-%{cmake_version} cmake
mv icu-release-%{icu_version} icu
mv indexstore-db-swift-%{swift_version} indexstore-db
mv llvm-project-swift-%{swift_version} llvm-project
mv ninja-%{ninja_version} ninja
mv sourcekit-lsp-swift-%{swift_version} sourcekit-lsp
mv swift-argument-parser-%{swift_argument_parser_version} swift-argument-parser
mv swift-atomics-%{swift_atomics_version} swift-atomics
mv swift-cmark-swift-%{swift_version} cmark
mv swift-collections-%{swift_collections_version} swift-collections
mv swift-corelibs-foundation-swift-%{swift_version} swift-corelibs-foundation
mv swift-corelibs-libdispatch-swift-%{swift_version} swift-corelibs-libdispatch
mv swift-corelibs-xctest-swift-%{swift_version} swift-corelibs-xctest
mv swift-crypto-%{swift_crypto_version} swift-crypto
mv swift-docc-render-artifact-swift-%{swift_version} swift-docc-render-artifact
mv swift-docc-swift-%{swift_version} swift-docc
mv swift-docc-symbolkit-swift-%{swift_version} swift-docc-symbolkit
mv swift-driver-swift-%{swift_version} swift-driver
mv swift-format-swift-%{swift_version} swift-format
mv swift-integration-tests-swift-%{swift_version} swift-integration-tests
mv swift-llbuild-swift-%{swift_version} llbuild
mv swift-lmdb-swift-%{swift_version} swift-lmdb
mv swift-markdown-swift-%{swift_version} swift-markdown
mv swift-nio-%{swift_nio_version} swift-nio
mv swift-nio-ssl-%{swift_nio_ssl_version} swift-nio-ssl
mv swift-numerics-%{swift_numerics_version} swift-numerics
mv swift-package-manager-swift-%{swift_version} swiftpm
mv swift-swift-%{swift_version} swift
mv swift-syntax-swift-%{swift_version} swift-syntax
mv swift-system-%{swift_system_version} swift-system
mv swift-tools-support-core-swift-%{swift_version} swift-tools-support-core
mv swift-xcode-playground-support-swift-%{swift_version} swift-xcode-playground-support
mv Yams-%{yams_version} yams
mv swift-experimental-string-processing-swift-%{swift_version} swift-experimental-string-processing

# Adjust python version hwasan_symbolize
%patch0 -p1

%build
export VERBOSE=1
# the flags positioned by rpmbuild conflict with the ones set by build-script. It causes this error:
# /BUILD/swift-source/build/buildbot_linux/llvm-linux-x86_64/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
# I tried this, but it does not change anything:
# export LDFLAGS="-Wl,-L/usr/lib64 ${LDFLAGS}"
# so, I decided to get rid of all rpmbuild's flags
unset CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS CC CXX

# Run the build
swift/utils/build-script --preset=buildbot_linux,no_assertions,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-amazonlinux2023.tar.gz

%install
mkdir -p %{buildroot}%{_libexecdir}/swift/%{package_version}
cp -r %{_builddir}/usr/* %{buildroot}%{_libexecdir}/swift/%{package_version}
mkdir -p %{buildroot}%{_bindir}
ln -fs %{_libexecdir}/swift/%{package_version}/bin/swift %{buildroot}%{_bindir}/swift
ln -fs %{_libexecdir}/swift/%{package_version}/bin/swiftc %{buildroot}%{_bindir}/swiftc
ln -fs %{_libexecdir}/swift/%{package_version}/bin/sourcekit-lsp %{buildroot}%{_bindir}/sourcekit-lsp
mkdir -p %{buildroot}%{_mandir}/man1
cp %{_builddir}/usr/share/man/man1/swift.1 %{buildroot}%{_mandir}/man1/swift.1

%files
%license swift/LICENSE.txt
%{_bindir}/swift
%{_bindir}/swiftc
%{_bindir}/sourcekit-lsp
%{_mandir}/man1/swift.1.gz
%{_libexecdir}/swift/

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog
8 changes: 4 additions & 4 deletions platforms/Linux/RPM/Shared/metadata/global.inc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# versions

%global package_version 5.7.1
%global swift_version 5.7.1-RELEASE
%global package_version 5.8.1
%global swift_version 5.8.1-RELEASE

%global cmake_version 3.19.6
%global icu_version 65-1
%global ninja_version 1.10.2
%global swift_argument_parser_version 1.0.3
%global swift_atomics_version 1.0.2
%global swift_collections_version 1.0.1
%global swift_crypto_version 1.1.5
%global swift_crypto_version 2.2.3
%global swift_nio_ssl_version 2.15.0
%global swift_nio_version 2.31.2
%global swift_numerics_version 1.0.1
%global swift_system_version 1.1.1
%global yams_version 4.0.2
%global yams_version 5.0.1

# locations

Expand Down
Loading