Skip to content
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

Initial Swift 4 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Swift 4

## New dependencies
* libatomic
* libBlocksRuntime

## Requirements
* To be compiled on Fedora 25 because gcc-7 is not supported yet on Fedora 26
* libBlocksRuntime installed from RPM or local archive

# Runtime
* Environment variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH needed because https://bugs.swift.org/browse/SR-5524
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# swift-rpm
Swift RPM for Fedora.

## Requirements
To be compiled on Fedora 25 because gcc-7 is not supported yet on Fedora 26.

### Dependencies
libatomic and libBlocksRuntime are now needed too.

The official Fedora RPM for libBlocksRuntime-devel doesn't exist yet.
Unless the libBlocksRuntime RPM is installed by alternative ways, the [./libblocksruntime-0.1.gz](archive with headers and dynamic library files compiled on Fedora 25)
will be installed.

In later case the library are not registered to RPM's database and the resulting RPM package to be installed without dependencies using
`rpm -ivh --nodeps`


## Install Swift RPM
If libBlocksRuntime is not provided add option ```--nodeps```

```bash
sudo dnf install libbsd python gcc-c++ clang
sudo rpm -Uvh swift-3.1-RELEASE3.1.x86_64.rpm
sudo dnf install libbsd python2 gcc-c++ clang
sudo rpm -Uvh swift-4.0-DEVELOPMENT

cat >> ~/.bashrc <<EOF
# Swift language - https://bugs.swift.org/browse/SR-5524
export C_INCLUDE_PATH=/usr/lib/swift/clang/include/
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
EOF
```
Tested on Fedora 22, 23, 24, 25 - 64 bits.

Tested on Fedora 25, 26 - 64 bits.

## Run a RPM build

To build a new tag version of swift edit rpm-from-source.sh and change TAG, REL and VER accordingly.
```bash
./rpm-from-source.sh
```
## Issues
lldb is compiled but CLI has characters issues (maybe libicu version) - This seems same issue as on Swift-3.1 rpm.
Binary file added libblocksruntime_0.1.tgz
Binary file not shown.
78 changes: 44 additions & 34 deletions rpm-from-source.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
echo on
sudo dnf install -y rpm-build ninja-build clang libicu-devel gcc-c++ cmake libuuid-devel libedit-devel swig pkgconfig libbsd-devel libxml2-devel libsqlite3x-devel python-devel autoconf automake libtool libcurl-devel
sudo ln -s /usr/bin/ninja-build /usr/bin/ninja

RPMTOPDIR=~/rpmbuild
mkdir -p $RPMTOPDIR/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
TAG=3.1-RELEASE
VER=3.1
REL=RELEASE3.1

wget https://github.com/apple/swift/archive/swift-${TAG}.tar.gz -O swift.tar.gz
mv swift.tar.gz $RPMTOPDIR/SOURCES/swift.tar.gz
wget https://github.com/apple/swift-corelibs-foundation/archive/swift-${TAG}.tar.gz -O corelibs-foundation.tar.gz
mv corelibs-foundation.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-integration-tests/archive/swift-${TAG}.tar.gz -O swift-integration-tests.tar.gz
mv swift-integration-tests.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-corelibs-xctest/archive/swift-${TAG}.tar.gz -O corelibs-xctest.tar.gz
mv corelibs-xctest.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-clang/archive/swift-${TAG}.tar.gz -O clang.tar.gz
mv clang.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-package-manager/archive/swift-${TAG}.tar.gz -O package-manager.tar.gz
mv package-manager.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-lldb/archive/swift-${TAG}.tar.gz -O lldb.tar.gz
mv lldb.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-llvm/archive/swift-${TAG}.tar.gz -O llvm.tar.gz
mv llvm.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-llbuild/archive/swift-${TAG}.tar.gz -O llbuild.tar.gz
mv llbuild.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/apple/swift-cmark/archive/swift-${TAG}.tar.gz -O cmark.tar.gz
mv cmark.tar.gz $RPMTOPDIR/SOURCES/
wget https://github.com/ninja-build/ninja/archive/v1.7.2.tar.gz -O ninja.tar.gz
mv ninja.tar.gz $RPMTOPDIR/SOURCES/
sed -e "s/%{ver}/$VER/" -e "s/%{rel}/$REL/" -e "s/%{tag}/$TAG/" swift.spec > $RPMTOPDIR/SPECS/swift.spec
rpmbuild -ba $RPMTOPDIR/SPECS/swift.spec
echo on
RPMROOTDIR=~/rpmbuild
VER=4.0
BRANCH=swift-${VER}-branch
REL=DEVELOPMENT

# Dependencies
sudo dnf install -y rpm-build wget git clang libicu-devel gcc-c++ cmake libuuid-devel libedit-devel swig pkgconfig libbsd-devel libxml2-devel libsqlite3x-devel python-devel autoconf automake libtool libcurl-devel libatomic
# Might not be needed anymore since it's also pulled by git in build
sudo dnf install -y ninja-build

# libBlocksRuntime
ldd /usr/lib64/libBlocksRuntime.so.0
if [[ $? -ne 0 ]]
then
cp libblocksruntime_0.1.tgz /tmp/
sudo sh -c 'cd /; tar xzvf /tmp/libblocksruntime_0.1.tgz'
sudo ldconfig
rm -f /tmp/libblocksruntime_0.1.tgz
fi

# Fails if libBlocksRuntime not installed
ldd /usr/lib64/libBlocksRuntime.so.0
[[ $? -ne 0 ]] && exit

# rpm -ivh libatomic-7.1.1-6.fc27.x86_64.rpm

mkdir -p $RPMROOTDIR/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

wget https://github.com/apple/swift/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/swift.tar.gz
wget https://github.com/apple/swift-corelibs-foundation/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/corelibs-foundation.tar.gz
wget https://github.com/apple/swift-integration-tests/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/swift-integration-tests.tar.gz
wget https://github.com/apple/swift-corelibs-xctest/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/corelibs-xctest.tar.gz
wget https://github.com/apple/swift-clang/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/clang.tar.gz
wget https://github.com/apple/swift-package-manager/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/package-manager.tar.gz
wget https://github.com/apple/swift-lldb/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/lldb.tar.gz
wget https://github.com/apple/swift-llvm/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/llvm.tar.gz
wget https://github.com/apple/swift-llbuild/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/llbuild.tar.gz
wget https://github.com/apple/swift-cmark/archive/${BRANCH}.tar.gz -O $RPMROOTDIR/SOURCES/cmark.tar.gz

cp *.patch ${RPMROOTDIR}/SOURCES/

sed -e "s/%{ver}/$VER/" -e "s/%{rel}/$REL/" -e "s/%{branch}/$BRANCH/" swift.spec > $RPMROOTDIR/SPECS/swift.spec
rpmbuild -ba $RPMROOTDIR/SPECS/swift.spec
54 changes: 54 additions & 0 deletions swift-fedora.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff -ru swift-orig/lib/Basic/Version.cpp swift/lib/Basic/Version.cpp
--- swift-orig/lib/Basic/Version.cpp 2017-08-07 12:21:34.150036560 +1000
+++ swift/lib/Basic/Version.cpp 2017-08-07 12:22:07.662904723 +1000
@@ -386,31 +386,7 @@
OS << SWIFT_VENDOR " ";
#endif

- OS << "Swift version " SWIFT_VERSION_STRING;
-#ifndef SWIFT_COMPILER_VERSION
- OS << "-dev";
-#endif
-
- if (!(effectiveVersion == Version::getCurrentLanguageVersion())) {
- OS << " effective-" << effectiveVersion;
- }
-
-#if defined(SWIFT_COMPILER_VERSION)
- OS << " (swiftlang-" SWIFT_COMPILER_VERSION;
-#if defined(CLANG_COMPILER_VERSION)
- OS << " clang-" CLANG_COMPILER_VERSION;
-#endif
- OS << ")";
-#elif defined(LLVM_REVISION) || defined(CLANG_REVISION) || \
- defined(SWIFT_REVISION)
- OS << " (";
- printFullRevisionString(OS);
- OS << ")";
-#endif
-
- // Suppress unused function warning
- (void)&printFullRevisionString;
-
+ OS << "Swift version " SWIFT_VERSION_STRING " (swift-4.0-DEVELOPMENT)";
return OS.str();
}

diff -ru swift-orig/utils/build-script-impl swift/utils/build-script-impl
--- swift-orig/utils/build-script-impl 2017-08-07 12:21:34.345035793 +1000
+++ swift/utils/build-script-impl 2017-08-07 12:24:16.510397847 +1000
@@ -2431,10 +2431,13 @@
fi

with_pushd "${FOUNDATION_SOURCE_DIR}" \
+ export CFLAGS=-I${FOUNDATION_SOURCE_DIR}/closure
+ with_pushd "${FOUNDATION_SOURCE_DIR}" \
call env SWIFTC="${SWIFTC_BIN}" CLANG="${LLVM_BIN}"/clang SWIFT="${SWIFT_BIN}" \
SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" DSTROOT="$(get_host_install_destdir ${host})" PREFIX="$(get_host_install_prefix ${host})" ./configure "${FOUNDATION_BUILD_TYPE}" ${FOUNDATION_BUILD_ARGS[@]} -DXCTEST_BUILD_DIR=${XCTEST_BUILD_DIR} $LIBDISPATCH_BUILD_ARGS
with_pushd "${FOUNDATION_SOURCE_DIR}" \
call ${NINJA_BIN}
+ export CFLAGS=

# Foundation builds itself and doesn't use cmake
continue
Only in swift/utils: build-script-impl.rej
51 changes: 31 additions & 20 deletions swift.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ Source0: swift.tar.gz
Source1: clang.tar.gz
Source2: cmark.tar.gz
Source3: corelibs-foundation.tar.gz
# Explicitly commented out here as we get it from git below
#Source4: corelibs-libdispatch.tar.gz
Source4: corelibs-xctest.tar.gz
Source5: llbuild.tar.gz
Source6: lldb.tar.gz
Source7: llvm.tar.gz
Source8: package-manager.tar.gz
Patch0: %{name}-fedora.patch
BuildRoot: %{_tmppath}/%{name}-%{ver}-%{rel}

BuildRequires: clang,libicu-devel,gcc-c++,cmake,libuuid-devel,libedit-devel,swig,pkgconfig,libbsd-devel,libxml2-devel,libsqlite3x-devel,python-devel,ninja-build
Requires: clang,libicu-devel
Requires: clang,libicu-devel,libatomic

%description
Build apple swift compiler from source
Expand All @@ -35,40 +37,49 @@ gzip -dc ../SOURCES/llbuild.tar.gz | tar -xvvf -
gzip -dc ../SOURCES/lldb.tar.gz | tar -xvvf -
gzip -dc ../SOURCES/llvm.tar.gz | tar -xvvf -
gzip -dc ../SOURCES/package-manager.tar.gz | tar -xvvf -
gzip -dc ../SOURCES/ninja.tar.gz | tar -xvvf -
mv ninja-1.7.2 ninja
mv swift-swift-%{tag} swift
mv swift-integration-tests-swift-%{tag} swift-integration-tests
mv swift-clang-swift-%{tag} clang
mv swift-cmark-swift-%{tag} cmark
mv swift-corelibs-foundation-swift-%{tag} swift-corelibs-foundation
mv swift-corelibs-xctest-swift-%{tag} swift-corelibs-xctest
mv swift-llbuild-swift-%{tag} llbuild
mv swift-lldb-swift-%{tag} lldb
mv swift-llvm-swift-%{tag} llvm
mv swift-package-manager-swift-%{tag} swiftpm
# Explicit checkout of libdispatch so we can also initialize
# the submodules
mv swift-%{branch} swift
mv swift-integration-tests-%{branch} swift-integration-tests
mv swift-clang-%{branch} clang
mv swift-cmark-%{branch} cmark
mv swift-corelibs-foundation-%{branch} swift-corelibs-foundation
mv swift-corelibs-xctest-%{branch} swift-corelibs-xctest
mv swift-llbuild-%{branch} llbuild
mv swift-lldb-%{branch} lldb
mv swift-llvm-%{branch} llvm
mv swift-package-manager-%{branch} swiftpm

# Explicit checkout of ninja which we need to do, apparently starting with 3.1
git clone https://github.com/ninja-build/ninja.git ../BUILD/ninja
pushd ../BUILD/ninja
git checkout release
popd

# Explicit checkout of libdispatch so we can also initialize the submodules
git clone https://github.com/apple/swift-corelibs-libdispatch swift-corelibs-libdispatch
pushd swift-corelibs-libdispatch
git checkout %{branch}
git submodule init; git submodule update
popd

%patch0 -p0

%build
sed -e s/lib\${LLVM_LIBDIR_SUFFIX}/lib64/g lldb/scripts/CMakeLists.txt > CMakeLists.txt.tmp && mv CMakeLists.txt.tmp lldb/scripts/CMakeLists.txt

cd swift
# Modification of the build-presets.ini to comment out:
# * test
# * validation-test
# because those are currently failing. The other test
# because those are currently failing. The other test
# is left in place and Swift builds and runs successfully
# at the end.
sed -i.bak "s/^test/#test/g" ./utils/build-presets.ini
sed -i.bak "s/^validation-test/#validation-test/g" ./utils/build-presets.ini
./utils/build-script --preset=buildbot_linux install_destdir=%{buildroot} installable_package=%{buildroot}/swift-%{ver}-%{rel}-fedora24.tar.gz

./utils/build-script --preset=buildbot_linux install_destdir=%{buildroot} installable_package=%{buildroot}/swift-%{ver}-%{rel}-fedora.tar.gz
# Moving the tar file out of the way
cp %{buildroot}/swift-%{ver}-%{rel}-fedora24.tar.gz ~
rm %{buildroot}/swift-%{ver}-%{rel}-fedora24.tar.gz
cp %{buildroot}/swift-%{ver}-%{rel}-fedora.tar.gz ~
rm %{buildroot}/swift-%{ver}-%{rel}-fedora.tar.gz

%files
%defattr(-, root, root)
Expand All @@ -82,7 +93,7 @@ rm %{buildroot}/swift-%{ver}-%{rel}-fedora24.tar.gz
%clean
echo "DATAROOTDIR==" %{_datarootdir}
echo "BUILDROOT=" %{buildroot}
rm -rf %{buildroot}
#rm -rf %{buildroot}

#The changelog is built automatically from Git history
%changelog