From 1ba28ce29cbe5831c4ce7ee197dbcdd28a09929b Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Fri, 24 Nov 2023 23:54:59 +0000 Subject: [PATCH 1/7] RPM build scripts for Amazon Linux 2023, x64, Swift 5.8 --- .../Linux/RPM/Amazonlinux/2023/Dockerfile | 31 ++++ .../Linux/RPM/Amazonlinux/2023/README.md | 31 ++++ .../Linux/RPM/Amazonlinux/2023/build_rpm.sh | 1 + .../RPM/Amazonlinux/2023/createrepo_rpm.sh | 1 + .../RPM/Amazonlinux/2023/description.inc | 1 + .../RPM/Amazonlinux/2023/docker-compose.yaml | 47 +++++ .../Linux/RPM/Amazonlinux/2023/global.inc | 1 + .../RPM/Amazonlinux/2023/install_ld.gold.sh | 16 ++ .../Linux/RPM/Amazonlinux/2023/metadata.inc | 1 + .../2023/patches/hwasan_symbolize.patch | 10 ++ .../Linux/RPM/Amazonlinux/2023/swiftlang.spec | 169 ++++++++++++++++++ 11 files changed, 309 insertions(+) create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/Dockerfile create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/README.md create mode 120000 platforms/Linux/RPM/Amazonlinux/2023/build_rpm.sh create mode 120000 platforms/Linux/RPM/Amazonlinux/2023/createrepo_rpm.sh create mode 120000 platforms/Linux/RPM/Amazonlinux/2023/description.inc create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml create mode 120000 platforms/Linux/RPM/Amazonlinux/2023/global.inc create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh create mode 120000 platforms/Linux/RPM/Amazonlinux/2023/metadata.inc create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/patches/hwasan_symbolize.patch create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile new file mode 100644 index 00000000..6d71508b --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile @@ -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 + diff --git a/platforms/Linux/RPM/Amazonlinux/2023/README.md b/platforms/Linux/RPM/Amazonlinux/2023/README.md new file mode 100644 index 00000000..396edfbe --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/README.md @@ -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) diff --git a/platforms/Linux/RPM/Amazonlinux/2023/build_rpm.sh b/platforms/Linux/RPM/Amazonlinux/2023/build_rpm.sh new file mode 120000 index 00000000..e83f0881 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/build_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/build_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/createrepo_rpm.sh b/platforms/Linux/RPM/Amazonlinux/2023/createrepo_rpm.sh new file mode 120000 index 00000000..11c58fd2 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/createrepo_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/createrepo_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/description.inc b/platforms/Linux/RPM/Amazonlinux/2023/description.inc new file mode 120000 index 00000000..a880ccf4 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/description.inc @@ -0,0 +1 @@ +../../Shared/metadata/description.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml new file mode 100644 index 00000000..0a1124c4 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml @@ -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 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/global.inc b/platforms/Linux/RPM/Amazonlinux/2023/global.inc new file mode 120000 index 00000000..bee5c7e7 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/global.inc @@ -0,0 +1 @@ +../../Shared/metadata/global.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh b/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh new file mode 100644 index 00000000..d1c2fcb2 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh @@ -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 \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/metadata.inc b/platforms/Linux/RPM/Amazonlinux/2023/metadata.inc new file mode 120000 index 00000000..e0ad3078 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/metadata.inc @@ -0,0 +1 @@ +../../Shared/metadata/metadata.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/patches/hwasan_symbolize.patch b/platforms/Linux/RPM/Amazonlinux/2023/patches/hwasan_symbolize.patch new file mode 100644 index 00000000..3f323825 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/patches/hwasan_symbolize.patch @@ -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. diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec new file mode 100644 index 00000000..ac71ef33 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec @@ -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 From fd6ce9a61fe14648cdf40edfa85cf8a3c8cc93d7 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Thu, 15 Feb 2024 09:16:57 +0100 Subject: [PATCH 2/7] refresh for 5.9 --- .../Linux/RPM/Amazonlinux/2023/Dockerfile | 10 + .../Linux/RPM/Amazonlinux/2023/global-5.8.inc | 25 +++ .../Linux/RPM/Amazonlinux/2023/global-5.9.inc | 25 +++ .../RPM/Amazonlinux/2023/install_ld.gold.sh | 10 + .../2023/patches/build-presets.patch | 16 ++ .../RPM/Amazonlinux/2023/swiftlang-5.8.spec | 173 ++++++++++++++++++ .../RPM/Amazonlinux/2023/swiftlang-5.9.spec | 173 ++++++++++++++++++ .../Linux/RPM/Amazonlinux/2023/swiftlang.spec | 170 +---------------- 8 files changed, 433 insertions(+), 169 deletions(-) create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec mode change 100644 => 120000 platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile index 6d71508b..0494704e 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile @@ -29,3 +29,13 @@ RUN echo -e "\n%description" >> /tmp/optimization.spec # install the build requirements RUN cd /tmp && yum-builddep -y optimization.spec +# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}pwd +# ADD swiftlang.spec /root/rpmbuild/SPECS/swiftlang.spec +# ADD description-tmp.inc /root/rpmbuild/SPECS/description.inc +# ADD global-tmp.inc /root/rpmbuild/SPECS/global.inc +# ADD metadata-tmp.inc /root/rpmbuild/SPECS/metadata.inc +# ADD patches/hwasan_symbolize.patch /root/rpmbuild/SOURCES/ +# ADD patches/llvm-graviton.patch /root/rpmbuild/SOURCES/ +# WORKDIR /root/rpmbuild/SPECS +# RUN yum-builddep -y ./swiftlang.spec +# RUN spectool -g -R ./swiftlang.spec diff --git a/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc b/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc new file mode 100644 index 00000000..49eb2d1f --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc @@ -0,0 +1,25 @@ +# versions + +%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 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 5.0.1 + +# locations + +%global swift_source_location swift-source + +# other + +%global debug_package %{nil} diff --git a/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc b/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc new file mode 100644 index 00000000..95c237fa --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc @@ -0,0 +1,25 @@ +# versions + +%global package_version 5.9.1 +%global swift_version 5.9.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.2.2 +%global swift_atomics_version 1.0.2 +%global swift_collections_version 1.0.1 +%global swift_crypto_version 2.5.0 +%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 5.0.1 + +# locations + +%global swift_source_location swift-source + +# other + +%global debug_package %{nil} diff --git a/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh b/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh index d1c2fcb2..50fdfa92 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh +++ b/platforms/Linux/RPM/Amazonlinux/2023/install_ld.gold.sh @@ -1,3 +1,13 @@ +# 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 + +#!/usr/bin/env bash + dnf install gmp-devel mpfr-devel texinfo bison git gcc-c++ -y mkdir ld.gold && cd ld.gold diff --git a/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch b/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch new file mode 100644 index 00000000..788eeaea --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch @@ -0,0 +1,16 @@ +diff --git a/swift/utils/build-presets.ini b/swift/utils/build-presets.ini +index 1d1a17b1f0b..229ff2a19d6 100644 +--- a/swift/utils/build-presets.ini ++++ b/swift/utils/build-presets.ini +@@ -916,6 +916,11 @@ mixin-preset= + buildbot_linux,no_assertions + mixin_buildbot_linux,no_test + ++[preset: buildbot_amazon_linux_2023,no_assertions,no_test] ++skip-early-swift-driver ++mixin-preset= ++ buildbot_linux,no_assertions ++ mixin_buildbot_linux,no_test + + [preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build] + mixin-preset= \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec new file mode 100644 index 00000000..17a52068 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec @@ -0,0 +1,173 @@ +%include global-5.8.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 +Patch1: build-presets.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 + +# Add a Swift build preset to compile on AmazonLinux 2023 +%patch1 -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 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec new file mode 100644 index 00000000..60b2b231 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec @@ -0,0 +1,173 @@ +%include global-5.9.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 +Source22: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}-gfm.tar.gz#/swift-cmark-gfm.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: 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: lld +BuildRequires: make +BuildRequires: ncurses-devel +BuildRequires: ninja-build +BuildRequires: pkgconfig +BuildRequires: procps-ng +BuildRequires: python +BuildRequires: python-devel +BuildRequires: python-pexpect +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: lld +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 22 -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-cmark-swift-%{swift_version}-gfm swift-cmark-gfm +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 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec deleted file mode 100644 index ac71ef33..00000000 --- a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec +++ /dev/null @@ -1,169 +0,0 @@ -%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 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec new file mode 120000 index 00000000..647a050c --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang.spec @@ -0,0 +1 @@ +swiftlang-5.8.spec \ No newline at end of file From 3bb0ec57bd338d57ca749b81bac8e853bc1ba2f1 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Thu, 15 Feb 2024 16:56:01 +0100 Subject: [PATCH 3/7] add instructions to build Swift 5.9 --- .../2023/{Dockerfile => Dockerfile-5.8} | 2 +- .../Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 | 45 +++++++++++++++++ .../Linux/RPM/Amazonlinux/2023/README.md | 50 +++++++++++++++---- ...r-compose.yaml => docker-compose-5.8.yaml} | 6 +-- .../Amazonlinux/2023/docker-compose-5.9.yaml | 47 +++++++++++++++++ .../Linux/RPM/Amazonlinux/2023/global-5.8.inc | 4 +- .../Linux/RPM/Amazonlinux/2023/global-5.9.inc | 2 + .../2023/patches/build-presets.patch | 16 ------ .../RPM/Amazonlinux/2023/swiftlang-5.9.spec | 13 ++--- 9 files changed, 144 insertions(+), 41 deletions(-) rename platforms/Linux/RPM/Amazonlinux/2023/{Dockerfile => Dockerfile-5.8} (96%) create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 rename platforms/Linux/RPM/Amazonlinux/2023/{docker-compose.yaml => docker-compose-5.8.yaml} (90%) create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.9.yaml delete mode 100644 platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 similarity index 96% rename from platforms/Linux/RPM/Amazonlinux/2023/Dockerfile rename to platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 index 0494704e..89c3b160 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 @@ -29,7 +29,7 @@ RUN echo -e "\n%description" >> /tmp/optimization.spec # install the build requirements RUN cd /tmp && yum-builddep -y optimization.spec -# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}pwd +# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} # ADD swiftlang.spec /root/rpmbuild/SPECS/swiftlang.spec # ADD description-tmp.inc /root/rpmbuild/SPECS/description.inc # ADD global-tmp.inc /root/rpmbuild/SPECS/global.inc diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 new file mode 100644 index 00000000..6b8c482b --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 @@ -0,0 +1,45 @@ +# 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" + +# 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 + +# Add Swift 5.8 (be sure to have a link to your Swift tar.gz file) +# ADD a tar.gz files automatically decompress and expand it +# to be replaced by a download from Swift.org when it will be available +ADD swift-5.8-amazonlinux2023.tar.gz / +RUN swift --version + +# 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 + +# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} +# ADD swiftlang.spec /root/rpmbuild/SPECS/swiftlang.spec +# ADD description-tmp.inc /root/rpmbuild/SPECS/description.inc +# ADD global-tmp.inc /root/rpmbuild/SPECS/global.inc +# ADD metadata-tmp.inc /root/rpmbuild/SPECS/metadata.inc +# ADD patches/hwasan_symbolize.patch /root/rpmbuild/SOURCES/ +# ADD patches/llvm-graviton.patch /root/rpmbuild/SOURCES/ +# WORKDIR /root/rpmbuild/SPECS +# RUN yum-builddep -y ./swiftlang.spec +# RUN spectool -g -R ./swiftlang.spec diff --git a/platforms/Linux/RPM/Amazonlinux/2023/README.md b/platforms/Linux/RPM/Amazonlinux/2023/README.md index 396edfbe..6ad944d7 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/README.md +++ b/platforms/Linux/RPM/Amazonlinux/2023/README.md @@ -1,31 +1,59 @@ -# Building Swift on Amazon Linux +# Building Swift on Amazon Linux 2023 +## Install docker -### building with docker-compose +```sh +sudo dnf install docker -y +sudo usermod -a -G docker ec2-user +sudo newgrp docker +sudo systemctl enable docker.service +sudo systemctl start docker.service +``` -* to run the build end-to-end +## Install docker compose v2 +```sh +DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} +mkdir -p $DOCKER_CONFIG/cli-plugins +curl -SL https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose +chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose ``` -docker-compose run build + +## Select the swift version to build + +Create a symlink `swiftlang.spec -> swiftlang-VERSION.spec` + +For example, to build Swift 5.9 : + +```sh +SWIFT_VERSION=5.9 +rm swiftlang.spec +ln -s swiftlang-${SWIFT)_VERSION}.spec swiftlang.spec ``` -* to enter the docker env in shell mode +## Building with docker-compose + +### run the build end-to-end +```sh +docker compose -f docker-compose-${SWIFT_VERSION}.yaml run build ``` -docker-compose run shell + +### enter the docker env in shell mode + +```sh +docker compose -f docker-compose-${SWIFT_VERSION}.yaml run shell ``` then you can run `./build_rpm.sh` to run the build manually inside the docker +### rebuild the base image -* to rebuild the base image - -``` -docker-compose build --pull +```sh +docker compose -f docker-compose-${SWIFT_VERSION}.yaml 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) diff --git a/platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.8.yaml similarity index 90% rename from platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml rename to platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.8.yaml index 0a1124c4..8ff1f232 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/docker-compose.yaml +++ b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.8.yaml @@ -17,13 +17,13 @@ version: "3" services: docker-setup: - image: amazonlinux-2023-rpm-builder + image: amazonlinux-2023-rpm-builder-5.8 build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile-5.8 common: &common - image: amazonlinux-2023-rpm-builder + image: amazonlinux-2023-rpm-builder-5.8 depends_on: [docker-setup] volumes: - ../../Amazonlinux/2023:/code/Amazonlinux/2023:z diff --git a/platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.9.yaml b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.9.yaml new file mode 100644 index 00000000..ea626343 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/docker-compose-5.9.yaml @@ -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-5.9 + build: + context: . + dockerfile: Dockerfile-5.9 + + common: &common + image: amazonlinux-2023-rpm-builder-5.9 + 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 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc b/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc index 49eb2d1f..1128b4c6 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc +++ b/platforms/Linux/RPM/Amazonlinux/2023/global-5.8.inc @@ -1,7 +1,7 @@ # versions -%global package_version 5.8.1 -%global swift_version 5.8.1-RELEASE +%global package_version 5.8 +%global swift_version 5.8-RELEASE %global cmake_version 3.19.6 %global icu_version 65-1 diff --git a/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc b/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc index 95c237fa..384e6f90 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc +++ b/platforms/Linux/RPM/Amazonlinux/2023/global-5.9.inc @@ -14,6 +14,8 @@ %global swift_nio_version 2.31.2 %global swift_numerics_version 1.0.1 %global swift_system_version 1.1.1 +%global swift_asn1_version 0.7.0 +%global swift_certificates_version 0.4.1 %global yams_version 5.0.1 # locations diff --git a/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch b/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch deleted file mode 100644 index 788eeaea..00000000 --- a/platforms/Linux/RPM/Amazonlinux/2023/patches/build-presets.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/swift/utils/build-presets.ini b/swift/utils/build-presets.ini -index 1d1a17b1f0b..229ff2a19d6 100644 ---- a/swift/utils/build-presets.ini -+++ b/swift/utils/build-presets.ini -@@ -916,6 +916,11 @@ mixin-preset= - buildbot_linux,no_assertions - mixin_buildbot_linux,no_test - -+[preset: buildbot_amazon_linux_2023,no_assertions,no_test] -+skip-early-swift-driver -+mixin-preset= -+ buildbot_linux,no_assertions -+ mixin_buildbot_linux,no_test - - [preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build] - mixin-preset= \ No newline at end of file diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec index 60b2b231..ac7ce3b6 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec @@ -23,7 +23,7 @@ Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_ 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 -Source22: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}-gfm.tar.gz#/swift-cmark-gfm.tar.gz +Source22: https://github.com/apple/swift-asn1/archive/%{swift_asn1_version}.tar.gz#/swift-asn1.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 @@ -36,8 +36,7 @@ Source31: https://github.com/apple/swift-format/archive/swift-%{swift_vers 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: hwasan_symbolize.patch +Source35: https://github.com/apple/swift-certificates/archive/%{swift_certificates_version}.tar.gz#/swift-certificates.tar.gz BuildRequires: clang BuildRequires: curl-devel @@ -93,7 +92,7 @@ ExclusiveArch: x86_64 aarch64 %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 22 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33 -a 34 +%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 22 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33 -a 34 -a 35 # The Swift build script requires directories to be named # in a specific way so renaming the source directories is @@ -107,7 +106,7 @@ 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-cmark-swift-%{swift_version}-gfm swift-cmark-gfm +mv swift-asn1-%{swift_asn1_version} swift-asn1 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 @@ -133,9 +132,7 @@ 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 +mv swift-certificates-%{swift_certificates_version} swift-certificates %build export VERBOSE=1 From b135bfb6977175fc44541518509c30dfce776a21 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Thu, 15 Feb 2024 17:03:38 +0100 Subject: [PATCH 4/7] remove patch on build presets --- platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec index 17a52068..4323e7e7 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec @@ -37,7 +37,6 @@ Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_ve 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 -Patch1: build-presets.patch BuildRequires: clang BuildRequires: curl-devel @@ -134,9 +133,6 @@ mv swift-experimental-string-processing-swift-%{swift_version} swift-experimenta # Adjust python version hwasan_symbolize %patch0 -p1 -# Add a Swift build preset to compile on AmazonLinux 2023 -%patch1 -p1 - %build export VERBOSE=1 # the flags positioned by rpmbuild conflict with the ones set by build-script. It causes this error: From 7d10177a9d8c643d5dff6d15720160d08cb45705 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Thu, 15 Feb 2024 17:18:25 +0100 Subject: [PATCH 5/7] simplify dockerfiles --- .../Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 | 11 ----------- .../Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 | 17 +++-------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 index 89c3b160..91394916 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 @@ -28,14 +28,3 @@ 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 - -# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} -# ADD swiftlang.spec /root/rpmbuild/SPECS/swiftlang.spec -# ADD description-tmp.inc /root/rpmbuild/SPECS/description.inc -# ADD global-tmp.inc /root/rpmbuild/SPECS/global.inc -# ADD metadata-tmp.inc /root/rpmbuild/SPECS/metadata.inc -# ADD patches/hwasan_symbolize.patch /root/rpmbuild/SOURCES/ -# ADD patches/llvm-graviton.patch /root/rpmbuild/SOURCES/ -# WORKDIR /root/rpmbuild/SPECS -# RUN yum-builddep -y ./swiftlang.spec -# RUN spectool -g -R ./swiftlang.spec diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 index 6b8c482b..4bce554a 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 @@ -17,9 +17,9 @@ 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 -# Add Swift 5.8 (be sure to have a link to your Swift tar.gz file) -# ADD a tar.gz files automatically decompress and expand it -# to be replaced by a download from Swift.org when it will be available +# Add Swift 5.8 (be sure to have the Swift tar.gz file) +# ADD a tar.gz files automatically decompresses and expands it +# TODO: replace with a download from Swift.org when it will be available ADD swift-5.8-amazonlinux2023.tar.gz / RUN swift --version @@ -32,14 +32,3 @@ 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 - -# RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} -# ADD swiftlang.spec /root/rpmbuild/SPECS/swiftlang.spec -# ADD description-tmp.inc /root/rpmbuild/SPECS/description.inc -# ADD global-tmp.inc /root/rpmbuild/SPECS/global.inc -# ADD metadata-tmp.inc /root/rpmbuild/SPECS/metadata.inc -# ADD patches/hwasan_symbolize.patch /root/rpmbuild/SOURCES/ -# ADD patches/llvm-graviton.patch /root/rpmbuild/SOURCES/ -# WORKDIR /root/rpmbuild/SPECS -# RUN yum-builddep -y ./swiftlang.spec -# RUN spectool -g -R ./swiftlang.spec From 5723a95f72097c2d5a84708e2eda9ccbc13544be Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sat, 17 Feb 2024 13:00:43 +0100 Subject: [PATCH 6/7] add diffutils to container image in case one builds with tests --- platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 | 4 +--- platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 index 91394916..cc673429 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.8 @@ -9,10 +9,8 @@ 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 +RUN dnf install -y rpmdevtools yum-utils createrepo diffutils # Compile ld.gold from the source and install it. ADD install_ld.gold.sh /tmp/install_ld.gold.sh diff --git a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 index 4bce554a..14cc278c 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 +++ b/platforms/Linux/RPM/Amazonlinux/2023/Dockerfile-5.9 @@ -10,7 +10,7 @@ FROM amazonlinux:2023 LABEL PURPOSE="This image is configured to build Swift for the version of Amazon Linux listed above" # RPM and yum development tools -RUN dnf install -y rpmdevtools yum-utils createrepo +RUN dnf install -y rpmdevtools yum-utils createrepo diffutils # Compile ld.gold from the source and install it. ADD install_ld.gold.sh /tmp/install_ld.gold.sh From a336bd4238f5d07d93934cbdb7395554766329a2 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sun, 18 Feb 2024 09:26:14 +0100 Subject: [PATCH 7/7] add patch to compile on graviton --- .../Amazonlinux/2023/patches/llvm-graviton.patch | 13 +++++++++++++ .../Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec | 4 ++++ .../Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 platforms/Linux/RPM/Amazonlinux/2023/patches/llvm-graviton.patch diff --git a/platforms/Linux/RPM/Amazonlinux/2023/patches/llvm-graviton.patch b/platforms/Linux/RPM/Amazonlinux/2023/patches/llvm-graviton.patch new file mode 100644 index 00000000..ae293ea1 --- /dev/null +++ b/platforms/Linux/RPM/Amazonlinux/2023/patches/llvm-graviton.patch @@ -0,0 +1,13 @@ +diff --git a/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp b/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp +index 750b3c386753..fbf312908476 100644 +--- a/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2143,7 +2143,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( + static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; + static const char *const AArch64Triples[] = { + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", +- "aarch64-suse-linux"}; ++ "aarch64-suse-linux", "aarch64-amazon-linux"}; + static const char *const AArch64beLibDirs[] = {"/lib"}; + static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", + "aarch64_be-linux-gnu"}; diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec index 4323e7e7..710ff550 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.8.spec @@ -37,6 +37,7 @@ Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_ve 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 +Patch1: patches/llvm-graviton.patch BuildRequires: clang BuildRequires: curl-devel @@ -133,6 +134,9 @@ mv swift-experimental-string-processing-swift-%{swift_version} swift-experimenta # Adjust python version hwasan_symbolize %patch0 -p1 +# Add Amazon Linux aarch64 triplet +%patch1 -p1 + %build export VERBOSE=1 # the flags positioned by rpmbuild conflict with the ones set by build-script. It causes this error: diff --git a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec index ac7ce3b6..383fa369 100644 --- a/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec +++ b/platforms/Linux/RPM/Amazonlinux/2023/swiftlang-5.9.spec @@ -38,6 +38,8 @@ Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_ve Source34: https://github.com/apple/swift-experimental-string-processing/archive/swift-%{swift_version}.tar.gz#/swift-experimental-string-processing.tar.gz Source35: https://github.com/apple/swift-certificates/archive/%{swift_certificates_version}.tar.gz#/swift-certificates.tar.gz +Patch1: patches/llvm-graviton.patch + BuildRequires: clang BuildRequires: curl-devel BuildRequires: gcc-c++ @@ -134,6 +136,9 @@ mv Yams-%{yams_version} yams mv swift-experimental-string-processing-swift-%{swift_version} swift-experimental-string-processing mv swift-certificates-%{swift_certificates_version} swift-certificates +# Add Amazon Linux aarch64 triplet +%patch1 -p1 + %build export VERBOSE=1 # the flags positioned by rpmbuild conflict with the ones set by build-script. It causes this error: